summaryrefslogtreecommitdiff
path: root/spec/controllers/import
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-03 15:29:27 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-03 15:29:27 +0200
commit7b5bc32cadbf2c0a3ac1e80643e46786fd8b1b56 (patch)
tree0dfa9add1156d8ce9ff8709e36da577b7c94ad1c /spec/controllers/import
parent9157985cfce1391973673ea278dc7506a90f8f53 (diff)
downloadgitlab-ce-7b5bc32cadbf2c0a3ac1e80643e46786fd8b1b56.tar.gz
Allow projects to be imported from Google Code.
Diffstat (limited to 'spec/controllers/import')
-rw-r--r--spec/controllers/import/google_code_controller_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/import/google_code_controller_spec.rb b/spec/controllers/import/google_code_controller_spec.rb
new file mode 100644
index 00000000000..037cddb4600
--- /dev/null
+++ b/spec/controllers/import/google_code_controller_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe Import::GoogleCodeController do
+ let(:user) { create(:user) }
+ let(:dump_file) { fixture_file_upload(Rails.root + 'spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') }
+
+ before do
+ sign_in(user)
+ end
+
+ describe "POST callback" do
+ it "stores Google Takeout dump list in session" do
+ post :callback, dump_file: dump_file
+
+ 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')
+ controller.stub_chain(:client, :valid?).and_return(true)
+ end
+
+ it "assigns variables" do
+ @project = create(:project, import_type: 'google_code', creator_id: user.id)
+ controller.stub_chain(:client, :repos).and_return([@repo])
+
+ get :status
+
+ expect(assigns(:already_added_projects)).to eq([@project])
+ expect(assigns(:repos)).to eq([@repo])
+ end
+
+ it "does not show already added project" do
+ @project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
+ controller.stub_chain(:client, :repos).and_return([@repo])
+
+ get :status
+
+ expect(assigns(:already_added_projects)).to eq([@project])
+ expect(assigns(:repos)).to eq([])
+ end
+ end
+end