paid_up 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +28 -20
  4. data/VERSION +1 -1
  5. data/app/helpers/paid_up/features_helper.rb +3 -3
  6. data/app/models/paid_up/ability.rb +29 -11
  7. data/app/models/paid_up/feature.rb +70 -8
  8. data/app/models/paid_up/features_plan.rb +1 -2
  9. data/app/models/paid_up/plan.rb +9 -13
  10. data/app/models/paid_up/unlimited.rb +15 -0
  11. data/app/views/paid_up/features/_abilities_table.html.haml +13 -4
  12. data/app/views/paid_up/subscriptions/new.html.haml +20 -20
  13. data/bin/rails +8 -1
  14. data/config/locales/en.yml +4 -1
  15. data/coverage/.last_run.json +1 -1
  16. data/coverage/.resultset.json +291 -145
  17. data/db/migrate/20150407105900_create_paid_up_features_plans_table.rb +1 -1
  18. data/lib/generators/paid_up/install/install_generator.rb +6 -0
  19. data/lib/generators/paid_up/install/templates/initializer.rb +21 -1
  20. data/lib/paid_up/{integer.rb → extensions/integer.rb} +2 -4
  21. data/lib/paid_up/{stripe_extensions.rb → extensions/stripe.rb} +3 -6
  22. data/lib/paid_up/mixins/paid_for.rb +24 -0
  23. data/lib/paid_up/{mixins.rb → mixins/subscriber.rb} +28 -22
  24. data/lib/paid_up/validators/rolify_rows.rb +9 -0
  25. data/lib/paid_up/{table_validator.rb → validators/table_rows.rb} +2 -2
  26. data/lib/paid_up.rb +27 -7
  27. data/paid_up.gemspec +26 -16
  28. data/spec/dummy/app/models/ability.rb +0 -1
  29. data/spec/dummy/app/models/doodad.rb +3 -0
  30. data/spec/dummy/app/models/group.rb +1 -1
  31. data/spec/dummy/app/models/role.rb +10 -0
  32. data/spec/dummy/app/models/user.rb +2 -3
  33. data/spec/dummy/bin/rspec +3 -0
  34. data/spec/dummy/config/application.rb +0 -1
  35. data/spec/dummy/config/initializers/paid_up.rb +21 -1
  36. data/spec/dummy/config/initializers/rolify.rb +7 -0
  37. data/spec/dummy/config/routes.rb +10 -0
  38. data/spec/dummy/db/development.sqlite3 +0 -0
  39. data/spec/dummy/db/migrate/20150517175135_create_groups_table.rb +0 -1
  40. data/spec/dummy/db/migrate/20150517175136_create_doodads_table.rb +9 -0
  41. data/spec/dummy/db/migrate/{20150518000915_add_devise_to_users.rb → 20150523010827_add_devise_to_users.rb} +0 -0
  42. data/spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb +19 -0
  43. data/spec/dummy/db/migrate/{20150518000917_create_paid_up_features_plans_table.paid_up.rb → 20150523010838_create_paid_up_features_plans_table.paid_up.rb} +1 -1
  44. data/spec/dummy/db/migrate/{20150518000919_create_paid_up_plans_table.paid_up.rb → 20150523010839_create_paid_up_plans_table.paid_up.rb} +0 -0
  45. data/spec/dummy/db/migrate/{20150519164355_add_stripe_id_column_to_users.paid_up.rb → 20150523010840_add_stripe_id_column_to_users.paid_up.rb} +0 -0
  46. data/spec/dummy/db/schema.rb +29 -15
  47. data/spec/dummy/db/seeds/features_plans.seeds.rb +9 -9
  48. data/spec/dummy/db/test.sqlite3 +0 -0
  49. data/spec/dummy/log/development.log +932 -108863
  50. data/spec/models/paid_up/feature_spec.rb +23 -5
  51. data/spec/models/paid_up/features_plan_spec.rb +2 -1
  52. data/spec/models/paid_up/plan_spec.rb +8 -32
  53. data/spec/models/user_spec.rb +110 -37
  54. data/spec/rails_helper.rb +1 -0
  55. data/spec/support/plans_and_features.rb +16 -62
  56. data/spec/views/paid_up/subscriptions_spec.rb +1 -1
  57. metadata +47 -15
  58. data/db/migrate/20150407110100_create_paid_up_features_table.rb +0 -11
  59. data/lib/paid_up/unlimited.rb +0 -17
  60. data/spec/dummy/db/migrate/20150518000918_create_paid_up_features_table.paid_up.rb +0 -12
  61. data/spec/dummy/db/seeds/features.seeds.rb +0 -19
  62. data/spec/dummy/test/controllers/plans_controller_controller_test.rb +0 -7
