paid_up 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/Gemfile +5 -1
  4. data/Rakefile +12 -10
  5. data/VERSION +1 -1
  6. data/app/controllers/paid_up/paid_up_controller.rb +8 -3
  7. data/app/controllers/paid_up/plans_controller.rb +2 -1
  8. data/app/controllers/paid_up/subscriptions_controller.rb +19 -6
  9. data/app/helpers/paid_up/features_helper.rb +19 -6
  10. data/app/helpers/paid_up/paid_up_helper.rb +6 -3
  11. data/app/helpers/paid_up/plans_helper.rb +12 -5
  12. data/app/helpers/paid_up/subscriptions_helper.rb +10 -3
  13. data/app/models/paid_up/ability.rb +43 -44
  14. data/app/models/paid_up/plan.rb +81 -69
  15. data/app/models/paid_up/plan_feature_setting.rb +17 -9
  16. data/app/models/paid_up/unlimited.rb +15 -13
  17. data/app/views/devise/confirmations/new.html.haml +1 -1
  18. data/app/views/devise/passwords/edit.html.haml +1 -1
  19. data/app/views/devise/passwords/new.html.haml +1 -1
  20. data/app/views/devise/registrations/_new_form.html.haml +1 -1
  21. data/app/views/devise/registrations/new.html.haml +1 -1
  22. data/app/views/devise/sessions/new.html.haml +1 -1
  23. data/app/views/devise/unlocks/new.html.haml +1 -1
  24. data/app/views/layouts/mailer.html.haml +1 -1
  25. data/app/views/layouts/mailer.text.haml +1 -1
  26. data/app/views/paid_up/features/_abilities_table.html.haml +1 -1
  27. data/app/views/paid_up/plans/index.html.haml +1 -1
  28. data/app/views/paid_up/subscriptions/new.html.haml +1 -1
  29. data/config/initializers/stripe.rb +3 -3
  30. data/coverage/.last_run.json +1 -1
  31. data/coverage/.resultset.json +414 -253
  32. data/db/migrate/20150407110101_create_paid_up_plans_table.rb +3 -3
  33. data/lib/generators/paid_up/install/install_generator.rb +42 -33
  34. data/lib/generators/paid_up/install/templates/ability.rb +1 -0
  35. data/lib/generators/paid_up/install/templates/initializer.rb +16 -14
  36. data/lib/generators/paid_up/utils.rb +11 -4
  37. data/lib/paid_up/configuration.rb +13 -8
  38. data/lib/paid_up/engine.rb +4 -3
  39. data/lib/paid_up/extensions/integer.rb +8 -5
  40. data/lib/paid_up/extensions/stripe.rb +10 -9
  41. data/lib/paid_up/feature.rb +27 -17
  42. data/lib/paid_up/localization.rb +17 -18
  43. data/lib/paid_up/mixins/paid_for.rb +66 -54
  44. data/lib/paid_up/mixins/subscriber.rb +154 -161
  45. data/lib/paid_up/railtie.rb +1 -1
  46. data/lib/paid_up/validators/rolify_rows.rb +14 -6
  47. data/lib/paid_up/validators/table_rows.rb +14 -6
  48. data/lib/paid_up/version.rb +1 -1
  49. data/lib/paid_up.rb +7 -8
  50. data/paid_up.gemspec +21 -8
  51. data/spec/controllers/paid_up/plans_spec.rb +6 -6
  52. data/spec/controllers/paid_up/subscriptions_spec.rb +68 -68
  53. data/spec/dummy/Rakefile +2 -1
  54. data/spec/dummy/app/assets/stylesheets/application.css.scss +3 -16
  55. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  56. data/spec/dummy/app/models/doodad.rb +1 -1
  57. data/spec/dummy/app/models/group.rb +1 -1
  58. data/spec/dummy/app/models/role.rb +4 -4
  59. data/spec/dummy/app/models/user.rb +1 -1
  60. data/spec/dummy/app/views/layouts/application.html.haml +2 -2
  61. data/spec/dummy/app/views/pages/index.html.haml +1 -1
  62. data/spec/dummy/config/application.rb +16 -12
  63. data/spec/dummy/config/environments/development.rb +4 -3
  64. data/spec/dummy/config/environments/production.rb +10 -6
  65. data/spec/dummy/config/environments/test.rb +3 -2
  66. data/spec/dummy/config/initializers/assets.rb +2 -1
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -2
  68. data/spec/dummy/config/initializers/devise.rb +58 -42
  69. data/spec/dummy/config/initializers/high_voltage.rb +1 -1
  70. data/spec/dummy/config/initializers/mime_types.rb +1 -1
  71. data/spec/dummy/config/initializers/paid_up.rb +16 -14
  72. data/spec/dummy/config/initializers/rolify.rb +3 -2
  73. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
  74. data/spec/dummy/config/routes.rb +2 -2
  75. data/spec/dummy/db/migrate/20150523010827_add_devise_to_users.rb +2 -2
  76. data/spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb +2 -2
  77. data/spec/dummy/db/migrate/20160207184112_create_paid_up_plans_table.paid_up.rb +3 -3
  78. data/spec/dummy/db/schema.rb +53 -53
  79. data/spec/dummy/db/seeds.rb +41 -56
  80. data/spec/dummy/db/test.sqlite3 +0 -0
  81. data/spec/dummy/lib/tasks/system.rake +2 -2
  82. data/spec/factories/group.rb +1 -1
  83. data/spec/factories/plan.rb +1 -1
  84. data/spec/factories/plan_feature_setting.rb +1 -1
  85. data/spec/factories/user.rb +13 -11
  86. data/spec/models/group_spec.rb +8 -7
  87. data/spec/models/paid_up/feature_spec.rb +18 -4
  88. data/spec/models/paid_up/plan_feature_setting_spec.rb +2 -2
  89. data/spec/models/paid_up/plan_spec.rb +12 -8
  90. data/spec/models/user_spec.rb +88 -78
  91. data/spec/paid_up_spec.rb +1 -1
  92. data/spec/rails_helper.rb +5 -5
  93. data/spec/routing/paid_up/plans_spec.rb +3 -3
  94. data/spec/routing/paid_up/subscription_spec.rb +30 -7
  95. data/spec/spec_helper.rb +7 -52
  96. data/spec/support/controller_macros.rb +2 -2
  97. data/spec/support/factory_girl.rb +1 -1
  98. data/spec/support/{features.rb → loaded_site/features.rb} +2 -2
  99. data/spec/support/{groups.rb → loaded_site/groups.rb} +1 -1
  100. data/spec/support/{loaded_site.rb → loaded_site/loaded_site.rb} +1 -1
  101. data/spec/support/{plans.rb → loaded_site/plans.rb} +8 -4
  102. data/spec/support/{users.rb → loaded_site/users.rb} +1 -1
  103. data/spec/support/stripe.rb +10 -13
  104. data/spec/views/paid_up/plans_spec.rb +17 -17
  105. data/spec/views/paid_up/subscriptions_spec.rb +24 -14
  106. metadata +64 -7
