paid_up 0.11.7 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -13
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +4 -3
- data/Gemfile +29 -24
- data/README.md +22 -1
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/app/controllers/paid_up/paid_up_controller.rb +16 -9
- data/app/controllers/paid_up/plans_controller.rb +2 -0
- data/app/controllers/paid_up/subscriptions_controller.rb +58 -49
- data/app/helpers/paid_up/features_helper.rb +35 -34
- data/app/helpers/paid_up/paid_up_helper.rb +10 -8
- data/app/helpers/paid_up/plans_helper.rb +75 -55
- data/app/helpers/paid_up/subscriptions_helper.rb +17 -13
- data/app/models/paid_up/ability.rb +53 -46
- data/app/models/paid_up/plan.rb +36 -34
- data/app/models/paid_up/plan_feature_setting.rb +2 -0
- data/app/models/paid_up/unlimited.rb +2 -0
- data/app/views/paid_up/features/_abilities_table.html.haml +1 -45
- data/app/views/paid_up/features/_boolean_state.html.haml +6 -0
- data/app/views/paid_up/features/_setting_state.html.haml +13 -0
- data/app/views/paid_up/subscriptions/index.html.haml +2 -2
- data/config/initializers/stripe.rb +2 -0
- data/config/locales/en.yml +4 -1
- data/config/routes.rb +3 -1
- data/lib/generators/paid_up/install/install_generator.rb +4 -1
- data/lib/generators/paid_up/install/templates/ability.rb +2 -0
- data/lib/generators/paid_up/install/templates/initializer.rb +2 -0
- data/lib/generators/paid_up/utils.rb +2 -0
- data/lib/paid_up/configuration.rb +4 -2
- data/lib/paid_up/engine.rb +2 -0
- data/lib/paid_up/extensions/integer.rb +2 -0
- data/lib/paid_up/extensions/stripe.rb +2 -0
- data/lib/paid_up/feature.rb +10 -7
- data/lib/paid_up/feature_setting_type.rb +45 -0
- data/lib/paid_up/feature_setting_types/rolify.rb +10 -0
- data/lib/paid_up/feature_setting_types/table.rb +7 -0
- data/lib/paid_up/localization.rb +2 -0
- data/lib/paid_up/mixins/paid_for.rb +59 -47
- data/lib/paid_up/mixins/subscriber.rb +45 -101
- data/lib/paid_up/railtie.rb +2 -0
- data/lib/paid_up/ruby_version_check.rb +15 -0
- data/lib/paid_up/subscription.rb +80 -0
- data/lib/paid_up/validators/rolify_rows.rb +11 -6
- data/lib/paid_up/validators/table_rows.rb +9 -6
- data/lib/paid_up/version.rb +2 -0
- data/lib/paid_up.rb +8 -0
- data/paid_up.gemspec +108 -115
- data/spec/controllers/paid_up/plans_spec.rb +2 -0
- data/spec/controllers/paid_up/subscriptions_spec.rb +18 -11
- data/spec/dummy/Rakefile +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/models/ability.rb +2 -0
- data/spec/dummy/app/models/doodad.rb +2 -0
- data/spec/dummy/app/models/group.rb +2 -0
- data/spec/dummy/app/models/post.rb +2 -0
- data/spec/dummy/app/models/role.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.haml +13 -11
- data/spec/dummy/bin/bundle +2 -0
- data/spec/dummy/bin/rails +2 -0
- data/spec/dummy/bin/rake +2 -0
- data/spec/dummy/bin/setup +10 -8
- data/spec/dummy/config/application.rb +2 -3
- data/spec/dummy/config/boot.rb +2 -0
- data/spec/dummy/config/environment.rb +2 -0
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/test.rb +2 -4
- data/spec/dummy/config/initializers/assets.rb +2 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/paid_up.rb +10 -16
- data/spec/dummy/config/initializers/rolify.rb +2 -0
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config.ru +2 -0
- data/spec/dummy/db/schema.rb +14 -23
- data/spec/dummy/db/seeds.rb +8 -6
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/tasks/system.rake +2 -0
- data/spec/factories/doodad.rb +2 -0
- data/spec/factories/group.rb +2 -0
- data/spec/factories/plan.rb +2 -0
- data/spec/factories/plan_feature_setting.rb +2 -0
- data/spec/factories/post.rb +2 -0
- data/spec/factories/user.rb +3 -1
- data/spec/models/group_spec.rb +9 -7
- data/spec/models/paid_up/feature_spec.rb +2 -0
- data/spec/models/paid_up/plan_feature_setting_spec.rb +2 -0
- data/spec/models/paid_up/plan_spec.rb +2 -0
- data/spec/models/scope_spec.rb +9 -7
- data/spec/models/user_spec.rb +60 -58
- data/spec/paid_up_spec.rb +2 -0
- data/spec/rails_helper.rb +16 -2
- data/spec/routing/paid_up/plans_spec.rb +2 -0
- data/spec/routing/paid_up/subscription_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/controller_macros.rb +2 -0
- data/spec/support/factory_girl.rb +2 -0
- data/spec/support/loaded_site/features.rb +2 -0
- data/spec/support/loaded_site/groups.rb +2 -0
- data/spec/support/loaded_site/loaded_site.rb +2 -0
- data/spec/support/loaded_site/plans.rb +2 -0
- data/spec/support/loaded_site/posts.rb +2 -0
- data/spec/support/loaded_site/users.rb +4 -2
- data/spec/support/stripe.rb +2 -0
- data/spec/views/paid_up/plans_spec.rb +9 -7
- data/spec/views/paid_up/subscriptions_spec.rb +20 -19
- metadata +124 -90
- data/app/views/devise/confirmations/new.html.haml +0 -13
- data/app/views/devise/passwords/edit.html.haml +0 -19
- data/app/views/devise/passwords/new.html.haml +0 -14
- data/app/views/devise/registrations/_new_form.html.haml +0 -23
- data/app/views/devise/registrations/edit.html.haml +0 -39
- data/app/views/devise/registrations/new.html.haml +0 -11
- data/app/views/devise/sessions/_new_form.html.haml +0 -21
- data/app/views/devise/sessions/new.html.haml +0 -11
- data/app/views/devise/shared/_links.html.haml +0 -14
- data/app/views/devise/unlocks/new.html.haml +0 -14
- data/app/views/layouts/mailer.html.haml +0 -3
- data/app/views/layouts/mailer.text.haml +0 -1
- data/app/views/paid_up/subscription_mailer/payment_failed_email.html.haml +0 -0
- data/app/views/paid_up/subscription_mailer/payment_failed_email.text.haml +0 -0
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1927
- data/spec/dummy/app/views/pages/index.html.haml +0 -1
- data/spec/dummy/config/environments/production.rb +0 -83
- data/spec/dummy/config/initializers/high_voltage.rb +0 -3
data/spec/models/user_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
require 'cancan/matchers'
|
3
5
|
|
@@ -10,7 +12,7 @@ describe User do
|
|
10
12
|
end
|
11
13
|
|
12
14
|
context '#cards' do
|
13
|
-
subject {
|
15
|
+
subject { prof_subscriber.cards.first }
|
14
16
|
it { should be_a Stripe::Card }
|
15
17
|
end
|
16
18
|
|
@@ -67,13 +69,13 @@ describe User do
|
|
67
69
|
|
68
70
|
context 'starting from higher subscription' do
|
69
71
|
before do
|
70
|
-
|
72
|
+
prof_subscriber.subscribe_to_free_plan
|
71
73
|
end
|
72
74
|
after do
|
73
75
|
token = working_stripe_token no_ads_subscriber
|
74
|
-
|
76
|
+
prof_subscriber.subscribe_to_plan professional_plan, token
|
75
77
|
end
|
76
|
-
subject {
|
78
|
+
subject { prof_subscriber.plan }
|
77
79
|
it { should eq(free_plan) }
|
78
80
|
end
|
79
81
|
end
|
@@ -90,115 +92,115 @@ describe User do
|
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
93
|
-
context '#
|
95
|
+
context '#table_setting().rows_remaining' do
|
94
96
|
context 'when using a plan without the feature' do
|
95
|
-
subject { no_ads_subscriber.
|
97
|
+
subject { no_ads_subscriber.table_setting('doodads').rows_remaining }
|
96
98
|
it { should eq 0 }
|
97
99
|
end
|
98
100
|
context 'when subscribed to a plan with the feature limited' do
|
99
|
-
subject {
|
101
|
+
subject { leader_subscriber.table_setting('doodads').rows_remaining }
|
100
102
|
it { should eq 10 }
|
101
103
|
end
|
102
104
|
context 'when subscribed to a plan with the feature unlimited' do
|
103
|
-
subject {
|
105
|
+
subject { prof_subscriber.table_setting('doodads').rows_remaining }
|
104
106
|
it { should eq PaidUp::Unlimited.to_i }
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
|
-
context '#
|
110
|
+
context '#table_setting().rows_unlimited?' do
|
109
111
|
context 'when using a plan without the feature' do
|
110
|
-
subject { no_ads_subscriber.
|
112
|
+
subject { no_ads_subscriber.table_setting('doodads').rows_unlimited? }
|
111
113
|
it { should eq false }
|
112
114
|
end
|
113
115
|
context 'when subscribed to a plan with the feature limited' do
|
114
|
-
subject {
|
116
|
+
subject { leader_subscriber.table_setting('doodads').rows_unlimited? }
|
115
117
|
it { should eq false }
|
116
118
|
end
|
117
119
|
context 'when subscribed to a plan with the feature unlimited' do
|
118
|
-
subject {
|
120
|
+
subject { prof_subscriber.table_setting('doodads').rows_unlimited? }
|
119
121
|
it { should eq true }
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
|
-
context '#
|
125
|
+
context '#table_setting().rows_allowed' do
|
124
126
|
context 'when using a plan without the feature' do
|
125
|
-
subject { no_ads_subscriber.
|
127
|
+
subject { no_ads_subscriber.table_setting('doodads').rows_allowed }
|
126
128
|
it { should eq 0 }
|
127
129
|
end
|
128
130
|
context 'when subscribed to a plan with the feature limited' do
|
129
|
-
subject {
|
131
|
+
subject { leader_subscriber.table_setting('doodads').rows_allowed }
|
130
132
|
it { should eq 10 }
|
131
133
|
end
|
132
134
|
context 'when subscribed to a plan with the feature unlimited' do
|
133
|
-
subject {
|
135
|
+
subject { prof_subscriber.table_setting('doodads').rows_allowed }
|
134
136
|
it { should eq PaidUp::Unlimited.to_i }
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
138
|
-
context '#
|
140
|
+
context '#table_setting().rows_count' do
|
139
141
|
context 'when possessing no rows' do
|
140
|
-
subject {
|
142
|
+
subject { prof_subscriber.table_setting('doodads').rows_count }
|
141
143
|
it { should eq 0 }
|
142
144
|
end
|
143
145
|
context 'when possessing 3 rows' do
|
144
146
|
before do
|
145
147
|
3.times do
|
146
|
-
|
148
|
+
prof_subscriber.doodads.create! name: 'Test Doodad'
|
147
149
|
end
|
148
150
|
end
|
149
|
-
subject {
|
151
|
+
subject { prof_subscriber.table_setting('doodads').rows_count }
|
150
152
|
it { should eq 3 }
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
154
|
-
context '#
|
156
|
+
context '#rolify_setting().rows_remaining' do
|
155
157
|
context 'when using a plan without the feature' do
|
156
|
-
subject { no_ads_subscriber.
|
158
|
+
subject { no_ads_subscriber.rolify_setting('groups').rows_remaining }
|
157
159
|
it { should eq 0 }
|
158
160
|
end
|
159
161
|
context 'when subscribed to a plan with the feature limited' do
|
160
|
-
subject {
|
162
|
+
subject { leader_subscriber.rolify_setting('groups').rows_remaining }
|
161
163
|
it { should eq 4 }
|
162
164
|
end
|
163
165
|
context 'when subscribed to a plan with the feature unlimited' do
|
164
|
-
subject {
|
166
|
+
subject { prof_subscriber.rolify_setting('groups').rows_remaining }
|
165
167
|
it { should be > 99_999_999 }
|
166
168
|
end
|
167
169
|
end
|
168
170
|
|
169
|
-
context '#
|
171
|
+
context '#rolify_setting().rows_unlimited?' do
|
170
172
|
context 'when using a plan without the feature' do
|
171
|
-
subject { no_ads_subscriber.
|
173
|
+
subject { no_ads_subscriber.rolify_setting('groups').rows_unlimited? }
|
172
174
|
it { should eq false }
|
173
175
|
end
|
174
176
|
context 'when subscribed to a plan with the feature limited' do
|
175
|
-
subject {
|
177
|
+
subject { leader_subscriber.rolify_setting('groups').rows_unlimited? }
|
176
178
|
it { should eq false }
|
177
179
|
end
|
178
180
|
context 'when subscribed to a plan with the feature unlimited' do
|
179
|
-
subject {
|
181
|
+
subject { prof_subscriber.rolify_setting('groups').rows_unlimited? }
|
180
182
|
it { should eq true }
|
181
183
|
end
|
182
184
|
end
|
183
185
|
|
184
|
-
context '#
|
186
|
+
context '#rolify_setting().rows_allowed' do
|
185
187
|
context 'when using a plan without the feature' do
|
186
|
-
subject { no_ads_subscriber.
|
188
|
+
subject { no_ads_subscriber.rolify_setting('groups').rows_allowed }
|
187
189
|
it { should eq 0 }
|
188
190
|
end
|
189
191
|
context 'when subscribed to a plan with the feature limited' do
|
190
|
-
subject {
|
192
|
+
subject { leader_subscriber.rolify_setting('groups').rows_allowed }
|
191
193
|
it { should eq 5 }
|
192
194
|
end
|
193
195
|
context 'when subscribed to a plan with the feature unlimited' do
|
194
|
-
subject {
|
196
|
+
subject { prof_subscriber.rolify_setting('groups').rows_allowed }
|
195
197
|
it { should eq PaidUp::Unlimited.to_i }
|
196
198
|
end
|
197
199
|
end
|
198
200
|
|
199
|
-
context '#
|
201
|
+
context '#rolify_setting().rows_count' do
|
200
202
|
context 'when possessing no rows' do
|
201
|
-
subject { blank_subscriber.
|
203
|
+
subject { blank_subscriber.rolify_setting('groups').rows_count }
|
202
204
|
it { should eq 0 }
|
203
205
|
end
|
204
206
|
context 'when possessing 3 rows' do
|
@@ -211,7 +213,7 @@ describe User do
|
|
211
213
|
)
|
212
214
|
end
|
213
215
|
end
|
214
|
-
subject { blank_subscriber.
|
216
|
+
subject { blank_subscriber.rolify_setting('groups').rows_count }
|
215
217
|
it { should eq 3 }
|
216
218
|
end
|
217
219
|
end
|
@@ -227,28 +229,28 @@ describe User do
|
|
227
229
|
end
|
228
230
|
end
|
229
231
|
|
230
|
-
context '#
|
232
|
+
context '#paid_up_subscription' do
|
231
233
|
context 'when using free plan' do
|
232
|
-
subject { free_subscriber.
|
233
|
-
it { should be_a
|
234
|
+
subject { free_subscriber.paid_up_subscription }
|
235
|
+
it { should be_a PaidUp::Subscription }
|
234
236
|
end
|
235
237
|
context 'when subscribed to a plan' do
|
236
|
-
subject { no_ads_subscriber.
|
237
|
-
it { should be_a
|
238
|
+
subject { no_ads_subscriber.paid_up_subscription }
|
239
|
+
it { should be_a PaidUp::Subscription }
|
238
240
|
end
|
239
241
|
end
|
240
242
|
|
241
|
-
context '#
|
243
|
+
context '#subscribed_to?' do
|
242
244
|
context 'when using free plan' do
|
243
|
-
subject { free_subscriber.
|
245
|
+
subject { free_subscriber.subscribed_to? free_plan }
|
244
246
|
it { should be true }
|
245
247
|
end
|
246
248
|
context 'when true' do
|
247
|
-
subject {
|
249
|
+
subject { prof_subscriber.subscribed_to? professional_plan }
|
248
250
|
it { should be true }
|
249
251
|
end
|
250
252
|
context 'when false' do
|
251
|
-
subject { no_ads_subscriber.
|
253
|
+
subject { no_ads_subscriber.subscribed_to? professional_plan }
|
252
254
|
it { should be false }
|
253
255
|
end
|
254
256
|
end
|
@@ -269,7 +271,7 @@ describe User do
|
|
269
271
|
it { should be true }
|
270
272
|
end
|
271
273
|
context 'when false' do
|
272
|
-
subject {
|
274
|
+
subject { prof_subscriber.can_upgrade_to? no_ads_plan }
|
273
275
|
it { should be false }
|
274
276
|
end
|
275
277
|
end
|
@@ -290,7 +292,7 @@ describe User do
|
|
290
292
|
it { should be false }
|
291
293
|
end
|
292
294
|
context 'when true' do
|
293
|
-
subject {
|
295
|
+
subject { prof_subscriber.can_downgrade_to? no_ads_plan }
|
294
296
|
it { should be true }
|
295
297
|
end
|
296
298
|
end
|
@@ -313,7 +315,7 @@ describe User do
|
|
313
315
|
describe 'Abilities' do
|
314
316
|
context 'when anonymous' do
|
315
317
|
let(:group) do
|
316
|
-
FactoryGirl.create(:group, owner:
|
318
|
+
FactoryGirl.create(:group, owner: prof_subscriber)
|
317
319
|
end
|
318
320
|
let(:user) { nil }
|
319
321
|
subject(:ability) { Ability.new(user) }
|
@@ -327,7 +329,7 @@ describe User do
|
|
327
329
|
end
|
328
330
|
context 'when on free plan' do
|
329
331
|
let(:group) do
|
330
|
-
FactoryGirl.create(:group, owner:
|
332
|
+
FactoryGirl.create(:group, owner: prof_subscriber)
|
331
333
|
end
|
332
334
|
let(:user) { free_subscriber }
|
333
335
|
subject(:ability) { Ability.new(user) }
|
@@ -341,16 +343,16 @@ describe User do
|
|
341
343
|
end
|
342
344
|
context 'when on group plan' do
|
343
345
|
describe 'misc abilities' do
|
344
|
-
let(:user) {
|
346
|
+
let(:user) { leader_subscriber }
|
345
347
|
subject(:ability) { Ability.new(user) }
|
346
348
|
it { should be_able_to(:use, :ad_free) }
|
347
349
|
end
|
348
350
|
describe 'using groups' do
|
349
351
|
context 'given no groups are owned' do
|
350
352
|
let(:group) do
|
351
|
-
FactoryGirl.create(:group, owner:
|
353
|
+
FactoryGirl.create(:group, owner: leader_subscriber)
|
352
354
|
end
|
353
|
-
let(:user) {
|
355
|
+
let(:user) { leader_subscriber }
|
354
356
|
subject(:ability) { Ability.new(user) }
|
355
357
|
it { should be_able_to(:index, group) }
|
356
358
|
it { should be_able_to(:show, group) }
|
@@ -374,9 +376,9 @@ describe User do
|
|
374
376
|
describe 'using doodads' do
|
375
377
|
context 'given no doodads are owned' do
|
376
378
|
let(:doodad) do
|
377
|
-
FactoryGirl.create(:doodad, user:
|
379
|
+
FactoryGirl.create(:doodad, user: leader_subscriber)
|
378
380
|
end
|
379
|
-
let(:user) {
|
381
|
+
let(:user) { leader_subscriber }
|
380
382
|
subject(:ability) { Ability.new(user) }
|
381
383
|
it { should be_able_to(:index, doodad) }
|
382
384
|
it { should be_able_to(:show, doodad) }
|
@@ -400,9 +402,9 @@ describe User do
|
|
400
402
|
describe 'using posts' do
|
401
403
|
context 'given no posts are owned' do
|
402
404
|
let(:post) do
|
403
|
-
FactoryGirl.create(:post, user:
|
405
|
+
FactoryGirl.create(:post, user: leader_subscriber)
|
404
406
|
end
|
405
|
-
let(:user) {
|
407
|
+
let(:user) { leader_subscriber }
|
406
408
|
subject(:ability) { Ability.new(user) }
|
407
409
|
it { should be_able_to(:index, post) }
|
408
410
|
it { should be_able_to(:show, post) }
|
@@ -429,7 +431,7 @@ describe User do
|
|
429
431
|
let(:group) do
|
430
432
|
FactoryGirl.create(:group, owner: blank_subscriber)
|
431
433
|
end
|
432
|
-
let(:user) {
|
434
|
+
let(:user) { prof_subscriber }
|
433
435
|
subject(:ability) { Ability.new(user) }
|
434
436
|
it { should be_able_to(:index, group) }
|
435
437
|
it { should be_able_to(:show, group) }
|
@@ -441,9 +443,9 @@ describe User do
|
|
441
443
|
end
|
442
444
|
context 'given one group is owned' do
|
443
445
|
let(:group) do
|
444
|
-
FactoryGirl.create(:group, owner:
|
446
|
+
FactoryGirl.create(:group, owner: prof_subscriber)
|
445
447
|
end
|
446
|
-
let(:user) {
|
448
|
+
let(:user) { prof_subscriber }
|
447
449
|
subject(:ability) { Ability.new(user) }
|
448
450
|
it { should be_able_to(:index, group) }
|
449
451
|
it { should be_able_to(:show, group) }
|
data/spec/paid_up_spec.rb
CHANGED
data/spec/rails_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'coveralls'
|
2
4
|
Coveralls.wear!
|
3
5
|
|
@@ -7,6 +9,7 @@ require 'spec_helper'
|
|
7
9
|
require File.expand_path('../dummy/config/environment', __FILE__)
|
8
10
|
require 'rspec/rails'
|
9
11
|
# Add additional requires below this line. Rails is not loaded until this point!
|
12
|
+
require 'rspec/core/formatters/console_codes'
|
10
13
|
require 'shoulda/matchers'
|
11
14
|
require 'factory_girl_rails'
|
12
15
|
require 'capybara/rspec'
|
@@ -35,6 +38,10 @@ ActiveRecord::Migrator.migrations_paths = 'spec/dummy/db/migrate'
|
|
35
38
|
# If you are not using ActiveRecord, you can remove this line.
|
36
39
|
# ActiveRecord::Migration.maintain_test_schema!
|
37
40
|
|
41
|
+
# TODO: Add feature specs
|
42
|
+
# TODO: Add helper specs
|
43
|
+
# TODO: Remove view specs
|
44
|
+
|
38
45
|
RSpec.configure do |config|
|
39
46
|
config.before(:suite) do
|
40
47
|
DatabaseCleaner.strategy = :transaction
|
@@ -76,8 +83,15 @@ RSpec.configure do |config|
|
|
76
83
|
config.before(:each) { @routes = PaidUp::Engine.routes }
|
77
84
|
config.include PaidUp::Engine.routes.url_helpers
|
78
85
|
|
79
|
-
config.include Devise::
|
80
|
-
config.include Devise::
|
86
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
87
|
+
config.include Devise::Test::ControllerHelpers, type: :view
|
81
88
|
config.include ControllerMacros, type: :controller
|
82
89
|
config.include ControllerMacros, type: :view
|
83
90
|
end
|
91
|
+
|
92
|
+
Shoulda::Matchers.configure do |config|
|
93
|
+
config.integrate do |with|
|
94
|
+
with.test_framework :rspec
|
95
|
+
with.library :rails
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_context 'users' do
|
2
4
|
let(:free_subscriber) { User.find_by_name('Free Subscriber') }
|
3
5
|
let(:no_ads_subscriber) { User.find_by_name('No Ads Subscriber') }
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
+
let(:leader_subscriber) { User.find_by_name('Group Leader Subscriber') }
|
7
|
+
let(:prof_subscriber) { User.find_by_name('Professional Subscriber') }
|
6
8
|
let(:blank_subscriber) { User.find_by_name('Blank Subscriber') }
|
7
9
|
let(:disabling_subscriber) { User.find_by_name('Disabling Subscriber') }
|
8
10
|
end
|
data/spec/support/stripe.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
|
3
5
|
RSpec.describe 'paid_up/plans/index' do
|
4
6
|
include_context 'loaded site'
|
5
7
|
|
8
|
+
before do
|
9
|
+
view.extend PaidUp::PlansHelper
|
10
|
+
view.extend PaidUp::FeaturesHelper
|
11
|
+
view.extend BootstrapLeatherHelper
|
12
|
+
end
|
13
|
+
|
6
14
|
context 'when user is anonymous' do
|
7
15
|
before do
|
8
|
-
view.extend PaidUp::PlansHelper
|
9
|
-
view.extend PaidUp::FeaturesHelper
|
10
|
-
|
11
16
|
assign(:current_user, access_anonymous)
|
12
17
|
assign(:plans, PaidUp::Plan.subscribable)
|
13
18
|
render
|
@@ -29,10 +34,7 @@ RSpec.describe 'paid_up/plans/index' do
|
|
29
34
|
|
30
35
|
context 'when user is logged in as professional subscriber' do
|
31
36
|
before do
|
32
|
-
|
33
|
-
view.extend PaidUp::FeaturesHelper
|
34
|
-
|
35
|
-
assign(:current_user, login_subscriber(professional_subscriber))
|
37
|
+
assign(:current_user, login_subscriber(prof_subscriber))
|
36
38
|
assign(:plans, PaidUp::Plan.subscribable)
|
37
39
|
render
|
38
40
|
end
|
@@ -1,13 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails_helper'
|
2
4
|
|
3
5
|
RSpec.describe 'paid_up/subscriptions/new' do
|
4
6
|
include_context 'loaded site'
|
7
|
+
|
8
|
+
before do
|
9
|
+
view.extend PaidUp::PlansHelper
|
10
|
+
view.extend PaidUp::FeaturesHelper
|
11
|
+
view.extend BootstrapLeatherHelper
|
12
|
+
end
|
13
|
+
|
5
14
|
context 'when user is logged in as free customer' do
|
6
15
|
context 'displays a payment form' do
|
7
16
|
before do
|
8
|
-
view.extend PaidUp::PlansHelper
|
9
|
-
view.extend PaidUp::FeaturesHelper
|
10
|
-
|
11
17
|
assign(:current_user, login_subscriber(free_subscriber))
|
12
18
|
assign(:plan, professional_plan)
|
13
19
|
render
|
@@ -23,9 +29,6 @@ RSpec.describe 'paid_up/subscriptions/new' do
|
|
23
29
|
context 'when user is logged in as a paid customer' do
|
24
30
|
context 'displays a payment form' do
|
25
31
|
before do
|
26
|
-
view.extend PaidUp::PlansHelper
|
27
|
-
view.extend PaidUp::FeaturesHelper
|
28
|
-
|
29
32
|
assign(:current_user, login_subscriber(no_ads_subscriber))
|
30
33
|
assign(:plan, professional_plan)
|
31
34
|
render
|
@@ -42,26 +45,24 @@ end
|
|
42
45
|
|
43
46
|
RSpec.describe 'paid_up/subscriptions/index' do
|
44
47
|
include_context 'loaded site'
|
48
|
+
|
49
|
+
before do
|
50
|
+
view.extend PaidUp::PlansHelper
|
51
|
+
view.extend PaidUp::FeaturesHelper
|
52
|
+
view.extend BootstrapLeatherHelper
|
53
|
+
end
|
54
|
+
|
45
55
|
context 'when user is logged in' do
|
46
56
|
context "displays the details of a user's subscriptions" do
|
47
57
|
before do
|
48
|
-
|
49
|
-
view.extend PaidUp::FeaturesHelper
|
50
|
-
|
51
|
-
assign(:current_user, login_subscriber(group_leader_subscriber))
|
58
|
+
assign(:current_user, login_subscriber(leader_subscriber))
|
52
59
|
render
|
53
60
|
end
|
54
61
|
subject { rendered }
|
55
62
|
it { should include 'Group Leader' }
|
56
|
-
it
|
57
|
-
|
58
|
-
|
59
|
-
it do
|
60
|
-
should have_selector 'table.abilities #groups_ability .glyphicon-ok'
|
61
|
-
end
|
62
|
-
it do
|
63
|
-
should have_selector 'table.abilities #doodads_ability .glyphicon-ok'
|
64
|
-
end
|
63
|
+
it { should have_css 'table.abilities #ad_free_ability .glyphicon-ok' }
|
64
|
+
it { should have_css 'table.abilities #groups_ability .glyphicon-ok' }
|
65
|
+
it { should have_css 'table.abilities #doodads_ability .glyphicon-ok' }
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|