@@ -1,21 +1,39 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe PaidUp::Feature do
4
- it { should have_many(:features_plans).class_name('PaidUp::FeaturesPlan') }
5
- it { should have_many(:plans).class_name('PaidUp::Plan').through(:features_plans) }
6
- it { should validate_presence_of(:name) }
4
+ it { should validate_presence_of(:slug) }
7
5
  it { should validate_presence_of(:title) }
8
6
  it { should validate_presence_of(:setting_type) }
7
+ it { should validate_inclusion_of(:setting_type).in_array(%w(boolean table_rows rolify_rows))}
9
8
 
9
+ include_context 'plans and features'
10
10
  context '#feature_model' do
11
- include_context 'plans and features'
12
11
  subject { groups_feature.feature_model }
13
12
  it { should eq Group }
14
13
  end
15
14
 
16
15
  context '#feature_model_name' do
17
- include_context 'plans and features'
18
16
  subject { groups_feature.feature_model_name }
19
17
  it { should eq 'Group' }
20
18
  end
19
+
20
+ context '.all' do
21
+ subject { PaidUp::Feature.all }
22
+ it { should eq [ad_free_feature, groups_feature, doodads_feature] }
23
+ end
24
+
25
+ context '.find_by_slug' do
26
+ subject { PaidUp::Feature.find_by_slug('groups') }
27
+ it { should be_a PaidUp::Feature }
28
+ end
29
+
30
+ context '.find_all' do
31
+ subject { PaidUp::Feature.find_all( setting_type: 'rolify_rows') }
32
+ it { should be_an Array }
33
+ end
34
+
35
+ context '.find' do
36
+ subject { PaidUp::Feature.find(setting_type: 'rolify_rows') }
37
+ it { should be_a PaidUp::Feature }
38
+ end
21
39
  end
@@ -2,6 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  describe PaidUp::FeaturesPlan do
4
4
  it { should belong_to(:plan).class_name("PaidUp::Plan") }
5
- it { should belong_to(:feature).class_name("PaidUp::Feature") }
6
5
  it { should validate_presence_of(:setting) }
6
+ it { should validate_presence_of(:plan) }
7
+ it { should validate_presence_of(:feature) }
7
8
  end
@@ -4,8 +4,8 @@ describe PaidUp::Plan do
4
4
  it { should have_many(:features_plans).class_name('PaidUp::FeaturesPlan') }
5
5
  it { should have_many(:features).class_name('PaidUp::Feature').through(:features_plans) }
6
6
 
7
- it { should validate_presence_of(:description) }
8
7
  it { should validate_presence_of(:name) }
8
+ it { should validate_presence_of(:stripe_id) }
9
9
 
10
10
  include_context 'plans and features'
11
11
 
@@ -26,46 +26,22 @@ describe PaidUp::Plan do
26
26
  describe '#feature_setting' do
27
27
  describe 'when setting_type is integer' do
28
28
  context 'returns the setting value if available' do
29
- subject { group_leader_plan.feature_setting(groups_feature.id) }
29
+ subject { group_leader_plan.feature_setting('groups') }
30
30
  it { should eq(1) }
31
31
  end
32
32
  context 'returns 0 if not available' do
33
- subject { free_plan.feature_setting(groups_feature.id) }
33
+ subject { free_plan.feature_setting('groups') }
34
34
  it { should eq(0) }
35
35
  end
36
36
  end
37
37
 
38
38
  describe 'when setting_type is boolean' do
39
39
  context 'returns the setting value if available' do
40
- subject { group_leader_plan.feature_setting(configuration_feature.id) }
40
+ subject { group_leader_plan.feature_setting('ad_free') }
41
41
  it { should eq(true) }
42
42
  end
43
43
  context 'returns false if not available' do
44
- subject { free_plan.feature_setting(configuration_feature.id) }
45
- it { should eq(false) }
46
- end
47
- end
48
- end
49
-
50
- describe '#feature_setting_by_name' do
51
- describe 'when setting_type is integer' do
52
- context 'returns the setting value if available' do
53
- subject { group_leader_plan.feature_setting_by_name('groups') }
54
- it { should eq(1) }
55
- end
56
- context 'returns 0 if not available' do
57
- subject { free_plan.feature_setting_by_name('groups') }
58
- it { should eq(0) }
59
- end
60
- end
61
-
62
- describe 'when setting_type is boolean' do
63
- context 'returns the setting value if available' do
64
- subject { group_leader_plan.feature_setting_by_name('ad_free') }
65
- it { should eq(true) }
66
- end
67
- context 'returns false if not available' do
68
- subject { free_plan.feature_setting_by_name('ad_free') }
44
+ subject { free_plan.feature_setting('ad_free') }
69
45
  it { should eq(false) }
70
46
  end
71
47
  end
@@ -73,15 +49,15 @@ describe PaidUp::Plan do
73
49
 
74
50
  describe '#feature_unlimited?' do
75
51
  context 'returns true if unlimited' do
76
- subject { professional_plan.feature_unlimited?(groups_feature.id) }
52
+ subject { professional_plan.feature_unlimited?('groups') }
77
53
  it { should eq(true) }
78
54
  end
79
55
  context 'returns false if an integer' do
80
- subject { group_leader_plan.feature_unlimited?(groups_feature.id) }
56
+ subject { group_leader_plan.feature_unlimited?('groups') }
81
57
  it { should eq(false) }
82
58
  end
83
59
  context 'returns false if not found' do
84
- subject { free_plan.feature_unlimited?(groups_feature.id) }
60
+ subject { free_plan.feature_unlimited?('groups') }
85
61
  it { should eq(false) }
86
62
  end
87
63
  end
@@ -79,61 +79,123 @@ describe User do
79
79
 
80
80
  context '#table_rows_remaining' do
81
81
  context 'when using a plan without the feature' do
82
- subject { no_ads_subscriber.table_rows_remaining 'groups' }
82
+ subject { no_ads_subscriber.table_rows_remaining 'doodads' }
83
83
  it { should eq 0 }
84
84
  end
85
85
  context 'when subscribed to a plan with the feature limited' do
86
- subject { group_leader_subscriber.table_rows_remaining 'groups' }
87
- it { should eq 1 }
86
+ subject { group_leader_subscriber.table_rows_remaining 'doodads' }
87
+ it { should eq 5 }
88
88
  end
89
89
  context 'when subscribed to a plan with the feature unlimited' do
90
- subject { professional_subscriber.table_rows_remaining 'groups' }
90
+ subject { professional_subscriber.table_rows_remaining 'doodads' }
91
91
  it { should eq PaidUp::Unlimited.to_i }
92
92
  end
93
93
  end
94
94
 
95
95
  context '#table_rows_unlimited?' do
96
96
  context 'when using a plan without the feature' do
97
- subject { no_ads_subscriber.table_rows_unlimited? 'groups' }
97
+ subject { no_ads_subscriber.table_rows_unlimited? 'doodads' }
98
98
  it { should eq false }
99
99
  end
100
100
  context 'when subscribed to a plan with the feature limited' do
101
- subject { group_leader_subscriber.table_rows_unlimited? 'groups' }
101
+ subject { group_leader_subscriber.table_rows_unlimited? 'doodads' }
102
102
  it { should eq false }
103
103
  end
104
104
  context 'when subscribed to a plan with the feature unlimited' do
105
- subject { professional_subscriber.table_rows_unlimited? 'groups' }
105
+ subject { professional_subscriber.table_rows_unlimited? 'doodads' }
106
106
  it { should eq true }
107
107
  end
108
108
  end
109
109
 
110
110
  context '#table_rows_allowed' do
111
111
  context 'when using a plan without the feature' do
112
- subject { no_ads_subscriber.table_rows_allowed 'groups' }
112
+ subject { no_ads_subscriber.table_rows_allowed 'doodads' }
113
113
  it { should eq 0 }
