Commit c8b80247 authored by Robert Speicher's avatar Robert Speicher

Enable the RSpec/HookArgument cop and auto-correct offenses

parent 4ef10795
...@@ -1099,6 +1099,11 @@ RSpec/FilePath: ...@@ -1099,6 +1099,11 @@ RSpec/FilePath:
RSpec/Focus: RSpec/Focus:
Enabled: true Enabled: true
# Checks the arguments passed to `before`, `around`, and `after`.
RSpec/HookArgument:
Enabled: true
EnforcedStyle: implicit
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: is_expected, should # SupportedStyles: is_expected, should
RSpec/ImplicitExpect: RSpec/ImplicitExpect:
......
...@@ -70,12 +70,6 @@ RSpec/EmptyLineAfterFinalLet: ...@@ -70,12 +70,6 @@ RSpec/EmptyLineAfterFinalLet:
RSpec/EmptyLineAfterSubject: RSpec/EmptyLineAfterSubject:
Enabled: false Enabled: false
# Offense count: 78
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Enabled: false
# Offense count: 9 # Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: it_behaves_like, it_should_behave_like # SupportedStyles: it_behaves_like, it_should_behave_like
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
YAML.load(output) YAML.load(output)
end end
before(:each) do before do
stub_env('GITLAB_REDIS_QUEUES_CONFIG_FILE', absolute_path(queues_config_path)) stub_env('GITLAB_REDIS_QUEUES_CONFIG_FILE', absolute_path(queues_config_path))
clear_queues_raw_config clear_queues_raw_config
end end
after(:each) do after do
clear_queues_raw_config clear_queues_raw_config
end end
......
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
end end
context 'authorized projects without admin_issue ability' do context 'authorized projects without admin_issue ability' do
before(:each) do before do
authorized_project.add_guest(user) authorized_project.add_guest(user)
expect(user.can?(:admin_issue, authorized_project)).to eq(false) expect(user.can?(:admin_issue, authorized_project)).to eq(false)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
let(:user_params) { { user: { name: 'new_user', username: 'new_username', email: 'new@user.com', password: 'Any_password' } } } let(:user_params) { { user: { name: 'new_user', username: 'new_username', email: 'new@user.com', password: 'Any_password' } } }
context 'email confirmation' do context 'email confirmation' do
around(:each) do |example| around do |example|
perform_enqueued_jobs do perform_enqueued_jobs do
example.run example.run
end end
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
TestEnv.clean_test_path TestEnv.clean_test_path
end end
after(:example) do after do
TestEnv.clean_test_path TestEnv.clean_test_path
end end
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
context 'when visit with */* as accept header' do context 'when visit with */* as accept header' do
before(:each) do before do
page.driver.add_header('Accept', '*/*') page.driver.add_header('Accept', '*/*')
end end
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs } let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs }
before(:each) do before do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
end end
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
end end
end end
before(:each) do before do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
end end
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
end end
context 'with an unfolded line' do context 'with an unfolded line' do
before(:each) do before do
find('.js-unfold', match: :first).click find('.js-unfold', match: :first).click
wait_for_requests wait_for_requests
end end
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
end end
context 'with an unfolded line' do context 'with an unfolded line' do
before(:each) do before do
find('.js-unfold', match: :first).click find('.js-unfold', match: :first).click
wait_for_requests wait_for_requests
end end
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
TestEnv.clean_test_path TestEnv.clean_test_path
end end
after(:example) do after do
TestEnv.clean_test_path TestEnv.clean_test_path
end end
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
end end
after(:each) do after do
FileUtils.rm_rf(export_path, secure: true) FileUtils.rm_rf(export_path, secure: true)
end end
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
TestEnv.clean_test_path TestEnv.clean_test_path
end end
after(:example) do after do
TestEnv.clean_test_path TestEnv.clean_test_path
end end
...@@ -107,11 +107,11 @@ ...@@ -107,11 +107,11 @@
TestEnv.clean_test_path TestEnv.clean_test_path
end end
before(:example) do before do
group.add_owner(user) group.add_owner(user)
end end
after(:example) do after do
TestEnv.clean_test_path TestEnv.clean_test_path
end end
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
end end
describe 'trigger "Take ownership" workflow' do describe 'trigger "Take ownership" workflow' do
before(:each) do before do
create(:ci_trigger, owner: user2, project: @project, description: trigger_title) create(:ci_trigger, owner: user2, project: @project, description: trigger_title)
visit project_settings_ci_cd_path(@project) visit project_settings_ci_cd_path(@project)
end end
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
end end
describe 'trigger "Revoke" workflow' do describe 'trigger "Revoke" workflow' do
before(:each) do before do
create(:ci_trigger, owner: user2, project: @project, description: trigger_title) create(:ci_trigger, owner: user2, project: @project, description: trigger_title)
visit project_settings_ci_cd_path(@project) visit project_settings_ci_cd_path(@project)
end end
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
let(:loading_icon) { '.fa.fa-spinner' } let(:loading_icon) { '.fa.fa-spinner' }
let(:username_input) { 'new_user_username' } let(:username_input) { 'new_user_username' }
before(:each) do before do
visit new_user_session_path visit new_user_session_path
click_link 'Register' click_link 'Register'
end end
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
clean_frontend_fixtures('abuse_reports/') clean_frontend_fixtures('abuse_reports/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('blob/') clean_frontend_fixtures('blob/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('boards/') clean_frontend_fixtures('boards/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('branches/') clean_frontend_fixtures('branches/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('dashboard/') clean_frontend_fixtures('dashboard/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
clean_frontend_fixtures('deploy_keys/') clean_frontend_fixtures('deploy_keys/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
clean_frontend_fixtures('environments/metrics') clean_frontend_fixtures('environments/metrics')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('issues/') clean_frontend_fixtures('issues/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
clean_frontend_fixtures('builds/') clean_frontend_fixtures('builds/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do
render_views render_views
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
describe Projects::LabelsController, '(JavaScript fixtures)', type: :controller do describe Projects::LabelsController, '(JavaScript fixtures)', type: :controller do
render_views render_views
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
clean_frontend_fixtures('merge_requests/') clean_frontend_fixtures('merge_requests/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
clean_frontend_fixtures('merge_request_diffs/') clean_frontend_fixtures('merge_request_diffs/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
clean_frontend_fixtures('pipelines/') clean_frontend_fixtures('pipelines/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
clean_frontend_fixtures('projects/') clean_frontend_fixtures('projects/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
clean_frontend_fixtures('services/prometheus') clean_frontend_fixtures('services/prometheus')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
clean_frontend_fixtures('services/') clean_frontend_fixtures('services/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
clean_frontend_fixtures('snippets/') clean_frontend_fixtures('snippets/')
end end
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
describe Dashboard::TodosController, '(JavaScript fixtures)', type: :controller do describe Dashboard::TodosController, '(JavaScript fixtures)', type: :controller do
render_views render_views
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
describe Projects::TodosController, '(JavaScript fixtures)', type: :controller do describe Projects::TodosController, '(JavaScript fixtures)', type: :controller do
render_views render_views
before(:each) do before do
sign_in(admin) sign_in(admin)
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
allow(Kernel).to receive(:at_exit) allow(Kernel).to receive(:at_exit)
end end
after(:each) do after do
described_class.instance_variable_set(:@instance, nil) described_class.instance_variable_set(:@instance, nil)
end end
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
let(:data) { described_class.build(note, user) } let(:data) { described_class.build(note, user) }
let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors let(:fixed_time) { Time.at(1425600000) } # Avoid time precision errors
before(:each) do before do
expect(data).to have_key(:object_attributes) expect(data).to have_key(:object_attributes)
expect(data[:object_attributes]).to have_key(:url) expect(data[:object_attributes]).to have_key(:url)
expect(data[:object_attributes][:url]) expect(data[:object_attributes][:url])
......