@@ -91,6 +91,18 @@ def create_jobs(count, attrs = {})
91
91
it { expect ( report ) . to include ( 'user svenfuchs: total: 3, running: 0, queueable: 1' ) }
92
92
end
93
93
94
+ describe 'with a default limit 5 and a repo keychain/config limit 2' do
95
+ before { config . limit . default = 5 }
96
+ before { config . limit . by_repo = { repo . slug => 2 } }
97
+ before { create_jobs ( 3 ) }
98
+ before { repo . settings . update_attributes! ( maximum_number_of_builds : 2 ) }
99
+ before { subject }
100
+
101
+ it { expect ( subject . size ) . to eq 2 }
102
+ it { expect ( report ) . to include ( 'max jobs for repo svenfuchs/gem-release by repo_config: 2' ) }
103
+ it { expect ( report ) . to include ( 'user svenfuchs: total: 3, running: 0, queueable: 2' ) }
104
+ end
105
+
94
106
describe 'with a default limit 5 and a repo settings limit 2' do
95
107
before { config . limit . default = 5 }
96
108
before { create_jobs ( 3 ) }
@@ -193,4 +205,36 @@ def create_jobs(count, attrs = {})
193
205
it { expect ( subject . size ) . to eq 2 }
194
206
it { expect ( report ) . to include ( "jobs for build #{ build . id } limited at stage: 1 (queueable: 2)" ) }
195
207
end
208
+
209
+ describe 'stages with a a repo config limit 1' do
210
+ let ( :one ) { FactoryGirl . create ( :stage , number : 1 ) }
211
+ let ( :two ) { FactoryGirl . create ( :stage , number : 2 ) }
212
+
213
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : one , stage_number : '1.1' ) }
214
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : one , stage_number : '1.2' ) }
215
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : two , stage_number : '2.1' ) }
216
+ before { config . limit . default = 5 }
217
+ before { config . limit . by_repo = { repo . slug => 1 } }
218
+ before { subject }
219
+
220
+ it { expect ( subject . size ) . to eq 1 }
221
+ it { expect ( report ) . to include ( "jobs for build #{ build . id } limited at stage: 1 (queueable: 2)" ) }
222
+ it { expect ( report ) . to include ( 'max jobs for repo svenfuchs/gem-release by repo_config: 1' ) }
223
+ end
224
+
225
+ describe 'stages with a a repo settings limit 5' do
226
+ let ( :one ) { FactoryGirl . create ( :stage , number : 1 ) }
227
+ let ( :two ) { FactoryGirl . create ( :stage , number : 2 ) }
228
+
229
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : one , stage_number : '1.1' ) }
230
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : one , stage_number : '1.2' ) }
231
+ before { create_jobs ( 1 , owner : owner , state : :created , stage : two , stage_number : '2.1' ) }
232
+ before { config . limit . default = 5 }
233
+ before { repo . settings . update_attributes! ( maximum_number_of_builds : 1 ) }
234
+ before { subject }
235
+
236
+ it { expect ( subject . size ) . to eq 1 }
237
+ it { expect ( report ) . to include ( "jobs for build #{ build . id } limited at stage: 1 (queueable: 2)" ) }
238
+ it { expect ( report ) . to include ( 'max jobs for repo svenfuchs/gem-release by repo_settings: 1' ) }
239
+ end
196
240
end
0 commit comments