114
114
  end
115
115
  context 'when subscribed to a plan with the feature limited' do
116
- subject { group_leader_subscriber.table_rows_allowed 'groups' }
117
- it { should eq 1 }
116
+ subject { group_leader_subscriber.table_rows_allowed 'doodads' }
117
+ it { should eq 5 }
118
118
  end
119
119
  context 'when subscribed to a plan with the feature unlimited' do
120
- subject { professional_subscriber.table_rows_allowed 'groups' }
120
+ subject { professional_subscriber.table_rows_allowed 'doodads' }
121
121
  it { should eq PaidUp::Unlimited.to_i }
122
122
  end
123
123
  end
124
124
 
125
125
  context '#table_rows' do
126
126
  context 'when possessing no rows' do
127
- subject { professional_subscriber.table_rows 'groups' }
127
+ subject { professional_subscriber.table_rows 'doodads' }
128
+ it { should eq 0 }
129
+ end
130
+ context 'when possessing 3 rows' do
131
+ before do
132
+ 3.times do
133
+ professional_subscriber.doodads.create! name: 'Test Doodad'
134
+ end
135
+ end
136
+ subject { professional_subscriber.table_rows 'doodads' }
137
+ it { should eq 3 }
138
+ end
139
+ end
140
+
141
+ context '#rolify_rows_remaining' do
142
+ context 'when using a plan without the feature' do
143
+ subject { no_ads_subscriber.rolify_rows_remaining 'groups' }
144
+ it { should eq 0 }
145
+ end
146
+ context 'when subscribed to a plan with the feature limited' do
147
+ subject { group_leader_subscriber.rolify_rows_remaining 'groups' }
148
+ it { should eq 1 }
149
+ end
150
+ context 'when subscribed to a plan with the feature unlimited' do
151
+ subject { professional_subscriber.rolify_rows_remaining 'groups' }
152
+ it { should eq PaidUp::Unlimited.to_i }
153
+ end
154
+ end
155
+
156
+ context '#rolify_rows_unlimited?' do
157
+ context 'when using a plan without the feature' do
158
+ subject { no_ads_subscriber.rolify_rows_unlimited? 'groups' }
159
+ it { should eq false }
160
+ end
161
+ context 'when subscribed to a plan with the feature limited' do
162
+ subject { group_leader_subscriber.rolify_rows_unlimited? 'groups' }
163
+ it { should eq false }
164
+ end
165
+ context 'when subscribed to a plan with the feature unlimited' do
166
+ subject { professional_subscriber.rolify_rows_unlimited? 'groups' }
167
+ it { should eq true }
168
+ end
169
+ end
170
+
171
+ context '#rolify_rows_allowed' do
172
+ context 'when using a plan without the feature' do
173
+ subject { no_ads_subscriber.rolify_rows_allowed 'groups' }
174
+ it { should eq 0 }
175
+ end
176
+ context 'when subscribed to a plan with the feature limited' do
177
+ subject { group_leader_subscriber.rolify_rows_allowed 'groups' }
178
+ it { should eq 1 }
179
+ end
180
+ context 'when subscribed to a plan with the feature unlimited' do
181
+ subject { professional_subscriber.rolify_rows_allowed 'groups' }
182
+ it { should eq PaidUp::Unlimited.to_i }
183
+ end
184
+ end
185
+
186
+ context '#rolify_rows' do
187
+ context 'when possessing no rows' do
188
+ subject { professional_subscriber.rolify_rows 'groups' }
128
189
  it { should eq 0 }
129
190
  end
130
191
  context 'when possessing 3 rows' do
131
- subject {
132
- professional_subscriber.groups.create! name: 'Test Group'
133
- professional_subscriber.groups.create! name: 'Test Group'
134
- professional_subscriber.groups.create! name: 'Test Group'
135
- professional_subscriber.table_rows 'groups'
136
- }
192
+ before do
193
+ 3.times do
194
+ group = Group.create! name: 'Test Group'
195
+ professional_subscriber.add_role(:owner, group)
196
+ end
197
+ end
198
+ subject { professional_subscriber.rolify_rows 'groups' }
137
199
  it { should eq 3 }
138
200
  end
139
201
  end
@@ -234,70 +296,81 @@ describe User do
234
296
 