@@ -1,23 +1,20 @@
1
1
  shared_context 'stripe' do
2
- let(:default_card_data) {
2
+ let(:default_card_data) do
3
3
  {
4
- number: '4242424242424242',
5
- exp_month: 1,
6
- exp_year: 45,
7
- cvc: '111'
4
+ number: '4242424242424242',
5
+ exp_month: 1,
6
+ exp_year: 45,
7
+ cvc: '111'
8
8
  }
9
- }
9
+ end
10
10
  end
11
+
11
12
  def working_stripe_token(subscriber, card_hash = default_card_data)
12
13
  unless subscriber.stripe_id.present?
13
- customer = Stripe::Customer.create(
14
- email: subscriber.email
15
- )
14
+ customer = Stripe::Customer.create(email: subscriber.email)
16
15
  subscriber.stripe_id = customer.id
17
16
  subscriber.save
18
17
  subscriber.reload
19
18
  end
20
- Stripe::Token.create(
21
- card: card_hash
22
- ).id
23
- end
19
+ Stripe::Token.create(card: card_hash).id
20
+ end
@@ -1,6 +1,6 @@
1
- require "rails_helper"
1
+ require 'rails_helper'
2
2
 
3
- RSpec.describe "paid_up/plans/index" do
3
+ RSpec.describe 'paid_up/plans/index' do
4
4
  include_context 'loaded site'
