diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-11-06 16:20:44 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-11-06 16:20:44 +0300 |
commit | 9b58b8e363fd388635385085c58be3d4637eaa45 (patch) | |
tree | e348f8d2cf9030d59448cea3dbc459a29bbecf95 /spec/policies | |
parent | d4ceec9d47a7da5fa17cb6e161ac491e13fcb8bd (diff) |
Do not allow jobs to be erased
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/ci/build_policy_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/policies/ci/build_policy_spec.rb b/spec/policies/ci/build_policy_spec.rb index 8e1bc3d1543..e5d5e1017cd 100644 --- a/spec/policies/ci/build_policy_spec.rb +++ b/spec/policies/ci/build_policy_spec.rb @@ -150,5 +150,47 @@ describe Ci::BuildPolicy do end end end + + # TODO: Finish spec + describe 'rules for erase build' do + let(:project) { create(:project, :repository) } + let(:another_user) { create(:user) } + + context 'when developer created a build' do + before do + project.add_developer(user) + end + + context 'when the build was created by the user' do + let(:build) { create(:ci_build, user: user) } + + it { expect(policy).to be_allowed :erase_build } + end + + context 'when the build was created by others' do + let(:build) { create(:ci_build, user: another_user) } + + it { expect(policy).to be_disallowed :erase_build } + end + end + + context 'when master erases a build' do + before do + project.add_master(user) + end + + context 'when the build was created by the user' do + let(:build) { create(:ci_build, user: user) } + + it { expect(policy).to be_allowed :erase_build } + end + + context 'when the build was created by others' do + let(:build) { create(:ci_build, user: another_user) } + + it { expect(policy).to be_allowed :erase_build } + end + end + end end end |