235
297
 
236
298
  describe "Abilities" do
237
- subject(:ability){ Ability.new(user) }
238
299
 
239
300
  context "when anonymous" do
240
- let(:user){ User.new }
301
+ let(:group) { Group.create!(name: 'Test Group') }
302
+ let(:user){ nil }
303
+ subject(:ability){ Ability.new(user) }
241
304
  it{ should be_able_to(:read, Group) }
242
- it{ should_not be_able_to(:manage, Group) }
305
+ it{ should_not be_able_to(:manage, group) }
243
306
  it{ should_not be_able_to(:own, Group) }
244
307
  it{ should_not be_able_to(:create, Group) }
245
308
  it{ should_not be_able_to(:use, :ad_free) }
246
- it{ should_not be_able_to(:use, :calendar) }
309
+ it{ should_not be_able_to(:create, Doodad) }
247
310
  end
248
311
  context "when on free plan" do
312
+ let(:group) { Group.create!(name: 'Test Group') }
249
313
  let(:user){ free_subscriber }
314
+ subject(:ability){ Ability.new(user) }
250
315
  it{ should be_able_to(:read, Group) }
251
- it{ should_not be_able_to(:manage, Group) }
316
+ it{ should_not be_able_to(:manage, group) }
252
317
  it{ should_not be_able_to(:own, Group) }
253
318
  it{ should_not be_able_to(:create, Group) }
254
319
  it{ should_not be_able_to(:use, :ad_free) }
255
- it{ should_not be_able_to(:use, :calendar) }
320
+ it{ should_not be_able_to(:create, Doodad) }
256
321
  end
257
322
  context "when on group plan" do
258
323
  context "given no groups are owned" do
324
+ let(:group) { Group.create!(name: 'Test Group') }
259
325
  let(:user){ group_leader_subscriber }
326
+ subject(:ability){ Ability.new(user) }
260
327
  it{ should be_able_to(:read, Group) }
261
- it{ should be_able_to(:manage, Group) }
328
+ it{ should_not be_able_to(:manage, group) }
262
329
  it{ should be_able_to(:own, Group) }
263
330
  it{ should be_able_to(:create, Group) }
264
331
  it{ should be_able_to(:use, :ad_free) }
265
- it{ should_not be_able_to(:use, :calendar) }
332
+ it{ should be_able_to(:create, Doodad) }
266
333
  end
267
334
  context "given one group is owned" do
