Commit 7c102c5d authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'dont-retry-controller-tests' into 'master'

Avoid retrying controller tests due to data not being reset

See merge request gitlab-org/gitlab!73560
parents fc702413 461b342d
...@@ -111,8 +111,8 @@ RSpec.describe RegistrationsController do ...@@ -111,8 +111,8 @@ RSpec.describe RegistrationsController do
end end
context 'when user registers for the instance' do context 'when user registers for the instance' do
it 'logs an audit event' do it 'logs add email event and instance access request event' do
expect { subject }.to change { AuditEvent.count }.by(1) expect { subject }.to change { AuditEvent.count }.by(2)
end end
it 'logs the audit event info', :aggregate_failures do it 'logs the audit event info', :aggregate_failures do
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
"reference", "reference",
"path", "path",
"relation_path", "relation_path",
"weight" "weight",
"blocked"
], ],
"properties": { "properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
"due_date": { "type": ["string", "null"] }, "due_date": { "type": ["string", "null"] },
"state": { "type": "string" }, "state": { "type": "string" },
"weight": { "type": ["integer", "null"] }, "weight": { "type": ["integer", "null"] },
"blocked": { "type": "boolean" },
"reference": { "type": "string" }, "reference": { "type": "string" },
"path": { "type": "string" }, "path": { "type": "string" },
"relation_path": { "type": "string" }, "relation_path": { "type": "string" },
......
...@@ -72,7 +72,7 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do ...@@ -72,7 +72,7 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true } } let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true } }
it 'creates a new project, a "Learn GitLab - Ultimate trial" project, does not set a cookie' do it 'creates a new project, a "Learn GitLab - Ultimate trial" project, does not set a cookie' do
expect { subject }.to change { namespace.projects.pluck(:name) }.from([]).to(['New project', s_('Learn GitLab - Ultimate trial')]) expect { subject }.to change { namespace.projects.pluck(:name).sort }.from([]).to(['New project', s_('Learn GitLab - Ultimate trial')].sort)
expect(subject).to have_gitlab_http_status(:redirect) expect(subject).to have_gitlab_http_status(:redirect)
expect(namespace.projects.find_by_name(s_('Learn GitLab - Ultimate trial'))).to be_import_finished expect(namespace.projects.find_by_name(s_('Learn GitLab - Ultimate trial'))).to be_import_finished
end end
......
...@@ -62,7 +62,7 @@ RSpec.describe Dashboard::TodosController do ...@@ -62,7 +62,7 @@ RSpec.describe Dashboard::TodosController do
create(:issue, project: project, assignees: [user]) create(:issue, project: project, assignees: [user])
group_2 = create(:group) group_2 = create(:group)
group_2.add_owner(user) group_2.add_owner(user)
project_2 = create(:project) project_2 = create(:project, namespace: user.namespace)
project_2.add_developer(user) project_2.add_developer(user)
merge_request_2 = create(:merge_request, source_project: project_2) merge_request_2 = create(:merge_request, source_project: project_2)
create(:todo, project: project, author: author, user: user, target: merge_request_2) create(:todo, project: project, author: author, user: user, target: merge_request_2)
......
...@@ -86,10 +86,11 @@ RSpec.describe Projects::MergeRequests::DiffsController do ...@@ -86,10 +86,11 @@ RSpec.describe Projects::MergeRequests::DiffsController do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:maintainer) { true }
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: project) }
before do before do
project.add_maintainer(user) project.add_maintainer(user) if maintainer
sign_in(user) sign_in(user)
end end
...@@ -383,8 +384,9 @@ RSpec.describe Projects::MergeRequests::DiffsController do ...@@ -383,8 +384,9 @@ RSpec.describe Projects::MergeRequests::DiffsController do
end end
context 'when the user cannot view the merge request' do context 'when the user cannot view the merge request' do
let(:maintainer) { false }
before do before do
project.team.truncate
diff_for_path(old_path: existing_path, new_path: existing_path) diff_for_path(old_path: existing_path, new_path: existing_path)
end end
......
...@@ -10,7 +10,8 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -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_it_be_with_reload(:project_public_with_private_builds) { create(:project, :repository, :public, :builds_private) }
let(:user) { project.owner } 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 before do
sign_in(user) sign_in(user)
...@@ -2073,8 +2074,6 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -2073,8 +2074,6 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'POST #rebase' do describe 'POST #rebase' do
let(:viewer) { user }
def post_rebase def post_rebase
post :rebase, params: { namespace_id: project.namespace, project_id: project, id: merge_request } post :rebase, params: { namespace_id: project.namespace, project_id: project, id: merge_request }
end end
...@@ -2085,7 +2084,7 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -2085,7 +2084,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'successfully' do context 'successfully' do
it 'enqeues a RebaseWorker' do it 'enqeues a RebaseWorker' do
expect_rebase_worker_for(viewer) expect_rebase_worker_for(user)
post_rebase post_rebase
...@@ -2108,17 +2107,17 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -2108,17 +2107,17 @@ RSpec.describe Projects::MergeRequestsController do
context 'with a forked project' do context 'with a forked project' do
let(:forked_project) { fork_project(project, fork_owner, repository: true) } let(:forked_project) { fork_project(project, fork_owner, repository: true) }
let(:fork_owner) { create(:user) } let(:fork_owner) { create(:user) }
let(:merge_request_source_project) { forked_project }
before do context 'user cannot push to source branch' do
project.add_developer(fork_owner) before do
project.add_developer(fork_owner)
merge_request.update!(source_project: forked_project) forked_project.add_reporter(user)
forked_project.add_reporter(user) end
end
context 'user cannot push to source branch' do
it 'returns 404' do it 'returns 404' do
expect_rebase_worker_for(viewer).never expect_rebase_worker_for(user).never
post_rebase post_rebase
......
...@@ -499,13 +499,12 @@ RSpec.describe RegistrationsController do ...@@ -499,13 +499,12 @@ RSpec.describe RegistrationsController do
expect(User.last.name).to eq("#{base_user_params[:first_name]} #{base_user_params[:last_name]}") expect(User.last.name).to eq("#{base_user_params[:first_name]} #{base_user_params[:last_name]}")
end 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| expect(controller).to receive(:create).and_wrap_original do |m, *args|
m.call(*args) m.call(*args)
expect(Gitlab::ApplicationContext.current) expect(Gitlab::ApplicationContext.current)
.to include('meta.user' => base_user_params[:username], .to include('meta.caller_id' => 'RegistrationsController#create')
'meta.caller_id' => 'RegistrationsController#create')
end end
subject subject
......
...@@ -197,6 +197,14 @@ RSpec.configure do |config| ...@@ -197,6 +197,14 @@ RSpec.configure do |config|
if ENV['CI'] || ENV['RETRIES'] if ENV['CI'] || ENV['RETRIES']
# This includes the first try, i.e. tests will be run 4 times before failing. # This includes the first try, i.e. tests will be run 4 times before failing.
config.default_retry_count = ENV.fetch('RETRIES', 3).to_i + 1 config.default_retry_count = ENV.fetch('RETRIES', 3).to_i + 1
# Do not retry controller tests because rspec-retry cannot properly
# reset the controller which may contain data from last attempt. See
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73360
config.around(:each, type: :controller) do |example|
example.run_with_retry(retry: 1)
end
config.exceptions_to_hard_fail = [DeprecationToolkitEnv::DeprecationBehaviors::SelectiveRaise::RaiseDisallowedDeprecation] config.exceptions_to_hard_fail = [DeprecationToolkitEnv::DeprecationBehaviors::SelectiveRaise::RaiseDisallowedDeprecation]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment