Fix remaining Bitbucket controller specs
This commit is contained in:
		
							parent
							
								
									af6926283b
								
							
						
					
					
						commit
						7953480646
					
				|  | @ -46,7 +46,7 @@ class Import::BitbucketController < Import::BaseController | |||
|     repo_owner = current_user.username if repo_owner == bitbucket_client.user.username | ||||
|     @target_namespace = params[:new_namespace].presence || repo_owner | ||||
| 
 | ||||
|     namespace = find_or_create_namespace(@target_namespace, repo_owner) | ||||
|     namespace = find_or_create_namespace(@target_namespace, current_user) | ||||
| 
 | ||||
|     if current_user.can?(:create_projects, namespace) | ||||
|       @project = Gitlab::BitbucketImport::ProjectCreator.new(repo, @project_name, namespace, current_user, credentials).execute | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ describe Import::BitbucketController do | |||
|   let(:token) { "asdasd12345" } | ||||
|   let(:secret) { "sekrettt" } | ||||
|   let(:refresh_token) { SecureRandom.hex(15) } | ||||
|   let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } } | ||||
|   let(:access_params) { { token: token, expires_at: nil, expires_in: nil, refresh_token: nil } } | ||||
| 
 | ||||
|   def assign_session_tokens | ||||
|     session[:bitbucket_token] = token | ||||
|  | @ -77,19 +77,16 @@ describe Import::BitbucketController do | |||
|     let(:bitbucket_username) { user.username } | ||||
| 
 | ||||
|     let(:bitbucket_user) do | ||||
|       { user: { username: bitbucket_username } }.with_indifferent_access | ||||
|       double(username: bitbucket_username) | ||||
|     end | ||||
| 
 | ||||
|     let(:bitbucket_repo) do | ||||
|       { slug: "vim", owner: bitbucket_username }.with_indifferent_access | ||||
|       double(slug: "vim", owner: bitbucket_username, name: 'vim') | ||||
|     end | ||||
| 
 | ||||
|     before do | ||||
|       allow(Gitlab::BitbucketImport::KeyAdder). | ||||
|         to receive(:new).with(bitbucket_repo, user, access_params). | ||||
|         and_return(double(execute: true)) | ||||
| 
 | ||||
|       stub_client(user: bitbucket_user, project: bitbucket_repo) | ||||
|       allow_any_instance_of(Bitbucket::Client).to receive(:repo).and_return(bitbucket_repo) | ||||
|       allow_any_instance_of(Bitbucket::Client).to receive(:user).and_return(bitbucket_user) | ||||
|       assign_session_tokens | ||||
|     end | ||||
| 
 | ||||
|  | @ -97,7 +94,7 @@ describe Import::BitbucketController do | |||
|       context "when the Bitbucket user and GitLab user's usernames match" do | ||||
|         it "takes the current user's namespace" do | ||||
|           expect(Gitlab::BitbucketImport::ProjectCreator). | ||||
|             to receive(:new).with(bitbucket_repo, user.namespace, user, access_params). | ||||
|             to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). | ||||
|             and_return(double(execute: true)) | ||||
| 
 | ||||
|           post :create, format: :js | ||||
|  | @ -109,7 +106,7 @@ describe Import::BitbucketController do | |||
| 
 | ||||
|         it "takes the current user's namespace" do | ||||
|           expect(Gitlab::BitbucketImport::ProjectCreator). | ||||
|             to receive(:new).with(bitbucket_repo, user.namespace, user, access_params). | ||||
|             to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). | ||||
|             and_return(double(execute: true)) | ||||
| 
 | ||||
|           post :create, format: :js | ||||
|  | @ -121,7 +118,7 @@ describe Import::BitbucketController do | |||
|       let(:other_username) { "someone_else" } | ||||
| 
 | ||||
|       before do | ||||
|         bitbucket_repo["owner"] = other_username | ||||
|         allow(bitbucket_repo).to receive(:owner).and_return(other_username) | ||||
|       end | ||||
| 
 | ||||
|       context "when a namespace with the Bitbucket user's username already exists" do | ||||
|  | @ -130,7 +127,7 @@ describe Import::BitbucketController do | |||
|         context "when the namespace is owned by the GitLab user" do | ||||
|           it "takes the existing namespace" do | ||||
|             expect(Gitlab::BitbucketImport::ProjectCreator). | ||||
|               to receive(:new).with(bitbucket_repo, existing_namespace, user, access_params). | ||||
|               to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params). | ||||
|               and_return(double(execute: true)) | ||||
| 
 | ||||
|             post :create, format: :js | ||||
|  | @ -163,7 +160,7 @@ describe Import::BitbucketController do | |||
| 
 | ||||
|           it "takes the new namespace" do | ||||
|             expect(Gitlab::BitbucketImport::ProjectCreator). | ||||
|               to receive(:new).with(bitbucket_repo, an_instance_of(Group), user, access_params). | ||||
|               to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params). | ||||
|               and_return(double(execute: true)) | ||||
| 
 | ||||
|             post :create, format: :js | ||||
|  | @ -184,7 +181,7 @@ describe Import::BitbucketController do | |||
| 
 | ||||
|           it "takes the current user's namespace" do | ||||
|             expect(Gitlab::BitbucketImport::ProjectCreator). | ||||
|               to receive(:new).with(bitbucket_repo, user.namespace, user, access_params). | ||||
|               to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). | ||||
|               and_return(double(execute: true)) | ||||
| 
 | ||||
|             post :create, format: :js | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue