Skip to content

Commit b38aa6b

Browse files
committed
Fix spec
1 parent ee2993e commit b38aa6b

File tree

7 files changed

+44
-183
lines changed

7 files changed

+44
-183
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module Travis::API::V3
22
class Models::V2Addon
3-
attr_reader :id, :type, :current_usage
3+
attr_reader :id, :name, :type, :current_usage
44

55
def initialize(attrs)
66
@id = attrs.fetch('id')
7+
@name = attrs.fetch('name')
78
@type = attrs.fetch('type')
89
@current_usage = attrs['current_usage'] && Models::V2AddonUsage.new(attrs['current_usage'])
910
end

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
module Travis::API::V3
22
class Models::V2PlanConfig
3-
attr_reader :id, :name, :private_repos, :default_addons, :starting_price, :starting_users, :private_credits, :public_credits
3+
attr_reader :id, :name, :private_repos, :starting_price, :starting_users, :private_credits, :public_credits
44

55
def initialize(attrs)
66
@id = attrs.fetch('id')
77
@name = attrs.fetch('name')
88
@private_repos = attrs.fetch('private_repos')
9-
@default_addons = attrs.fetch('addon_configs')
109
@starting_price = attrs.fetch('starting_price')
1110
@starting_users = attrs.fetch('starting_users')
1211
@private_credits = attrs.fetch('private_credits')

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Travis::API::V3
22
class Renderer::V2Addon < ModelRenderer
3-
representation(:standard, :id, :type, :current_usage)
4-
representation(:minimal, :id, :type, :current_usage)
3+
representation(:standard, :id, :name, :type, :current_usage)
4+
representation(:minimal, :id, :name, :type, :current_usage)
55

66
def current_usage
77
Renderer.render_model(model.current_usage, mode: :standard) unless model.current_usage.nil?

spec/support/billing_spec_helper.rb

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,6 @@ def billing_v2_subscription_response_body(attributes={})
5151
"id" => "pro_tier_plan",
5252
"name" => "Pro Tier Plan",
5353
'private_repos' => true,
54-
'addon_configs' => [
55-
{
56-
"id": "oss_tier_credits",
57-
"name": "Free 40 000 credits (renewed monthly)",
58-
"price": 0,
59-
"quantity": 40000,
60-
"type": "credit_public"
61-
},
62-
{
63-
"id": "credits_500k",
64-
"name": "500 000 credits (50k Linux build minutes)",
65-
"price": 30000,
66-
"quantity": 500000,
67-
"type": "credit_private"
68-
},
69-
{
70-
"id": "users_pro",
71-
"name": "Pro Tier user licenses",
72-
"price": 0,
73-
"quantity": 10000,
74-
"type": "user_license"
75-
}
76-
],
7754
'starting_price' => 30000,
7855
'starting_users' => 10000,
7956
'private_credits' => 500000,
@@ -111,42 +88,28 @@ def billing_addons_response_body
11188
[
11289
{
11390
"id" => "1",
114-
"plan_id" => "1",
11591
"name" => "OSS Build Credits",
116-
"addon_type" => "credit_public",
117-
"created_at" => "2020-07-09T12:06:13.293Z",
118-
"updated_at" => "2020-07-09T12:07:03.619Z",
119-
"current_usage_id" => 1,
92+
"type" => "credit_public",
12093
"current_usage" => {
12194
"id" => 1,
12295
"addon_id" => 1,
123-
"addon_quantity" => 10000,
96+
"addon_quantity" => 40000,
12497
"addon_usage" => 0,
125-
"purchase_date" => "2020-07-09T12:06:27.919Z",
126-
"valid_to" => nil,
127-
"status" => "active",
128-
"created_at" => "2020-07-09T12:06:27.944Z",
129-
"updated_at" => "2020-07-09T12:06:27.944Z"
98+
"remaining" => 40000,
99+
"active" => true
130100
}
131101
},
132102
{
133103
"id" => 2,
134-
"plan_id" => 1,
135104
"name" => "Build Credits",
136-
"addon_type" => "credit_private",
137-
"created_at" => "2020-07-09T12:06:17.003Z",
138-
"updated_at" => "2020-07-09T12:07:09.067Z",
139-
"current_usage_id" => 2,
105+
"type" => "credit_private",
140106
"current_usage" => {
141107
"id" => 2,
142108
"addon_id" => 2,
143109
"addon_quantity" => 10000,
144110
"addon_usage" => 0,
145-
"purchase_date" => "2020-07-09T12:06:31.739Z",
146-
"valid_to" => nil,
147-
"status" => "active",
148-
"created_at" => "2020-07-09T12:06:31.741Z",
149-
"updated_at" => "2020-07-09T12:06:31.741Z"
111+
"remaining" => 10000,
112+
"active" => true
150113
}
151114
}
152115
]