5
5
 
6
6
  context 'when user is anonymous' do
@@ -12,18 +12,18 @@ RSpec.describe "paid_up/plans/index" do
12
12
  assign(:plans, PaidUp::Plan.subscribable)
13
13
  render
14
14
  end
15
- context "displays the subscribable plans" do
15
+ context 'displays the subscribable plans' do
16
16
  subject { rendered }
17
- it { should match /Free/ }
17
+ it { should include 'Free' }
18
18
  it { should have_css '.free_subscribe_button .btn-success' }
19
- it { should match /No Ads/ }
19
+ it { should include 'No Ads' }
20
20
  it { should have_css '.no_ads_subscribe_button .btn-success' }
21
- it { should match /Group Leader/ }
21
+ it { should include 'Group Leader' }
22
22
  it { should have_css '.group_leader_subscribe_button .btn-success' }
23
- it { should match /Professional/ }
23
+ it { should include 'Professional' }
24
24
  it { should have_css '.professional_subscribe_button .btn-success' }
25
- it { should_not match /Error/}
26
- it { should_not match /Anonymous/}
25
+ it { should_not include 'Error' }
26
+ it { should_not include 'Anonymous' }
27
27
  end
28
28
  end
29
29
 
@@ -36,18 +36,18 @@ RSpec.describe "paid_up/plans/index" do
36
36
  assign(:plans, PaidUp::Plan.subscribable)
37
37
  render
38
38
  end
39
- context "displays all the plans" do
39
+ context 'displays all the plans' do
40
40
  subject { rendered }
41
- it { should match /Free/ }
41
+ it { should include 'Free' }
42
42
  it { should have_css '.free_subscribe_button .btn-danger' }
43
- it { should match /No Ads/ }
43
+ it { should include 'No Ads' }
44
44
  it { should have_css '.no_ads_subscribe_button .btn-danger' }
45
- it { should match /Group Leader/ }
45
+ it { should include 'Group Leader' }
46
46
  it { should have_css '.group_leader_subscribe_button .btn-danger' }
47
- it { should match /Professional/ }
47
+ it { should include 'Professional' }
48
48
  it { should have_css '.professional_subscribe_button .btn-disabled' }
49
- it { should_not match /Error/}
50
- it { should_not match /Anonymous/}
49
+ it { should_not include 'Error' }
50
+ it { should_not include 'Anonymous' }
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -1,9 +1,9 @@
1
- require "rails_helper"
1
+ require 'rails_helper'
2
2
 
3
- RSpec.describe "paid_up/subscriptions/new" do
3
+ RSpec.describe 'paid_up/subscriptions/new' do
4
4
  include_context 'loaded site'
5
5
  context 'when user is logged in as free customer' do
6
- context "displays a payment form" do
6
+ context 'displays a payment form' do
7
7
  before do
8
8
  view.extend PaidUp::PlansHelper
9
9
  view.extend PaidUp::FeaturesHelper
@@ -13,13 +13,15 @@ RSpec.describe "paid_up/subscriptions/new" do
13
13
  render
14
14
  end
15
15
  subject { rendered }
16
- it { should match /Professional/ }
16
+ it { should include 'Professional' }
17
17
  it { should have_selector 'form' }
