diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-10 21:12:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-10 21:12:35 +0300 |
commit | 6fd750c19206412cfc52b49a70b56147d839c52f (patch) | |
tree | 04607e6c9864c09dd312d6bfc3efe9cc5f81c762 /spec/controllers | |
parent | 26881dd926cfac47c9603d44e8d5a504ab8c4a14 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
4 files changed, 17 insertions, 17 deletions
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb index f0aa351bee0..cf528b414c0 100644 --- a/spec/controllers/dashboard/todos_controller_spec.rb +++ b/spec/controllers/dashboard/todos_controller_spec.rb @@ -62,7 +62,7 @@ RSpec.describe Dashboard::TodosController do create(:issue, project: project, assignees: [user]) group_2 = create(:group) group_2.add_owner(user) - project_2 = create(:project) + project_2 = create(:project, namespace: user.namespace) project_2.add_developer(user) merge_request_2 = create(:merge_request, source_project: project_2) create(:todo, project: project, author: author, user: user, target: merge_request_2) diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb index 3d7636b1f30..5b1c6777523 100644 --- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb @@ -86,10 +86,11 @@ RSpec.describe Projects::MergeRequests::DiffsController do let(:project) { create(:project, :repository) } let(:user) { create(:user) } + let(:maintainer) { true } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } before do - project.add_maintainer(user) + project.add_maintainer(user) if maintainer sign_in(user) end @@ -383,8 +384,9 @@ RSpec.describe Projects::MergeRequests::DiffsController do end context 'when the user cannot view the merge request' do + let(:maintainer) { false } + before do - project.team.truncate diff_for_path(old_path: existing_path, new_path: existing_path) end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 438fc2f2106..e2fc867db44 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -10,7 +10,8 @@ RSpec.describe Projects::MergeRequestsController do let_it_be_with_reload(:project_public_with_private_builds) { create(:project, :repository, :public, :builds_private) } let(:user) { project.owner } - let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } + let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: merge_request_source_project, allow_maintainer_to_push: false) } + let(:merge_request_source_project) { project } before do sign_in(user) @@ -2073,8 +2074,6 @@ RSpec.describe Projects::MergeRequestsController do end describe 'POST #rebase' do - let(:viewer) { user } - def post_rebase post :rebase, params: { namespace_id: project.namespace, project_id: project, id: merge_request } end @@ -2085,7 +2084,7 @@ RSpec.describe Projects::MergeRequestsController do context 'successfully' do it 'enqeues a RebaseWorker' do - expect_rebase_worker_for(viewer) + expect_rebase_worker_for(user) post_rebase @@ -2108,17 +2107,17 @@ RSpec.describe Projects::MergeRequestsController do context 'with a forked project' do let(:forked_project) { fork_project(project, fork_owner, repository: true) } let(:fork_owner) { create(:user) } + let(:merge_request_source_project) { forked_project } - before do - project.add_developer(fork_owner) + context 'user cannot push to source branch' do + before do + project.add_developer(fork_owner) - merge_request.update!(source_project: forked_project) - forked_project.add_reporter(user) - end + forked_project.add_reporter(user) + end - context 'user cannot push to source branch' do it 'returns 404' do - expect_rebase_worker_for(viewer).never + expect_rebase_worker_for(user).never post_rebase diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index a25c597edb2..baf500c2b57 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -499,13 +499,12 @@ RSpec.describe RegistrationsController do expect(User.last.name).to eq("#{base_user_params[:first_name]} #{base_user_params[:last_name]}") end - it 'sets the username and caller_id in the context' do + it 'sets the caller_id in the context' do expect(controller).to receive(:create).and_wrap_original do |m, *args| m.call(*args) expect(Gitlab::ApplicationContext.current) - .to include('meta.user' => base_user_params[:username], - 'meta.caller_id' => 'RegistrationsController#create') + .to include('meta.caller_id' => 'RegistrationsController#create') end subject |