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
end
context 'when user registers for the instance' do
it 'logs an audit event' do
expect { subject }.to change { AuditEvent.count }.by(1)
it 'logs add email event and instance access request event' do
expect { subject }.to change { AuditEvent.count }.by(2)
end
it 'logs the audit event info', :aggregate_failures do
......
......@@ -12,7 +12,8 @@
"reference",
"path",
"relation_path",
"weight"
"weight",
"blocked"
],
"properties": {
"id": { "type": "integer" },
......@@ -23,6 +24,7 @@
"due_date": { "type": ["string", "null"] },
"state": { "type": "string" },
"weight": { "type": ["integer", "null"] },
"blocked": { "type": "boolean" },
"reference": { "type": "string" },
"path": { "type": "string" },
"relation_path": { "type": "string" },
......
......@@ -72,7 +72,7 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
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
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(namespace.projects.find_by_name(s_('Learn GitLab - Ultimate trial'))).to be_import_finished
end
......
......@@ -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)
......
......@@ -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
......
......@@ -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 }
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
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
......
......@@ -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
......
......@@ -197,6 +197,14 @@ RSpec.configure do |config|
if ENV['CI'] || ENV['RETRIES']
# 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
# 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]
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