Skip to content

Commit 3e73fc4

Browse files
authored
Owner allowance minimal (#1160)
* minimal allowance for owner * default values in allowance model
1 parent 15f34a5 commit 3e73fc4

File tree

10 files changed

+12
-105
lines changed

10 files changed

+12
-105
lines changed

lib/travis/api/v3/billing_client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def self.default_allowance_response(id = 0)
3030
}.freeze)
3131
end
3232

33+
def self.minimal_allowance_response(id = 0)
34+
Travis::API::V3::Models::Allowance.new(2, id, {})
35+
end
36+
3337
def executions(owner_type, owner_id, page, per_page, from, to)
3438
response = connection.get("/usage/#{owner_type.downcase}s/#{owner_id}/executions?page=#{page}&per_page=#{per_page}&from=#{from}&to=#{to}")
3539
executions = response.body.map do |execution_data|

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ class Models::Allowance
55
def initialize(subscription_type, owner_id, attributes = {})
66
@subscription_type = subscription_type
77
@id = owner_id
8-
@public_repos = attributes.fetch('public_repos')
9-
@private_repos = attributes.fetch('private_repos')
10-
@concurrency_limit = attributes.fetch('concurrency_limit')
11-
@user_usage = attributes.fetch('user_usage')
12-
@pending_user_licenses = attributes.fetch('pending_user_licenses')
8+
@public_repos = attributes.fetch('public_repos', nil)
9+
@private_repos = attributes.fetch('private_repos', nil)
10+
@concurrency_limit = attributes.fetch('concurrency_limit', nil)
11+
@user_usage = attributes.fetch('user_usage', nil)
12+
@pending_user_licenses = attributes.fetch('pending_user_licenses', nil)
1313
end
1414
end
1515
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Travis::API::V3
22
class Renderer::Allowance < ModelRenderer
3-
representation(:minimal, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id)
3+
representation(:minimal, :id)
44
representation(:standard, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id)
55
end
66
end

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ def allow_migration
3333
def allowance
3434
return BillingClient.default_allowance_response(id) if Travis.config.org?
3535
return BillingClient.default_allowance_response(id) unless access_control.user
36-
37-
client = BillingClient.new(access_control.user.id)
38-
client.allowance(owner_type, id)
36+
37+
BillingClient.minimal_allowance_response(id)
3938
end
4039

4140
def owner_type

spec/v3/services/installation/find_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@
5959
"allowance" => {
6060
"@representation" => "minimal",
6161
"@type" => "allowance",
62-
"concurrency_limit" => 1,
63-
"private_repos" => false,
64-
"public_repos" => true,
65-
"subscription_type" => 1,
66-
"user_usage" => false,
67-
"pending_user_licenses" => false,
6862
"id" => 1
6963
},
7064
"allow_migration" => false,

spec/v3/services/organization/find_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
"allowance" => {
2727
"@type" => "allowance",
2828
"@representation" => "minimal",
29-
"subscription_type" => 1,
30-
"public_repos" => true,
31-
"private_repos" => false,
32-
"concurrency_limit" => 1,
33-
"user_usage" => false,
34-
"pending_user_licenses" => false,
3529
"id" => org.id
3630
}
3731
}}
@@ -66,12 +60,6 @@
6660
"allowance" => {
6761
"@type" => "allowance",
6862
"@representation" => "minimal",
69-
"subscription_type" => 1,
70-
"public_repos" => true,
71-
"private_repos" => false,
72-
"concurrency_limit" => 1,
73-
"user_usage" => false,
74-
"pending_user_licenses" => false,
7563
"id" => org.id
7664
}
7765
}}

spec/v3/services/organizations/for_current_user_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@
6262
"allowance" => {
6363
"@type" => "allowance",
6464
"@representation" => "minimal",
65-
"subscription_type" => 1,
66-
"public_repos" => true,
67-
"private_repos" => false,
68-
"concurrency_limit" => 1,
69-
"user_usage" => false,
70-
"pending_user_licenses" => false,
7165
"id" => org.id
7266
}
7367
}]