268
- let(:user){
269
- group_leader_subscriber.groups.create!(name: 'Test Group')
270
- group_leader_subscriber.reload
335
+ let(:group) { Group.create!(name: 'Test Group') }
336
+ let(:user) {
337
+ group_leader_subscriber.add_role(:owner, group)
338
+ group_leader_subscriber
271
339
  }
340
+ subject(:ability){ Ability.new(user) }
272
341
  it{ should be_able_to(:read, Group) }
273
- it{ should be_able_to(:manage, Group) }
342
+ it{ should be_able_to(:manage, group) }
274
343
  it{ should be_able_to(:own, Group) }
275
344
  it{ should_not be_able_to(:create, Group) }
276
345
  it{ should be_able_to(:use, :ad_free) }
277
- it{ should_not be_able_to(:use, :calendar) }
346
+ it{ should be_able_to(:create, Doodad) }
278
347
  end
279
348
  end
280
349
  context "when on professional plan" do
281
350
  context "given no groups are owned" do
351
+ let(:group) { Group.create!(name: 'Test Group') }
282
352
  let(:user){ professional_subscriber }
353
+ subject(:ability){ Ability.new(user) }
283
354
  it{ should be_able_to(:read, Group) }
284
- it{ should be_able_to(:manage, Group) }
355
+ it{ should_not be_able_to(:manage, group) }
285
356
  it{ should be_able_to(:own, Group) }
286
357
  it{ should be_able_to(:create, Group) }
287
358
  it{ should be_able_to(:use, :ad_free) }
288
- it{ should be_able_to(:use, :calendar) }
359
+ it{ should be_able_to(:create, Doodad) }
289
360
  end
290
361
  context "given one group is owned" do
362
+ let(:group){ Group.create!(name: 'Test Group') }
291
363
  let(:user){
292
- professional_subscriber.groups.create!(name: 'Test Group')
293
- professional_subscriber.reload
364
+ professional_subscriber.add_role(:owner, group)
365
+ professional_subscriber
294
366
  }
367
+ subject(:ability){ Ability.new(user) }
295
368
  it{ should be_able_to(:read, Group) }
296
- it{ should be_able_to(:manage, Group) }
369
+ it{ should be_able_to(:manage, group) }
297
370
  it{ should be_able_to(:own, Group) }
298
371
  it{ should be_able_to(:create, Group) }
299
372
  it{ should be_able_to(:use, :ad_free) }
300
- it{ should be_able_to(:use, :calendar) }
373
+ it{ should be_able_to(:create, Doodad) }
301
374
  end
302
375
  end
303
376
  end
data/spec/rails_helper.rb CHANGED
@@ -9,6 +9,7 @@ require 'rspec/rails'
9
9
  # Add additional requires below this line. Rails is not loaded until this point!
10
10
  require 'shoulda/matchers'
11
11
  require 'factory_girl_rails'
12
+ require 'capybara/rspec'
12
13
 
13
14
  # Requires supporting ruby files with custom matchers and macros, etc, in
14
15
  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@@ -1,44 +1,13 @@
1
1
  shared_context "plans and features" do
2
2
  include_context 'stripe'
3
-
3
+
4
4
  ############
5
5
  # Features #
6
6
  ############
7
7
 
8
- let!(:ad_free_feature) { FactoryGirl.create(
9
- :feature,
10
- name: 'ad_free',
11
- title: 'Ad Free',
12
- setting_type: 'boolean'
13
- ) }
14
-
15
- let!(:groups_feature) { FactoryGirl.create(
16
- :feature,
17
- name: 'groups',
18
- title: 'Groups',
19
- setting_type: 'table_rows'
20
- ) }
21
-
22
- let!(:configuration_feature) { FactoryGirl.create(
23
- :feature,
24
- name: 'configuration',
25
- title: 'Configuration',
26
- setting_type: 'boolean'
27
- ) }
28
-
29
- let!(:theme_feature) { FactoryGirl.create(
30
- :feature,
31
- name: 'theme',
32
- title: 'Theme',
33
- setting_type: 'boolean'
34
- ) }
35
-
36
- let!(:calendar_feature) { FactoryGirl.create(
37
- :feature,
38
- name: 'calendar',
39
- title: 'Calendar',
40
- setting_type: 'boolean'
41
- ) }
8
+ let!(:ad_free_feature) { PaidUp::Feature.find_by_slug('ad_free') }
9
+ let!(:groups_feature) { PaidUp::Feature.find_by_slug('groups') }
10
+ let!(:doodads_feature) { PaidUp::Feature.find_by_slug('doodads') }
42
11
 
43
12
  #########
44
13
  # Plans #
@@ -101,7 +70,8 @@ shared_context "plans and features" do
101
70
  FactoryGirl.create(
102
71
  :features_plan,
103
72
  plan_id: no_ads_plan.id,
104
- feature_id: ad_free_feature.id
73
+ feature: 'ad_free',
74
+ setting: true
105
75
  )
106
76
  }
107
77
  let!(:group_leader_plan) {
@@ -126,7 +96,7 @@ shared_context "plans and features" do
126
96
  FactoryGirl.create(
127
97
  :features_plan,
128
98
  plan_id: group_leader_plan.id,
129
- feature_id: ad_free_feature.id,
99
+ feature: 'ad_free',
130
100
  setting: true
131
101
  )
132
102
  }
@@ -134,16 +104,16 @@ shared_context "plans and features" do
134
104
  FactoryGirl.create(
135
105
  :features_plan,
136
106
  plan_id: group_leader_plan.id,
137
- feature_id: groups_feature.id,
107
+ feature: 'groups',
138
108
  setting: 1
139
109
  )
140
110
  }