spec/v3/models/v2_subscription_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
'id' => 'pro_tier_plan',
1010
'name' => 'Pro Tier Plan',
1111
'private_repos' => true,
12-
'addon_configs' => [],
1312
'starting_price' => 30000,
1413
'starting_users' => 10000,
1514
'private_credits' => 500000,
1615
'public_credits' => 40000,
1716
},
1817
'addons' => [{
1918
'id' => 7,
19+
'name' => 'OSS Build Credits',
2020
'plan_id' => 3,
2121
'addon_config_id' => 'oss_tier_credits',
2222
'type' => 'credit_public',

spec/v3/services/v2_subscriptions/all_spec.rb

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,6 @@
2828
'id': 'pro_tier_plan',
2929
'name': 'Pro Tier Plan',
3030
'private_repos': true,
31-
'default_addons': [
32-
{
33-
'id': 'oss_tier_credits',
34-
'name': 'Free 40 000 credits (renewed monthly)',
35-
'price': 0,
36-
'quantity': 40_000,
37-
'type': 'credit_public'
38-
},
39-
{
40-
'id': 'credits_500k',
41-
'name': '500 000 credits (50k Linux build minutes)',
42-
'price': 30_000,
43-
'quantity': 500_000,
44-
'type': 'credit_private'
45-
},
46-
{
47-
'id': 'users_pro',
48-
'name': 'Pro Tier user licenses',
49-
'price': 0,
50-
'quantity': 10_000,
51-
'type': 'user_license'
52-
}
53-
],
5431
'starting_price': 30_000,
5532
'starting_users': 10_000,
5633
'private_credits': 500_000,
@@ -79,74 +56,45 @@
7956
'id' => 'pro_tier_plan',
8057
'name' => 'Pro Tier Plan',
8158
'private_repos' => true,
82-
'default_addons' => [
83-
{
84-
'id' => 'oss_tier_credits',
85-
'name' => 'Free 40 000 credits (renewed monthly)',
86-
'price' => 0,
87-
'quantity' => 40_000,
88-
'type' => 'credit_public'
89-
},
90-
{
91-
'id' => 'credits_500k',
92-
'name' => '500 000 credits (50k Linux build minutes)',
93-
'price' => 30_000,
94-
'quantity' => 500_000,
95-
'type' => 'credit_private'
96-
},
97-
{
98-
'id' => 'users_pro',
99-
'name' => 'Pro Tier user licenses',
100-
'price' => 0,
101-
'quantity' => 10_000,
102-
'type' => 'user_license'
103-
}
104-
],
10559
'starting_price' => 30_000,
10660
'starting_users' => 10_000,
10761
'private_credits' => 500_000,
10862
'public_credits' => 40_000
10963
},
11064
'addons' => [
11165
{
66+
'@type' => 'v2_addon',
67+
'@representation' => 'minimal',
11268
'id' => '1',
113-
'plan_id' => '1',
11469
'name' => 'OSS Build Credits',
115-
'addon_type' => 'credit_public',
116-
'created_at' => '2020-07-09T12:06:13.293Z',
117-
'updated_at' => '2020-07-09T12:07:03.619Z',
118-
'current_usage_id' => 1,
70+
'type' => 'credit_public',
11971
'current_usage' => {
72+
'@type' => 'v2_addon_usage',
73+
'@representation' => 'standard',
12074
'id' => 1,
12175
'addon_id' => 1,
122-
'addon_quantity' => 10_000,
76+
'addon_quantity' => 40_000,
12377
'addon_usage' => 0,
124-
'purchase_date' => '2020-07-09T12:06:27.919Z',
125-
'valid_to' => nil,
126-
'status' => 'active',
127-
'created_at' => '2020-07-09T12:06:27.944Z',
128-
'updated_at' => '2020-07-09T12:06:27.944Z'
78+
'remaining' => 40_000,
79+
'active' => true
12980
}
13081
},
13182
{
83+
'@type' => 'v2_addon',
84+
'@representation' => 'minimal',
13285
'id' => 2,
133-
'plan_id' => 1,
13486
'name' => 'Build Credits',
135-
'addon_type' => 'credit_private',
136-
'created_at' => '2020-07-09T12:06:17.003Z',
137-
'updated_at' => '2020-07-09T12:07:09.067Z',
138-
'current_usage_id' => 2,
87+
'type' => 'credit_private',
13988
'current_usage' =>
14089
{
90+
'@type' => 'v2_addon_usage',
91+
'@representation' => 'standard',
14192
'id' => 2,
14293
'addon_id' => 2,
14394
'addon_quantity' => 10_000,
14495
'addon_usage' => 0,
145-
'purchase_date' => '2020-07-09T12:06:31.739Z',
146-
'valid_to' => nil,
147-
'status' => 'active',
148-
'created_at' => '2020-07-09T12:06:31.741Z',
149-
'updated_at' => '2020-07-09T12:06:31.741Z'
96+
'remaining' => 10_000,
97+
'active' => true
15098
}
15199
}
152100
],

spec/v3/services/v2_subscriptions/create_spec.rb

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,6 @@
6767
'id' => 'pro_tier_plan',
6868
'name' => 'Pro Tier Plan',
6969
'private_repos' => true,
70-
'addon_configs' => [
71-
{
72-
'id' => 'oss_tier_credits',
73-
'name' => 'Free 40 000 credits (renewed monthly)',
74-
'price' => 0,
75-
'quantity' => 40_000,
76-
'type' => 'credit_public'
77-
},
78-
{
79-
'id' => 'credits_500k',
80-
'name' => '500 000 credits (50k Linux build minutes)',
81-
'price' => 30_000,
82-
'quantity' => 500_000,
83-
'type' => 'credit_private'
84-
},
85-
{
86-
'id' => 'users_pro',
87-
'name' => 'Pro Tier user licenses',
88-
'price' => 0,
89-
'quantity' => 10_000,
90-
'type' => 'user_license'
91-
}
92-
],
9370
'starting_price' => 30_000,
9471
'starting_users' => 10_000,
9572
'private_credits' => 500_000,
@@ -98,6 +75,7 @@
9875
'addons' => [{
9976
'id': 7,
10077
'plan_id': 3,
78+
"name": "OSS Build Credits",
10179
'addon_config_id': 'oss_tier_credits',
10280
'type': 'credit_public',
10381
'created_at': '2017-11-28T00:09:59.502Z',
@@ -154,56 +132,28 @@
154132
'id' => 'pro_tier_plan',
155133
'name' => 'Pro Tier Plan',
156134
'private_repos' => true,
157-
'default_addons' => [
158-
{
159-
'id' => 'oss_tier_credits',
160-
'name' => 'Free 40 000 credits (renewed monthly)',
161-
'price' => 0,
162-
'quantity' => 40_000,
163-
'type' => 'credit_public'
164-
},
165-
{
166-
'id' => 'credits_500k',
167-
'name' => '500 000 credits (50k Linux build minutes)',
168-
'price' => 30_000,
169-
'quantity' => 500_000,
170-
'type' => 'credit_private'
171-
},
172-
{
173-
'id' => 'users_pro',
174-
'name' => 'Pro Tier user licenses',
175-
'price' => 0,
176-
'quantity' => 10_000,
177-
'type' => 'user_license'
178-
}
179-
],
180135
'starting_users' => 10_000,
181136
'starting_price' => 30_000,
182137
'private_credits' => 500_000,
183138
'public_credits' => 40_000
184139
},
185140
'addons' => [{
186-
'id': 7,
187-
'plan_id': 3,
188-
'addon_config_id': 'oss_tier_credits',
189-
'type': 'credit_public',
190-
'created_at': '2017-11-28T00:09:59.502Z',
191-
'updated_at': '2017-11-28T00:09:59.502Z',
192-
'current_usage_id': 7,
193-
'current_usage': {
194-
'id': 7,
195-
'addon_id': 7,
196-
'addon_quantity': 40_000,
197-
'addon_usage': 0,
198-
'remaining': 40_000,
199-
'purchase_date': '2017-11-28T00:09:59.502Z',
200-
'valid_to': '2017-11-28T00:09:59.502Z',
201-
'status': 'pending',
202-
'active': false,
203-
'created_at': '2017-11-28T00:09:59.502Z',
204-
'updated_at': '2017-11-28T00:09:59.502Z'
141+
'@type' => 'v2_addon',
142+
'@representation' => 'minimal',
143+
'id' => 7,
144+
'name' => 'OSS Build Credits',
145+
'type' => 'credit_public',
146+
'current_usage' => {
147+
'@type' => 'v2_addon_usage',
148+
'@representation' => 'standard',
149+
'id' => 7,
150+
'addon_id' => 7,
151+
'addon_quantity' => 40000,
152+
'addon_usage' => 0,
153+
'remaining' => 40000,
154+
'active' => false
205155
}
206-
}.deep_stringify_keys],
156+
}],
207157
'client_secret' => 'client_secret',
208158
'source' => 'stripe',
209159
'billing_info' => {

0 commit comments

Comments
 (0)