Skip to content

Commit 3dba37e

Browse files
committed
Implement user license warnings
1 parent abc8d53 commit 3dba37e

File tree

10 files changed

+76
-32
lines changed

10 files changed

+76
-32
lines changed

lib/travis/api/v3/billing_client.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ def allowance(owner_type, owner_id)
1414
end
1515

1616
def self.default_allowance_response(id = 0)
17-
Travis::API::V3::Models::Allowance.new(1, id, { "public_repos" => true, "private_repos" => false, "concurrency_limit" => 1 }.freeze)
17+
Travis::API::V3::Models::Allowance.new(1, id, {
18+
"public_repos" => true,
19+
"private_repos" => false,
20+
"concurrency_limit" => 1,
21+
"user_usage" => false,
22+
"pending_user_licenses" => false
23+
}.freeze)
1824
end
1925

2026
def all

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module Travis::API::V3
22
class Models::Allowance
3-
attr_reader :subscription_type, :public_repos, :private_repos, :concurrency_limit, :id
3+
attr_reader :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id
44

55
def initialize(subscription_type, owner_id, attributes = {})
66
@subscription_type = subscription_type
77
@id = owner_id
88
@public_repos = attributes.fetch('public_repos')
99
@private_repos = attributes.fetch('private_repos')
1010
@concurrency_limit = attributes.fetch('concurrency_limit')
11+
@user_usage = attributes.fetch('user_usage')
12+
@pending_user_licenses = attributes.fetch('pending_user_licenses')
1113
end
1214
end
1315
end
Lines changed: 2 additions & 2 deletions
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, :id)
4-
representation(:standard, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :id)
3+
representation(:minimal, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id)
4+
representation(:standard, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id)
55
end
66
end

spec/v3/services/installation/find_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"@representation" => "minimal",
6161
"@type" => "allowance",
6262
"id" => 1,
63+
"pending_user_licenses" => false,
64+
"user_usage" => true,
6365
"concurrency_limit" => 1,
6466
"private_repos" => false,
6567
"public_repos" => true,

spec/v3/services/organization/find_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"@type" => "allowance",
2828
"@representation" => "minimal",
2929
"id" => org.id,
30+
"pending_user_licenses" => false,
31+
"user_usage" => true,
3032
"subscription_type" => 1,
3133
"public_repos" => true,
3234
"private_repos" => false,
@@ -65,6 +67,8 @@
6567
"@type" => "allowance",
6668
"@representation" => "minimal",
6769
"id" => org.id,
70+
"pending_user_licenses" => false,
71+
"user_usage" => true,
6872
"subscription_type" => 1,
6973
"public_repos" => true,
7074
"private_repos" => false,

spec/v3/services/organizations/for_current_user_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
"@type" => "allowance",
6464
"@representation" => "minimal",
6565
"id" => org.id,
66+
"pending_user_licenses" => false,
67+
"user_usage" => true,
6668
"subscription_type" => 1,
6769
"public_repos" => true,
6870
"private_repos" => false,

spec/v3/services/owner/find_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"@type" => "allowance",
2828
"@representation" => "minimal",
2929
"id" => org.id,
30+
"pending_user_licenses" => false,
31+
"user_usage" => true,
3032
"subscription_type" => 1,
3133
"public_repos" => true,
3234
"private_repos" => false,
@@ -56,6 +58,8 @@
5658
"@type" => "allowance",
5759
"@representation" => "minimal",
5860
"id" => org.id,
61+
"pending_user_licenses" => false,
62+
"user_usage" => true,
5963
"subscription_type" => 1,
6064
"public_repos" => true,
6165
"private_repos" => false,
@@ -90,6 +94,8 @@
9094
"@type" => "allowance",
9195
"@representation" => "minimal",
9296
"id" => org.id,
97+
"pending_user_licenses" => false,
98+
"user_usage" => true,
9399
"subscription_type" => 1,
94100
"public_repos" => true,
95101
"private_repos" => false,
@@ -168,6 +174,8 @@
168174
"@type" => "allowance",
169175
"@representation" => "minimal",
170176
"id" => org.id,
177+
"pending_user_licenses" => false,
178+
"user_usage" => true,
171179
"subscription_type" => 1,
172180
"public_repos" => true,
173181
"private_repos" => false,
@@ -241,6 +249,8 @@
241249
"@type" => "allowance",
242250
"@representation" => "minimal",
243251
"id" => org.id,
252+
"pending_user_licenses" => false,
253+
"user_usage" => true,
244254
"subscription_type" => 1,
245255
"public_repos" => true,
246256
"private_repos" => false,
@@ -274,6 +284,8 @@
274284
"@type" => "allowance",
275285
"@representation" => "minimal",
276286
"id" => org.id,
287+
"pending_user_licenses" => false,
288+
"user_usage" => true,
277289
"subscription_type" => 1,
278290
"public_repos" => true,
279291
"private_repos" => false,
@@ -317,6 +329,8 @@
317329
"@type" => "allowance",
318330
"@representation" => "minimal",
319331
"id" => user.id,
332+
"pending_user_licenses" => false,
333+
"user_usage" => true,
320334
"subscription_type" => 1,
321335
"public_repos" => true,
322336
"private_repos" => false,
@@ -351,6 +365,8 @@
351365
"@type" => "allowance",
352366
"@representation" => "minimal",
353367
"id" => user.id,
368+
"pending_user_licenses" => false,
369+
"user_usage" => true,
354370
"subscription_type" => 1,
355371
"public_repos" => true,
356372
"private_repos" => false,
@@ -385,6 +401,8 @@
385401
"@type" => "allowance",
386402
"@representation" => "minimal",
387403
"id" => user.id,
404+
"pending_user_licenses" => false,
405+
"user_usage" => true,
388406
"subscription_type" => 1,
389407
"public_repos" => true,
390408
"private_repos" => false,
@@ -423,6 +441,8 @@
423441
"@type" => "allowance",
424442
"@representation" => "minimal",
425443
"id" => user.id,
444+
"pending_user_licenses" => false,
445+
"user_usage" => true,
426446
"subscription_type" => 1,
427447
"public_repos" => true,
428448
"private_repos" => false,