18
- it { should match /#{paid_up.plan_subscriptions_path(professional_plan.id)}/ }
18
+ it do
19
+ should include paid_up.plan_subscriptions_path(professional_plan.id)
20
+ end
19
21
  end
20
22
  end
21
23
  context 'when user is logged in as a paid customer' do
22
- context "displays a payment form" do
24
+ context 'displays a payment form' do
23
25
  before do
24
26
  view.extend PaidUp::PlansHelper
25
27
  view.extend PaidUp::FeaturesHelper
@@ -29,14 +31,16 @@ RSpec.describe "paid_up/subscriptions/new" do
29
31
  render
30
32
  end
31
33
  subject { rendered }
32
- it { should match /Professional/ }
34
+ it { should include 'Professional' }
33
35
  it { should have_selector 'form' }
34
- it { should match /#{paid_up.plan_subscriptions_path(professional_plan.id)}/ }
36
+ it do
37
+ should include paid_up.plan_subscriptions_path(professional_plan.id)
38
+ end
35
39
  end
36
40
  end
37
41
  end
38
42
 
39
- RSpec.describe "paid_up/subscriptions/index" do
43
+ RSpec.describe 'paid_up/subscriptions/index' do
40
44
  include_context 'loaded site'
41
45
  context 'when user is logged in' do
42
46
  context "displays the details of a user's subscriptions" do
@@ -48,10 +52,16 @@ RSpec.describe "paid_up/subscriptions/index" do
48
52
  render
49
53
  end
50
54
  subject { rendered }
51
- it { should match /Group Leader/ }
52
- it { should have_selector 'table.abilities #ad_free_ability .glyphicon-ok'}
53
- it { should have_selector 'table.abilities #groups_ability .glyphicon-ok'}
54
- it { should have_selector 'table.abilities #doodads_ability .glyphicon-ok'}
55
+ it { should include 'Group Leader' }
56
+ it do
57
+ should have_selector 'table.abilities #ad_free_ability .glyphicon-ok'
58
+ end
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
55
65
  end
56
66
  end
57
- end
67
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paid_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.13
4
+ version: 0.9.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen Lundgren
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-20 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -220,6 +220,62 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '3.0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: pre-commit
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0.27'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.27'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.37'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.37'
251
+ - !ruby/object:Gem::Dependency
252
+ name: coffeelint
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '1.14'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '1.14'
265
+ - !ruby/object:Gem::Dependency
266
+ name: scss_lint
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: 0.47.0
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: 0.47.0
223
279
  - !ruby/object:Gem::Dependency
224
280
  name: sqlite3
225
281
  requirement: !ruby/object:Gem::Requirement
@@ -328,6 +384,7 @@ extra_rdoc_files:
328
384
  - README.md
329
385
  files:
330
386
  - ".rspec"
387
+ - ".rubocop.yml"
331
388
  - ".travis.yml"
332
389
  - Gemfile
333
390
  - LICENSE.txt
@@ -482,12 +539,12 @@ files:
482
539
  - spec/spec_helper.rb
483
540
  - spec/support/controller_macros.rb
484
541
  - spec/support/factory_girl.rb
485
- - spec/support/features.rb
486
- - spec/support/groups.rb
487
- - spec/support/loaded_site.rb
488
- - spec/support/plans.rb
542
+ - spec/support/loaded_site/features.rb
543
+ - spec/support/loaded_site/groups.rb
544
+ - spec/support/loaded_site/loaded_site.rb
545
+ - spec/support/loaded_site/plans.rb
546
+ - spec/support/loaded_site/users.rb
489
547
  - spec/support/stripe.rb
490
- - spec/support/users.rb
491
548
  - spec/views/paid_up/plans_spec.rb
492
549
  - spec/views/paid_up/subscriptions_spec.rb
493
550
  homepage: http://www.gemvein.com/museum/cases/paid_up