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
include AccessMatchersForController
describe 'GET edit' do
let(:action) do
proc do |user|
get :edit, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id
end
it { expect { go }.to be_allowed_for(:admin) }
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
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
let(:action) do
proc do |user|
post :take_ownership, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id
end
it { expect { go }.to be_allowed_for(:admin) }
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
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
let(:action) do
proc do |user|
put :update, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id,
schedule: {
description: 'a'
}
end
it { expect { go }.to be_allowed_for(:admin) }
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,
schedule: {
description: 'a'
}
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
......@@ -52,8 +52,8 @@ module AccessMatchersForController
matcher :be_allowed_for do |role|
match do |action|
user = emulate_user(role, @membership)
action.call(user)
emulate_user(role, @membership)
action.call
EXPECTED_STATUS_CODE_ALLOWED.include?(response.status)
end
......@@ -68,8 +68,8 @@ module AccessMatchersForController
matcher :be_denied_for do |role|
match do |action|
user = emulate_user(role, @membership)
action.call(user)
emulate_user(role, @membership)
action.call
EXPECTED_STATUS_CODE_DENIED.include?(response.status)
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