debian-mirror-gitlab/spec/controllers/import/google_code_controller_spec.rb

60 lines
1.7 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require 'spec_helper'
describe Import::GoogleCodeController do
2015-09-11 14:41:01 +05:30
include ImportSpecHelper
2015-04-26 12:48:37 +05:30
let(:user) { create(:user) }
2018-11-08 19:23:39 +05:30
let(:dump_file) { fixture_file_upload('spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') }
2015-04-26 12:48:37 +05:30
before do
sign_in(user)
end
describe "POST callback" do
it "stores Google Takeout dump list in session" do
2019-02-15 15:39:39 +05:30
post :callback, params: { dump_file: dump_file }
2015-04-26 12:48:37 +05:30
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-09-11 14:41:01 +05:30
stub_client(valid?: true)
2015-04-26 12:48:37 +05:30
end
it "assigns variables" do
2017-09-10 17:25:29 +05:30
@project = create(:project, import_type: 'google_code', creator_id: user.id)
2015-09-11 14:41:01 +05:30
stub_client(repos: [@repo], incompatible_repos: [])
2015-04-26 12:48:37 +05:30
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([@repo])
2015-09-11 14:41:01 +05:30
expect(assigns(:incompatible_repos)).to eq([])
2015-04-26 12:48:37 +05:30
end
it "does not show already added project" do
2017-09-10 17:25:29 +05:30
@project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
2015-09-11 14:41:01 +05:30
stub_client(repos: [@repo], incompatible_repos: [])
2015-04-26 12:48:37 +05:30
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([])
end
2015-09-11 14:41:01 +05:30
it "does not show any invalid projects" do
stub_client(repos: [], incompatible_repos: [@repo])
get :status
expect(assigns(:repos)).to be_empty
expect(assigns(:incompatible_repos)).to eq([@repo])
end
2015-04-26 12:48:37 +05:30
end
end