Commit 359d72ba authored by Shinya Maeda's avatar Shinya Maeda Committed by Shinya Maeda

Fix static analysys

parent e9734c6d
...@@ -90,7 +90,7 @@ describe Projects::PipelineSchedulesController do ...@@ -90,7 +90,7 @@ describe Projects::PipelineSchedulesController do
describe 'GET edit' do describe 'GET edit' do
let(:action) do let(:action) do
Proc.new do |user| proc do |user|
get :edit, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id get :edit, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id
end end
end end
...@@ -108,7 +108,7 @@ describe Projects::PipelineSchedulesController do ...@@ -108,7 +108,7 @@ describe Projects::PipelineSchedulesController do
describe 'GET take_ownership' do describe 'GET take_ownership' do
let(:action) do let(:action) do
Proc.new do |user| proc do |user|
post :take_ownership, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id post :take_ownership, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id
end end
end end
...@@ -126,7 +126,7 @@ describe Projects::PipelineSchedulesController do ...@@ -126,7 +126,7 @@ describe Projects::PipelineSchedulesController do
describe 'PUT update' do describe 'PUT update' do
let(:action) do let(:action) do
Proc.new do |user| proc do |user|
put :update, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id put :update, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id
end end
end end
......
...@@ -5,14 +5,22 @@ module AccessMatchersForController ...@@ -5,14 +5,22 @@ module AccessMatchersForController
extend RSpec::Matchers::DSL extend RSpec::Matchers::DSL
include Warden::Test::Helpers include Warden::Test::Helpers
EXPECTED_STATUS_CODE_ALLOWED = [200, 302] EXPECTED_STATUS_CODE_ALLOWED = [200, 302].freeze
EXPECTED_STATUS_CODE_DENIED = [404] EXPECTED_STATUS_CODE_DENIED = [404].freeze
def emulate_user(role, membership = nil) def emulate_user(role, membership = nil)
case role case role
when :admin when :admin
user = create(:admin) user = create(:admin)
sign_in(user) sign_in(user)
when :user
user = create(:user)
sign_in(user)
when :external
user = create(:user, external: true)
sign_in(user)
when :visitor # rubocop:disable Lint/EmptyWhen
# no-op
when *Gitlab::Access.sym_options_with_owner.keys # owner, master, developer, reporter, guest when *Gitlab::Access.sym_options_with_owner.keys # owner, master, developer, reporter, guest
raise ArgumentError, "cannot emulate #{role} without membership parent" unless membership raise ArgumentError, "cannot emulate #{role} without membership parent" unless membership
...@@ -24,14 +32,6 @@ module AccessMatchersForController ...@@ -24,14 +32,6 @@ module AccessMatchersForController
end end
sign_in(user) sign_in(user)
when :user
user = create(:user)
sign_in(user)
when :external
user = create(:user, external: true)
sign_in(user)
when :visitor
# no-op
else else
raise ArgumentError, "cannot emulate user #{role}" raise ArgumentError, "cannot emulate user #{role}"
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