spec/v3/services/repositories/for_owner_spec.rb

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,15 @@
557557
before { get("/v3/owner/svenfuchs/allowance", {}, headers) }
558558
example { expect(last_response).to be_ok }
559559
example { expect(JSON.load(body)).to be == {
560-
"@representation" => "standard",
561-
"@type" => "allowance",
562-
"concurrency_limit" => 1,
563-
"id" => 0,
564-
"private_repos" => false,
565-
"public_repos" => true,
566-
"subscription_type" => 1
560+
"@representation" => "standard",
561+
"@type" => "allowance",
562+
"concurrency_limit" => 1,
563+
"id" => 0,
564+
"pending_user_licenses" => false,
565+
"user_usage" => false,
566+
"private_repos" => false,
567+
"public_repos" => true,
568+
"subscription_type" => 1
567569
}}
568570
end
569571

@@ -578,13 +580,15 @@
578580
end
579581
example { expect(last_response).to be_ok }
580582
example { expect(JSON.load(body)).to be == {
581-
"@representation" => "standard",
582-
"@type" => "allowance",
583-
"concurrency_limit" => 666,
584-
"id" => 1,
585-
"private_repos" => true,
586-
"public_repos" => true,
587-
"subscription_type" => 2
583+
"@representation" => "standard",
584+
"@type" => "allowance",
585+
"concurrency_limit" => 666,
586+
"id" => 1,
587+
"pending_user_licenses" => false,
588+
"user_usage" => true,
589+
"private_repos" => true,
590+
"public_repos" => true,
591+
"subscription_type" => 2
588592
}}
589593
end
590594

spec/v3/services/user/current_spec.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
"education" => nil,
2626
"allow_migration" => false,
2727
"allowance" => {
28-
"@type" => "allowance",
29-
"@representation" => "minimal",
30-
"id" => user.id,
31-
"subscription_type" => 1,
32-
"public_repos" => true,
33-
"private_repos" => false,
34-
"concurrency_limit" => 1
28+
"@type" => "allowance",
29+
"@representation" => "minimal",
30+
"id" => user.id,
31+
"pending_user_licenses" => false,
32+
"user_usage" => false,
33+
"subscription_type" => 1,
34+
"public_repos" => true,
35+
"private_repos" => false,
36+
"concurrency_limit" => 1
3537
},
3638
"recently_signed_up"=>false,
3739
"secure_user_hash" => nil

spec/v3/services/user/find_spec.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@
3838
"education" => true,
3939
"allow_migration" => false,
4040
"allowance" => {
41-
"@type" => "allowance",
42-
"@representation" => "minimal",
43-
"id" => user.id,
44-
"subscription_type" => 2,
45-
"public_repos" => true,
46-
"private_repos" => true,
47-
"concurrency_limit" => 666
41+
"@type" => "allowance",
42+
"@representation" => "minimal",
43+
"id" => user.id,
44+
"pending_user_licenses" => false,
45+
"user_usage" => true,
46+
"subscription_type" => 2,
47+
"public_repos" => true,
48+
"private_repos" => true,
49+
"concurrency_limit" => 666
4850
},
4951
"recently_signed_up"=>false,
5052
"secure_user_hash" => nil,

0 commit comments

Comments
 (0)