spec/v3/services/owner/find_spec.rb

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
"allowance" => {
2727
"@type" => "allowance",
2828
"@representation" => "minimal",
29-
"subscription_type" => 1,
30-
"public_repos" => true,
31-
"private_repos" => false,
32-
"concurrency_limit" => 1,
33-
"user_usage" => false,
34-
"pending_user_licenses" => false,
3529
"id" => org.id
3630
}
3731
}}
@@ -57,12 +51,6 @@
5751
"allowance" => {
5852
"@type" => "allowance",
5953
"@representation" => "minimal",
60-
"subscription_type" => 1,
61-
"public_repos" => true,
62-
"private_repos" => false,
63-
"concurrency_limit" => 1,
64-
"user_usage" => false,
65-
"pending_user_licenses" => false,
6654
"id" => org.id
6755
}
6856
}}
@@ -93,12 +81,6 @@
9381
"allowance" => {
9482
"@type" => "allowance",
9583
"@representation" => "minimal",
96-
"subscription_type" => 1,
97-
"public_repos" => true,
98-
"private_repos" => false,
99-
"concurrency_limit" => 1,
100-
"user_usage" => false,
101-
"pending_user_licenses" => false,
10284
"id" => org.id
10385
},
10486
"repositories" => [{
@@ -173,12 +155,6 @@
173155
"allowance" => {
174156
"@type" => "allowance",
175157
"@representation" => "minimal",
176-
"subscription_type" => 1,
177-
"public_repos" => true,
178-
"private_repos" => false,
179-
"concurrency_limit" => 1,
180-
"user_usage" => false,
181-
"pending_user_licenses" => false,
182158
"id" => org.id
183159
},
184160
"repositories" => [{
@@ -248,12 +224,6 @@
248224
"allowance" => {
249225
"@type" => "allowance",
250226
"@representation" => "minimal",
251-
"subscription_type" => 1,
252-
"public_repos" => true,
253-
"private_repos" => false,
254-
"concurrency_limit" => 1,
255-
"user_usage" => false,
256-
"pending_user_licenses" => false,
257227
"id" => org.id
258228
}
259229
}}
@@ -283,12 +253,6 @@
283253
"allowance" => {
284254
"@type" => "allowance",
285255
"@representation" => "minimal",
286-
"subscription_type" => 1,
287-
"public_repos" => true,
288-
"private_repos" => false,
289-
"concurrency_limit" => 1,
290-
"user_usage" => false,
291-
"pending_user_licenses" => false,
292256
"id" => org.id
293257
},
294258
"@warnings" => [{
@@ -328,12 +292,6 @@
328292
"allowance" => {
329293
"@type" => "allowance",
330294
"@representation" => "minimal",
331-
"subscription_type" => 1,
332-
"public_repos" => true,
333-
"private_repos" => false,
334-
"concurrency_limit" => 1,
335-
"user_usage" => false,
336-
"pending_user_licenses" => false,
337295
"id" => user.id
338296
},
339297
"recently_signed_up"=>false,
@@ -364,12 +322,6 @@
364322
"allowance" => {
365323
"@type" => "allowance",
366324
"@representation" => "minimal",
367-
"subscription_type" => 1,
368-
"public_repos" => true,
369-
"private_repos" => false,
370-
"concurrency_limit" => 1,
371-
"user_usage" => false,
372-
"pending_user_licenses" => false,
373325
"id" => user.id
374326
},
375327
"recently_signed_up"=>false,
@@ -400,12 +352,6 @@
400352
"allowance" => {
401353
"@type" => "allowance",
402354
"@representation" => "minimal",
403-
"subscription_type" => 1,
404-
"public_repos" => true,
405-
"private_repos" => false,
406-
"concurrency_limit" => 1,
407-
"user_usage" => false,
408-
"pending_user_licenses" => false,
409355
"id" => user.id
410356
},
411357
"recently_signed_up"=>false,
@@ -440,12 +386,6 @@
440386
"allowance" => {
441387
"@type" => "allowance",
442388
"@representation" => "minimal",
443-
"subscription_type" => 1,
444-
"public_repos" => true,
445-
"private_repos" => false,
446-
"concurrency_limit" => 1,
447-
"user_usage" => false,
448-
"pending_user_licenses" => false,
449389
"id" => user.id
450390
},
451391
"recently_signed_up"=>false,

spec/v3/services/user/current_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
"allowance" => {
2828
"@type" => "allowance",
2929
"@representation" => "minimal",
30-
"subscription_type" => 1,
31-
"public_repos" => true,
32-
"private_repos" => false,
33-
"concurrency_limit" => 1,
34-
"user_usage" => false,
35-
"pending_user_licenses" => false,
3630
"id" => user.id
3731
},
3832
"recently_signed_up"=>false,

spec/v3/services/user/find_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
"allowance" => {
4141
"@type" => "allowance",
4242
"@representation" => "minimal",
43-
"subscription_type" => 2,
44-
"public_repos" => true,
45-
"private_repos" => true,
46-
"concurrency_limit" => 666,
47-
"user_usage" => true,
48-
"pending_user_licenses" => false,
4943
"id" => user.id
5044
},
5145
"recently_signed_up"=>false,

0 commit comments

Comments
 (0)