Fix static analysys

This commit is contained in:
Shinya Maeda 2017-06-06 02:29:34 +09:00 committed by Shinya Maeda
parent e9734c6df3
commit 359d72ba3e
2 changed files with 13 additions and 13 deletions

View file

@ -90,7 +90,7 @@ describe Projects::PipelineSchedulesController do
describe 'GET edit' 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
end
end
@ -108,7 +108,7 @@ describe Projects::PipelineSchedulesController do
describe 'GET take_ownership' 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
end
end
@ -126,7 +126,7 @@ describe Projects::PipelineSchedulesController do
describe 'PUT update' 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
end
end

View file

@ -5,14 +5,22 @@ module AccessMatchersForController
extend RSpec::Matchers::DSL
include Warden::Test::Helpers
EXPECTED_STATUS_CODE_ALLOWED = [200, 302]
EXPECTED_STATUS_CODE_DENIED = [404]
EXPECTED_STATUS_CODE_ALLOWED = [200, 302].freeze
EXPECTED_STATUS_CODE_DENIED = [404].freeze
def emulate_user(role, membership = nil)
case role
when :admin
user = create(:admin)
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
raise ArgumentError, "cannot emulate #{role} without membership parent" unless membership
@ -24,14 +32,6 @@ module AccessMatchersForController
end
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
raise ArgumentError, "cannot emulate user #{role}"
end