141
- let!(:configuration_group_leader_features_plan) {
111
+ let!(:doodads_group_leader_features_plan) {
142
112
  FactoryGirl.create(
143
113
  :features_plan,
144
114
  plan_id: group_leader_plan.id,
145
- feature_id: configuration_feature.id,
146
- setting: true
115
+ feature: 'doodads',
116
+ setting: 5
147
117
  )
148
118
  }
149
119
  let!(:professional_plan) {
@@ -169,7 +139,7 @@ shared_context "plans and features" do
169
139
  FactoryGirl.create(
170
140
  :features_plan,
171
141
  plan_id: professional_plan.id,
172
- feature_id: ad_free_feature.id,
142
+ feature: 'ad_free',
173
143
  setting: true
174
144
  )
175
145
  }
@@ -177,32 +147,16 @@ shared_context "plans and features" do
177
147
  FactoryGirl.create(
178
148
  :features_plan,
179
149
  plan_id: professional_plan.id,
180
- feature_id: groups_feature.id,
150
+ feature: 'groups',
181
151
  setting: PaidUp::Unlimited.to_i(:db)
182
152
  )
183
153
  }
184
- let!(:configuration_professional_features_plan) {
185
- FactoryGirl.create(
186
- :features_plan,
187
- plan_id: professional_plan.id,
188
- feature_id: configuration_feature.id,
189
- setting: true
190
- )
191
- }
192
- let!(:theme_professional_features_plan) {
193
- FactoryGirl.create(
194
- :features_plan,
195
- plan_id: professional_plan.id,
196
- feature_id: theme_feature.id,
197
- setting: true
198
- )
199
- }
200
- let!(:calendar_professional_features_plan) {
154
+ let!(:doodads_professional_features_plan) {
201
155
  FactoryGirl.create(
202
156
  :features_plan,
203
157
  plan_id: professional_plan.id,
204
- feature_id: calendar_feature.id,
205
- setting: true
158
+ feature: 'doodads',
159
+ setting: PaidUp::Unlimited.to_i(:db)
206
160
  )
207
161
  }
208
162
 
@@ -52,7 +52,7 @@ RSpec.describe "paid_up/subscriptions/index" do
52
52
  it { should match /Group Leader/ }
53
53
  it { should have_selector 'table.abilities #ad_free_ability .glyphicon-ok'}
54
54
  it { should have_selector 'table.abilities #groups_ability .glyphicon-ok'}
55
- it { should have_selector 'table.abilities #calendar_ability .glyphicon-remove'}
55
+ it { should have_selector 'table.abilities #doodads_ability .glyphicon-ok'}
56
56
  end
57
57
  end
58
58
  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.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen Lundgren
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '1.6'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rolify
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '4'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '4'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: stripe
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +262,20 @@ dependencies:
248
262
  - - "~>"
249
263
  - !ruby/object:Gem::Version
250
264
  version: '5.0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: high_voltage
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '2.3'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '2.3'
251
279
  description: Allows a model of your choosing (such as users) to subscribe to a plan,
252
280
  which enables features.
253
281
  email: karen.e.lundgren@gmail.com
@@ -277,6 +305,7 @@ files:
277
305
  - app/models/paid_up/feature.rb
278
306
  - app/models/paid_up/features_plan.rb
279
307
  - app/models/paid_up/plan.rb
308
+ - app/models/paid_up/unlimited.rb
280
309
  - app/views/devise/confirmations/new.html.haml
281
310
  - app/views/devise/passwords/edit.html.haml
282
311
  - app/views/devise/passwords/new.html.haml
@@ -300,7 +329,6 @@ files:
300
329
  - coverage/.resultset.json
301
330
  - coverage/.resultset.json.lock
302
331
  - db/migrate/20150407105900_create_paid_up_features_plans_table.rb
303
- - db/migrate/20150407110100_create_paid_up_features_table.rb
304
332
  - db/migrate/20150407110101_create_paid_up_plans_table.rb
305
333
  - db/migrate/20150519164237_add_stripe_id_column_to_users.rb
306
334
  - lib/generators/paid_up/install/install_generator.rb
@@ -310,13 +338,14 @@ files:
310
338
  - lib/paid_up.rb
311
339
  - lib/paid_up/configuration.rb
312
340
  - lib/paid_up/engine.rb
313
- - lib/paid_up/integer.rb
341
+ - lib/paid_up/extensions/integer.rb
342
+ - lib/paid_up/extensions/stripe.rb
314
343
  - lib/paid_up/localization.rb
315
- - lib/paid_up/mixins.rb
344
+ - lib/paid_up/mixins/paid_for.rb
345
+ - lib/paid_up/mixins/subscriber.rb
316
346
  - lib/paid_up/railtie.rb
317
- - lib/paid_up/stripe_extensions.rb
318
- - lib/paid_up/table_validator.rb
319
- - lib/paid_up/unlimited.rb
347
+ - lib/paid_up/validators/rolify_rows.rb
348
+ - lib/paid_up/validators/table_rows.rb
320
349
  - lib/paid_up/version.rb
321
350
  - paid_up.gemspec
322
351
  - spec/controllers/paid_up/plans_spec.rb
@@ -326,13 +355,16 @@ files:
326
355
  - spec/dummy/app/assets/stylesheets/application.css.scss
327
356
  - spec/dummy/app/controllers/application_controller.rb
328
357
  - spec/dummy/app/models/ability.rb
358
+ - spec/dummy/app/models/doodad.rb
329
359
  - spec/dummy/app/models/group.rb
360
+ - spec/dummy/app/models/role.rb
330
361
  - spec/dummy/app/models/user.rb
331
362
  - spec/dummy/app/views/layouts/application.html.haml
332
363
  - spec/dummy/app/views/pages/index.html.haml
333
364
  - spec/dummy/bin/bundle
334
365
  - spec/dummy/bin/rails
335
366
  - spec/dummy/bin/rake
367
+ - spec/dummy/bin/rspec
336
368
  - spec/dummy/bin/setup
337
369
  - spec/dummy/config.ru
338
370
  - spec/dummy/config/application.rb
@@ -351,6 +383,7 @@ files:
351
383
  - spec/dummy/config/initializers/inflections.rb
352
384
  - spec/dummy/config/initializers/mime_types.rb
353
385
  - spec/dummy/config/initializers/paid_up.rb
386
+ - spec/dummy/config/initializers/rolify.rb
354
387
  - spec/dummy/config/initializers/session_store.rb
355
388
  - spec/dummy/config/initializers/wrap_parameters.rb
356
389
  - spec/dummy/config/locales/devise.en.yml
@@ -360,14 +393,14 @@ files:
360
393
  - spec/dummy/db/development.sqlite3
361
394
  - spec/dummy/db/migrate/20150406154440_create_users_table.rb
362
395
  - spec/dummy/db/migrate/20150517175135_create_groups_table.rb
363
- - spec/dummy/db/migrate/20150518000915_add_devise_to_users.rb
364
- - spec/dummy/db/migrate/20150518000917_create_paid_up_features_plans_table.paid_up.rb
365
- - spec/dummy/db/migrate/20150518000918_create_paid_up_features_table.paid_up.rb
366
- - spec/dummy/db/migrate/20150518000919_create_paid_up_plans_table.paid_up.rb
367
- - spec/dummy/db/migrate/20150519164355_add_stripe_id_column_to_users.paid_up.rb
396
+ - spec/dummy/db/migrate/20150517175136_create_doodads_table.rb
397
+ - spec/dummy/db/migrate/20150523010827_add_devise_to_users.rb
398
+ - spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb
399
+ - spec/dummy/db/migrate/20150523010838_create_paid_up_features_plans_table.paid_up.rb
400
+ - spec/dummy/db/migrate/20150523010839_create_paid_up_plans_table.paid_up.rb
401
+ - spec/dummy/db/migrate/20150523010840_add_stripe_id_column_to_users.paid_up.rb
368
402
  - spec/dummy/db/schema.rb
369
403
  - spec/dummy/db/seeds.rb
370
- - spec/dummy/db/seeds/features.seeds.rb
371
404
  - spec/dummy/db/seeds/features_plans.seeds.rb
372
405
  - spec/dummy/db/seeds/plans.seeds.rb
373
406
  - spec/dummy/db/test.sqlite3
@@ -386,7 +419,6 @@ files:
386
419
  - spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf
387
420
  - spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2
388
421
  - spec/dummy/public/favicon.ico
389
- - spec/dummy/test/controllers/plans_controller_controller_test.rb
390
422
  - spec/factories/feature.rb
391
423
  - spec/factories/features_plan.rb
392
424
  - spec/factories/plan.rb