Commit a513ae4a authored by Shinya Maeda's avatar Shinya Maeda

use go instead of let proc

parent 07b0615e
...@@ -89,60 +89,54 @@ describe Projects::PipelineSchedulesController do ...@@ -89,60 +89,54 @@ describe Projects::PipelineSchedulesController do
include AccessMatchersForController include AccessMatchersForController
describe 'GET edit' do describe 'GET edit' do
let(:action) do it { expect { go }.to be_allowed_for(:admin) }
proc do |user| it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:master).of(project) }
it { expect { go }.to be_allowed_for(:developer).of(project) }
it { expect { go }.to be_denied_for(:reporter).of(project) }
it { expect { go }.to be_denied_for(:guest).of(project) }
it { expect { go }.to be_denied_for(:user) }
it { expect { go }.to be_denied_for(:external) }
it { expect { go }.to be_denied_for(:visitor) }
def go
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
specify { expect(action).to be_allowed_for(:admin) }
specify { expect(action).to be_allowed_for(:owner).of(project) }
specify { expect(action).to be_allowed_for(:master).of(project) }
specify { expect(action).to be_allowed_for(:developer).of(project) }
specify { expect(action).to be_denied_for(:reporter).of(project) }
specify { expect(action).to be_denied_for(:guest).of(project) }
specify { expect(action).to be_denied_for(:user) }
specify { expect(action).to be_denied_for(:external) }
specify { expect(action).to be_denied_for(:visitor) }
end
describe 'GET take_ownership' do describe 'GET take_ownership' do
let(:action) do it { expect { go }.to be_allowed_for(:admin) }
proc do |user| it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:master).of(project) }
it { expect { go }.to be_allowed_for(:developer).of(project) }
it { expect { go }.to be_denied_for(:reporter).of(project) }
it { expect { go }.to be_denied_for(:guest).of(project) }
it { expect { go }.to be_denied_for(:user) }
it { expect { go }.to be_denied_for(:external) }
it { expect { go }.to be_denied_for(:visitor) }
def go
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
specify { expect(action).to be_allowed_for(:admin) }
specify { expect(action).to be_allowed_for(:owner).of(project) }
specify { expect(action).to be_allowed_for(:master).of(project) }
specify { expect(action).to be_allowed_for(:developer).of(project) }
specify { expect(action).to be_denied_for(:reporter).of(project) }
specify { expect(action).to be_denied_for(:guest).of(project) }
specify { expect(action).to be_denied_for(:user) }
specify { expect(action).to be_denied_for(:external) }
specify { expect(action).to be_denied_for(:visitor) }
end
describe 'PUT update' do describe 'PUT update' do
let(:action) do it { expect { go }.to be_allowed_for(:admin) }
proc do |user| it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:master).of(project) }
it { expect { go }.to be_allowed_for(:developer).of(project) }
it { expect { go }.to be_denied_for(:reporter).of(project) }
it { expect { go }.to be_denied_for(:guest).of(project) }
it { expect { go }.to be_denied_for(:user) }
it { expect { go }.to be_denied_for(:external) }
it { expect { go }.to be_denied_for(:visitor) }
def go
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,
schedule: { schedule: {
description: 'a' description: 'a'
} }
end end
end end
specify { expect(action).to be_allowed_for(:admin) }
specify { expect(action).to be_allowed_for(:owner).of(project) }
specify { expect(action).to be_allowed_for(:master).of(project) }
specify { expect(action).to be_allowed_for(:developer).of(project) }
specify { expect(action).to be_denied_for(:reporter).of(project) }
specify { expect(action).to be_denied_for(:guest).of(project) }
specify { expect(action).to be_denied_for(:user) }
specify { expect(action).to be_denied_for(:external) }
specify { expect(action).to be_denied_for(:visitor) }
end
end end
end end
...@@ -52,8 +52,8 @@ module AccessMatchersForController ...@@ -52,8 +52,8 @@ module AccessMatchersForController
matcher :be_allowed_for do |role| matcher :be_allowed_for do |role|
match do |action| match do |action|
user = emulate_user(role, @membership) emulate_user(role, @membership)
action.call(user) action.call
EXPECTED_STATUS_CODE_ALLOWED.include?(response.status) EXPECTED_STATUS_CODE_ALLOWED.include?(response.status)
end end
...@@ -68,8 +68,8 @@ module AccessMatchersForController ...@@ -68,8 +68,8 @@ module AccessMatchersForController
matcher :be_denied_for do |role| matcher :be_denied_for do |role|
match do |action| match do |action|
user = emulate_user(role, @membership) emulate_user(role, @membership)
action.call(user) action.call
EXPECTED_STATUS_CODE_DENIED.include?(response.status) EXPECTED_STATUS_CODE_DENIED.include?(response.status)
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