|
103 | 103 | project.add_developer(user)
|
104 | 104 | end
|
105 | 105 |
|
106 |
| - context 'when branch build is assigned to is protected' do |
107 |
| - before do |
108 |
| - create(:protected_branch, :no_one_can_push, |
109 |
| - name: 'some-ref', project: project) |
110 |
| - end |
111 |
| - |
| 106 | + shared_examples 'protected ref' do |
112 | 107 | context 'when build is a manual action' do
|
113 | 108 | let(:build) do
|
114 | 109 | create(:ci_build, :manual, ref: 'some-ref', pipeline: pipeline)
|
|
130 | 125 | end
|
131 | 126 | end
|
132 | 127 |
|
| 128 | + context 'when build is against a protected branch' do |
| 129 | + before do |
| 130 | + create(:protected_branch, :no_one_can_push, |
| 131 | + name: 'some-ref', project: project) |
| 132 | + end |
| 133 | + |
| 134 | + it_behaves_like 'protected ref' |
| 135 | + end |
| 136 | + |
| 137 | + context 'when build is against a protected tag' do |
| 138 | + before do |
| 139 | + create(:protected_tag, :no_one_can_create, |
| 140 | + name: 'some-ref', project: project) |
| 141 | + |
| 142 | + build.update(tag: true) |
| 143 | + end |
| 144 | + |
| 145 | + it_behaves_like 'protected ref' |
| 146 | + end |
| 147 | + |
| 148 | + context 'when build is against a protected tag but it is not a tag' do |
| 149 | + before do |
| 150 | + create(:protected_tag, :no_one_can_create, |
| 151 | + name: 'some-ref', project: project) |
| 152 | + end |
| 153 | + |
| 154 | + context 'when build is a manual action' do |
| 155 | + let(:build) do |
| 156 | + create(:ci_build, :manual, ref: 'some-ref', pipeline: pipeline) |
| 157 | + end |
| 158 | + |
| 159 | + it 'includes ability to update build' do |
| 160 | + expect(policy).to be_allowed :update_build |
| 161 | + end |
| 162 | + end |
| 163 | + end |
| 164 | + |
133 | 165 | context 'when branch build is assigned to is not protected' do
|
134 | 166 | context 'when build is a manual action' do
|
135 | 167 | let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
|
|
0 commit comments