2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-03 13:29:27 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Import::GoogleCodeController do
|
2015-05-21 21:40:13 +00:00
|
|
|
include ImportSpecHelper
|
|
|
|
|
2015-04-03 13:29:27 +00:00
|
|
|
let(:user) { create(:user) }
|
2018-06-05 21:18:06 +00:00
|
|
|
let(:dump_file) { fixture_file_upload('spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') }
|
2015-04-03 13:29:27 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST callback" do
|
|
|
|
it "stores Google Takeout dump list in session" do
|
2018-12-17 22:52:17 +00:00
|
|
|
post :callback, params: { dump_file: dump_file }
|
2015-04-03 13:29:27 +00:00
|
|
|
|
|
|
|
expect(session[:google_code_dump]).to be_a(Hash)
|
|
|
|
expect(session[:google_code_dump]["kind"]).to eq("projecthosting#user")
|
|
|
|
expect(session[:google_code_dump]).to have_key("projects")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET status" do
|
|
|
|
before do
|
|
|
|
@repo = OpenStruct.new(name: 'vim')
|
2015-05-21 21:40:13 +00:00
|
|
|
stub_client(valid?: true)
|
2015-04-03 13:29:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "assigns variables" do
|
2017-08-02 19:55:11 +00:00
|
|
|
@project = create(:project, import_type: 'google_code', creator_id: user.id)
|
2015-05-21 21:40:13 +00:00
|
|
|
stub_client(repos: [@repo], incompatible_repos: [])
|
2015-04-03 13:29:27 +00:00
|
|
|
|
|
|
|
get :status
|
|
|
|
|
|
|
|
expect(assigns(:already_added_projects)).to eq([@project])
|
|
|
|
expect(assigns(:repos)).to eq([@repo])
|
2015-04-29 07:33:49 +00:00
|
|
|
expect(assigns(:incompatible_repos)).to eq([])
|
2015-04-03 13:29:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not show already added project" do
|
2017-08-02 19:55:11 +00:00
|
|
|
@project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
|
2015-05-21 21:40:13 +00:00
|
|
|
stub_client(repos: [@repo], incompatible_repos: [])
|
2015-04-03 13:29:27 +00:00
|
|
|
|
|
|
|
get :status
|
|
|
|
|
|
|
|
expect(assigns(:already_added_projects)).to eq([@project])
|
|
|
|
expect(assigns(:repos)).to eq([])
|
|
|
|
end
|
2015-04-29 07:33:49 +00:00
|
|
|
|
|
|
|
it "does not show any invalid projects" do
|
2015-05-21 21:40:13 +00:00
|
|
|
stub_client(repos: [], incompatible_repos: [@repo])
|
2015-04-29 07:33:49 +00:00
|
|
|
|
|
|
|
get :status
|
|
|
|
|
|
|
|
expect(assigns(:repos)).to be_empty
|
|
|
|
expect(assigns(:incompatible_repos)).to eq([@repo])
|
|
|
|
end
|
2015-04-03 13:29:27 +00:00
|
|
|
end
|
2020-01-24 00:08:51 +00:00
|
|
|
|
|
|
|
describe "POST create" do
|
|
|
|
it_behaves_like 'project import rate limiter'
|
|
|
|
end
|
2015-04-03 13:29:27 +00:00
|
|
|
end
|