Skip to content

Commit a04dba1

Browse files
author
Shairyar Baig
authored
Merge pull request #1116 from travis-ci/dm_build_priority_feature_on_org
Build priority feature on an Organization.
2 parents 5accd4a + 042e002 commit a04dba1

File tree

14 files changed

+33
-30
lines changed

14 files changed

+33
-30
lines changed

lib/travis/api/v3/models/organization.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def builds
2525
Models::Build.where(owner_type: 'Organization', owner_id: id)
2626
end
2727

28+
def build_priorities_enabled?
29+
Travis::Features.owner_active?(:build_priorities_org, self)
30+
end
31+
2832
alias members users
2933
end
3034
end

lib/travis/api/v3/permissions/build.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ def cancel?
99
def restart?
1010
restartable?
1111
end
12+
13+
def prioritize?
14+
write? && build_priorities?
15+
end
1216
end
1317
end

lib/travis/api/v3/permissions/generic.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,10 @@ def adminable?
7575
access_control.adminable? object
7676
end
7777

78+
def build_priorities?
79+
return false if object.owner_type != 'Organization'
80+
object.owner.build_priorities_enabled?
81+
end
82+
7883
end
7984
end

lib/travis/api/v3/renderer/owner.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Renderer::Owner < ModelRenderer
55
include Renderer::AvatarURL
66

77
representation(:minimal, :id, :login, :vcs_type)
8-
representation(:standard, :id, :login, :name, :github_id, :vcs_id, :vcs_type, :avatar_url, :education, :allow_migration, :allow_build_priorities)
8+
representation(:standard, :id, :login, :name, :github_id, :vcs_id, :vcs_type, :avatar_url, :education, :allow_migration)
99
representation(:additional, :repositories, :installation)
1010

1111
def initialize(*)
@@ -28,9 +28,5 @@ def installation
2828
def allow_migration
2929
!!Travis::Features.owner_active?(:allow_migration, @model)
3030
end
31-
32-
def allow_build_priorities
33-
!!Travis::Features.owner_active?(:build_priorities_org, @model)
34-
end
3531
end
3632
end

spec/v3/services/build/find_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
let(:stages) { build.stages }
66
let(:jobs) { Travis::API::V3::Models::Build.find(build.id).jobs }
77
let(:parsed_body) { JSON.load(body) }
8+
let(:org) { Travis::API::V3::Models::Organization.new(login: 'example-org') }
89

910
before do
1011
build.update_attributes(sender_id: repo.owner.id, sender_type: 'User')
@@ -42,7 +43,8 @@
4243
"@permissions" => {
4344
"read" => true,
4445
"cancel" => false,
45-
"restart" => false},
46+
"restart" => false,
47+
"prioritize" => false},
4648
"id" => build.id,
4749
"number" => build.number,
4850
"state" => build.state,
@@ -140,7 +142,8 @@
140142
"@permissions" => {
141143
"read" => true,
142144
"cancel" => true,
143-
"restart" => true},
145+
"restart" => true,
146+
"prioritize" => false},
144147
"id" => build.id,
145148
"number" => build.number,
146149
"state" => build.state,
@@ -230,7 +233,8 @@
230233
"@permissions" => {
231234
"read" => true,
232235
"cancel" => false,
233-
"restart" => false},
236+
"restart" => false,
237+
"prioritize" => false},
234238
"id" => build.id,
235239
"number" => build.number,
236240
"state" => build.state,

spec/v3/services/builds/find_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"@permissions" => {
6767
"read" => true,
6868
"cancel" => false,
69-
"restart" => false },
69+
"restart" => false,
70+
"prioritize" => false },
7071
"id" => build.id,
7172
"number" => "3",
7273
"state" => "configured",
@@ -184,7 +185,8 @@
184185
"@permissions" => {
185186
"read" => true,
186187
"cancel" => false,
187-
"restart" => false },
188+
"restart" => false,
189+
"prioritize" => false},
188190
"id" => build.id,
189191
"number" => "3",
190192
"state" => "configured",
@@ -306,7 +308,8 @@
306308
"@permissions" => {
307309
"read" => true,
308310
"cancel" => true,
309-
"restart" => true },
311+
"restart" => true,
312+
"prioritize" => false },
310313
"id" => build.id,
311314
"number" => "3",
312315
"state" => "configured",

spec/v3/services/builds/for_current_user_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"@permissions" => {
4949
"read" => true,
5050
"cancel" => false,
51-
"restart" => false },
51+
"restart" => false,
52+
"prioritize" => false },
5253
"id" => build.id,
5354
"number" => "3",
5455
"state" => "configured",

spec/v3/services/installation/find_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"synced_at" => nil,
5757
"education" => nil,
5858
"allow_migration" => false,
59-
"allow_build_priorities" => false,
6059
"recently_signed_up" => false,
6160
"secure_user_hash" => nil,
6261
}

spec/v3/services/organization/find_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"avatar_url" => nil,
2424
"education" => false,
2525
"allow_migration" => false,
26-
"allow_build_priorities" => false,
2726
}}
2827
end
2928

@@ -53,7 +52,6 @@
5352
"avatar_url" => nil,
5453
"education" => true,
5554
"allow_migration" => true,
56-
"allow_build_priorities" => true,
5755
}}
5856
end
5957

spec/v3/services/organizations/for_current_user_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"avatar_url" => nil,
6060
"education" => false,
6161
"allow_migration" => false,
62-
"allow_build_priorities" => false,
6362
}]
6463
}}
6564
end

0 commit comments

Comments
 (0)