paid_up 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +1 -1
  4. data/VERSION +1 -1
  5. data/app/models/paid_up/ability.rb +7 -3
  6. data/coverage/.last_run.json +1 -1
  7. data/coverage/.resultset.json +1430 -33
  8. data/lib/paid_up/engine.rb +9 -4
  9. data/lib/paid_up/mixins/paid_for.rb +1 -1
  10. data/paid_up.gemspec +13 -5
  11. data/spec/controllers/paid_up/plans_spec.rb +2 -2
  12. data/spec/controllers/paid_up/subscriptions_spec.rb +25 -46
  13. data/spec/dummy/config/application.rb +12 -0
  14. data/spec/dummy/coverage/.last_run.json +5 -0
  15. data/spec/dummy/coverage/.resultset.json +155 -0
  16. data/spec/dummy/coverage/.resultset.json.lock +0 -0
  17. data/spec/dummy/db/development.sqlite3 +0 -0
  18. data/spec/dummy/db/seeds.rb +88 -14
  19. data/spec/dummy/db/test.sqlite3 +0 -0
  20. data/spec/dummy/log/development.log +2281 -0
  21. data/spec/factories/group.rb +10 -0
  22. data/spec/factories/user.rb +19 -1
  23. data/spec/models/group_spec.rb +5 -5
  24. data/spec/models/paid_up/feature_spec.rb +2 -1
  25. data/spec/models/paid_up/plan_spec.rb +3 -2
  26. data/spec/models/user_spec.rb +47 -32
  27. data/spec/rails_helper.rb +18 -1
  28. data/spec/routing/paid_up/plans_spec.rb +1 -1
  29. data/spec/routing/paid_up/subscription_spec.rb +1 -1
  30. data/spec/support/features.rb +5 -0
  31. data/spec/support/groups.rb +4 -32
  32. data/spec/support/loaded_site.rb +7 -0
  33. data/spec/support/plans.rb +7 -0
  34. data/spec/support/users.rb +8 -0
  35. data/spec/views/paid_up/plans_spec.rb +1 -2
  36. data/spec/views/paid_up/subscriptions_spec.rb +2 -3
  37. metadata +23 -4
  38. data/spec/support/plans_and_features.rb +0 -163
  39. data/spec/support/subscribers.rb +0 -44
@@ -4,10 +4,15 @@ module PaidUp
4
4
  engine_name "paid_up"
5
5
 
6
6
  config.generators do |g|
7
- g.test_framework :rspec, :fixture => false
8
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
9
- g.assets false
10
- g.helper false
7
+ g.hidden_namespaces << 'test_unit' << 'erb'
8
+ g.orm :active_record
9
+ g.template_engine :haml
10
+ g.test_framework :rspec, fixture: false
11
+ g.integration_tool :rspec
12
+ g.stylesheets false
13
+ g.javascripts false
14
+ g.view_specs false
15
+ g.helper_specs false
11
16
  end
12
17
 
13
18
  def self.table_name_prefix
@@ -60,7 +60,7 @@ module PaidUp::Mixins
60
60
  owners_records.count
61
61
  end
62
62
 
63
- send(:define_method, :enabled?) do
63
+ send(:define_method, :enabled) do
64
64
  if owners_enabled_count >= owners_records_count
65
65
  true
66
66
  else
data/paid_up.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: paid_up 0.7.5 ruby lib
5
+ # stub: paid_up 0.7.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "paid_up"
9
- s.version = "0.7.5"
9
+ s.version = "0.7.6"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Karen Lundgren"]
14
- s.date = "2015-06-21"
14
+ s.date = "2015-06-24"
15
15
  s.description = "Allows a model of your choosing (such as users) to subscribe to a plan, which enables features."
16
16
  s.email = "karen.e.lundgren@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -121,6 +121,9 @@ Gem::Specification.new do |s|
121
121
  "spec/dummy/config/locales/en.yml",
122
122
  "spec/dummy/config/routes.rb",
123
123
  "spec/dummy/config/secrets.yml",
124
+ "spec/dummy/coverage/.last_run.json",
125
+ "spec/dummy/coverage/.resultset.json",
126
+ "spec/dummy/coverage/.resultset.json.lock",
124
127
  "spec/dummy/db/development.sqlite3",
125
128
  "spec/dummy/db/migrate/20150406154440_create_users_table.rb",
126
129
  "spec/dummy/db/migrate/20150517175135_create_groups_table.rb",
@@ -164,10 +167,12 @@ Gem::Specification.new do |s|
164
167
  "spec/spec_helper.rb",
165
168
  "spec/support/controller_macros.rb",
166
169
  "spec/support/factory_girl.rb",
170
+ "spec/support/features.rb",
167
171
  "spec/support/groups.rb",
168
- "spec/support/plans_and_features.rb",
172
+ "spec/support/loaded_site.rb",
173
+ "spec/support/plans.rb",
169
174
  "spec/support/stripe.rb",
170
- "spec/support/subscribers.rb",
175
+ "spec/support/users.rb",
171
176
  "spec/views/paid_up/plans_spec.rb",
172
177
  "spec/views/paid_up/subscriptions_spec.rb"
173
178
  ]
@@ -199,6 +204,7 @@ Gem::Specification.new do |s|
199
204
  s.add_development_dependency(%q<sass-rails>, ["~> 5.0"])
200
205
  s.add_development_dependency(%q<high_voltage>, ["~> 2.3"])
201
206
  s.add_development_dependency(%q<rspec-rails>, ["~> 3.2"])
207
+ s.add_development_dependency(%q<factory_girl_rails>, ["~> 4.5"])
202
208
  else
203
209
  s.add_dependency(%q<rails>, ["~> 4"])
204
210
  s.add_dependency(%q<rails-i18n>, ["~> 4"])
@@ -219,6 +225,7 @@ Gem::Specification.new do |s|
219
225
  s.add_dependency(%q<sass-rails>, ["~> 5.0"])
220
226
  s.add_dependency(%q<high_voltage>, ["~> 2.3"])
221
227
  s.add_dependency(%q<rspec-rails>, ["~> 3.2"])
228
+ s.add_dependency(%q<factory_girl_rails>, ["~> 4.5"])
222
229
  end
223
230
  else
224
231
  s.add_dependency(%q<rails>, ["~> 4"])
@@ -240,6 +247,7 @@ Gem::Specification.new do |s|
240
247
  s.add_dependency(%q<sass-rails>, ["~> 5.0"])
241
248
  s.add_dependency(%q<high_voltage>, ["~> 2.3"])
242
249
  s.add_dependency(%q<rspec-rails>, ["~> 3.2"])
250
+ s.add_dependency(%q<factory_girl_rails>, ["~> 4.5"])
243
251
  end
244
252
  end
245
253
 
@@ -1,11 +1,11 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe PaidUp::PlansController do
4
- include_context 'plans and features'
4
+ include_context 'loaded site'
5
5
  routes { PaidUp::Engine.routes }
6
6
 
7
7
  describe "GET #index" do
8
- before :each do
8
+ before do
9
9
  get :index
10
10
  end
11
11
  context "responds successfully with an HTTP 200 status code" do
@@ -2,12 +2,12 @@ require 'rails_helper'
2
2
 
3
3
 
4
4
  RSpec.describe PaidUp::SubscriptionsController do
5
- include_context 'plans and features'
5
+ include_context 'loaded site'
6
6
  routes { PaidUp::Engine.routes }
7
7
 
8
8
  describe 'GET #index' do
9
9
  context 'when the user is anonymous' do
10
- before :each do
10
+ before do
11
11
  access_anonymous
12
12
  get :index
13
13
  end
@@ -18,8 +18,7 @@ RSpec.describe PaidUp::SubscriptionsController do
18
18
  end
19
19
  end
20
20
  context 'when the user is signed in as a subscriber' do
21
- include_context 'subscribers'
22
- before :each do
21
+ before do
23
22
  sign_in free_subscriber
24
23
  get :index
25
24
  end
@@ -37,7 +36,7 @@ RSpec.describe PaidUp::SubscriptionsController do
37
36
 
38
37
  describe "GET #new" do
39
38
  context "when the user is anonymous" do
40
- before :each do
39
+ before do
41
40
  access_anonymous
42
41
  get :new, plan_id: professional_plan.id
43
42
  end
@@ -50,11 +49,13 @@ RSpec.describe PaidUp::SubscriptionsController do
50
49
  context "when the user is signed in" do
51
50
  context 'when upgrading' do
52
51
  context 'with a paid plan' do
53
- include_context 'subscribers'
54
- before :each do
52
+ before do
55
53
  sign_in free_subscriber
56
54
  get :new, plan_id: professional_plan.id
57
55
  end
56
+ after do
57
+ free_subscriber.subscribe_to_plan free_plan
58
+ end
58
59
  context "responds successfully with an HTTP 200 status code" do
59
60
  subject { response }
60
61
  it { should be_success }
@@ -70,11 +71,13 @@ RSpec.describe PaidUp::SubscriptionsController do
70
71
  end
71
72
  end
72
73
  context 'with the free plan' do
73
- include_context 'subscribers'
74
- before :each do
74
+ before do
75
75
  login_subscriber no_ads_subscriber
76
76
  get :new, plan_id: free_plan.id
77
77
  end
78
+ after do
79
+ no_ads_subscriber.subscribe_to_plan no_ads_plan
80
+ end
78
81
  context "redirects to the subscriptions index page" do
79
82
  subject { response }
80
83
  it { should redirect_to subscriptions_path }
@@ -86,11 +89,13 @@ RSpec.describe PaidUp::SubscriptionsController do
86
89
  end
87
90
  end
88
91
  context 'when downgrading' do
89
- include_context 'subscribers'
90
- before :each do
92
+ before do
91
93
  sign_in professional_subscriber
92
94
  get :new, plan_id: no_ads_plan.id
93
95
  end
96
+ after do
97
+ professional_subscriber.subscribe_to_plan professional_plan
98
+ end
94
99
  context "redirects to the subscriptions index page" do
95
100
  subject { response }
96
101
  it { should redirect_to subscriptions_path }
@@ -107,7 +112,7 @@ RSpec.describe PaidUp::SubscriptionsController do
107
112
 
108
113
  describe "POST #create" do
109
114
  context "when the user is anonymous" do
110
- before :each do
115
+ before do
111
116
  access_anonymous
112
117
  get :index
113
118
  end
@@ -119,12 +124,14 @@ RSpec.describe PaidUp::SubscriptionsController do
119
124
  end
120
125
  context "when the user is signed in" do
121
126
  context "upgrading from the free plan" do
122
- include_context 'subscribers'
123
- before :each do
127
+ before do
124
128
  sign_in free_subscriber
125
129
  token = working_stripe_token free_subscriber
126
130
  post :create, plan_id: professional_plan.id, stripeToken: token
127
131
  end
132
+ after do
133
+ free_subscriber.subscribe_to_plan free_plan
134
+ end
128
135
  context "redirects to the subscriptions index page" do
129
136
  subject { response }
130
137
  it { should redirect_to subscriptions_path }
@@ -137,11 +144,13 @@ RSpec.describe PaidUp::SubscriptionsController do
137
144
  end
138
145
 
139
146
  context "upgrading from the no ads plan" do
140
- include_context 'subscribers'
141
- before :each do
147
+ before do
142
148
  sign_in no_ads_subscriber
143
149
  post :create, plan_id: professional_plan.id
144
150
  end
151
+ after do
152
+ no_ads_subscriber.subscribe_to_plan no_ads_plan
153
+ end
145
154
  context "redirects to the subscriptions index page" do
146
155
  subject { response }
147
156
  it { should redirect_to subscriptions_path }
@@ -154,34 +163,4 @@ RSpec.describe PaidUp::SubscriptionsController do
154
163
  end
155
164
  end
156
165
  end
157
-
158
- describe "GET #index" do
159
- context "when the user is anonymous" do
160
- before :each do
161
- access_anonymous
162
- get :index
163
- end
164
- context 'redirects to the user sign up page' do
165
- subject { response }
166
- it { should redirect_to '/users/sign_in' }
167
- it { should have_http_status(302) }
168
- end
169
- end
170
- context "when the user is signed in" do
171
- include_context 'subscribers'
172
- before :each do
173
- sign_in free_subscriber
174
- get :index
175
- end
176
- context "responds successfully with an HTTP 200 status code" do
177
- subject { response }
178
- it { should be_success }
179
- it { should have_http_status(200) }
180
- end
181
- context "renders the index template" do
182
- subject { response }
183
- it { should render_template("index") }
184
- end
185
- end
186
- end
187
166
  end
@@ -26,6 +26,18 @@ module Dummy
26
26
 
27
27
  # Do not swallow errors in after_commit/after_rollback callbacks.
28
28
  config.active_record.raise_in_transactional_callbacks = true
29
+
30
+ config.generators do |g|
31
+ g.hidden_namespaces << 'test_unit' << 'erb'
32
+ g.orm :active_record
33
+ g.template_engine :haml
34
+ g.test_framework :rspec, fixture: false
35
+ g.integration_tool :rspec
36
+ g.stylesheets false
37
+ g.javascripts false
38
+ g.view_specs false
39
+ g.helper_specs false
40
+ end
29
41
  end
30
42
  end
31
43
 
@@ -0,0 +1,5 @@
1
+ {
2
+ "result": {
3
+ "covered_percent": 53.33
4
+ }
5
+ }
@@ -0,0 +1,155 @@
1
+ {
2
+ "RSpec": {
3
+ "coverage": {
4
+ "/home/work/Gems/paid_up/spec/dummy/spec/spec_helper.rb": [
5
+ null,
6
+ null,
7
+ null,
8
+ null,
9
+ null,
10
+ null,
11
+ null,
12
+ null,
13
+ null,
14
+ null,
15
+ null,
16
+ null,
17
+ null,
18
+ null,
19
+ null,
20
+ null,
21
+ null,
22
+ null,
23
+ 1,
24
+ null,
25
+ null,
26
+ null,
27
+ 1,
28
+ null,
29
+ null,
30
+ null,
31
+ null,
32
+ null,
33
+ null,
34
+ null,
35
+ 1,
36
+ null,
37
+ null,
38
+ null,
39
+ null,
40
+ 1,
41
+ null,
42
+ null,
43
+ null,
44
+ 1,
45
+ null,
46
+ null,
47
+ null,
48
+ null,
49
+ null,
50
+ null,
51
+ null,
52
+ null,
53
+ null,
54
+ null,
55
+ null,
56
+ null,
57
+ null,
58
+ null,
59
+ null,
60
+ null,
61
+ null,
62
+ null,
63
+ null,
64
+ null,
65
+ null,
66
+ null,
67
+ null,
68
+ null,
69
+ null,
70
+ null,
71
+ null,
72
+ null,
73
+ null,
74
+ null,
75
+ null,
76
+ null,
77
+ null,
78
+ null,
79
+ null,
80
+ null,
81
+ null,
82
+ null,
83
+ null,
84
+ null,
85
+ null,
86
+ null,
87
+ null,
88
+ null,
89
+ null,
90
+ null,
91
+ null
92
+ ],
93
+ "/home/work/Gems/paid_up/spec/dummy/spec/dummy/config/environment.rb": [
94
+ null,
95
+ 1,
96
+ null,
97
+ null,
98
+ 0
99
+ ],
100
+ "/home/work/Gems/paid_up/spec/dummy/spec/dummy/config/application.rb": [
101
+ 1,
102
+ null,
103
+ null,
104
+ 1,
105
+ 1,
106
+ null,
107
+ 1,
108
+ 1,
109
+ null,
110
+ 1,
111
+ 1,
112
+ null,
113
+ 0,
114
+ 0,
115
+ null,
116
+ null,
117
+ null,
118
+ null,
119
+ null,
120
+ null,
121
+ null,
122
+ null,
123
+ null,
124
+ null,
125
+ null,
126
+ null,
127
+ null,
128
+ 0,
129
+ null,
130
+ 0,
131
+ 0,
132
+ 0,
133
+ 0,
134
+ 0,
135
+ 0,
136
+ 0,
137
+ 0,
138
+ 0,
139
+ 0,
140
+ null,
141
+ null,
142
+ null,
143
+ null
144
+ ],
145
+ "/home/work/Gems/paid_up/spec/dummy/spec/dummy/config/boot.rb": [
146
+ null,
147
+ 1,
148
+ null,
149
+ 1,
150
+ 1
151
+ ]
152
+ },
153
+ "timestamp": 1435112021
154
+ }
155
+ }
File without changes
Binary file
@@ -1,3 +1,5 @@
1
+ # Dir[Rails.root.join("spec/factories/*.rb")].each {|f| require f}
2
+
1
3
  ###############
2
4
  # Plans #
3
5
  ###############
@@ -12,7 +14,7 @@ Stripe::Plan.find_or_create_by_id(
12
14
  :id => 'anonymous-plan'
13
15
  }
14
16
  )
15
- anonymous = PaidUp::Plan.create(
17
+ anonymous_plan = PaidUp::Plan.create(
16
18
  title: 'Anonymous',
17
19
  stripe_id: 'anonymous-plan',
18
20
  description: "What you can do without logging in.",
@@ -28,7 +30,7 @@ Stripe::Plan.find_or_create_by_id(
28
30
  :id => 'free-plan'
29
31
  }
30
32
  )
31
- free = PaidUp::Plan.create(
33
+ free_plan = PaidUp::Plan.create(
32
34
  title: 'Free',
33
35
  stripe_id: 'free-plan',
34
36
  description: "Can't beat the price!",
@@ -44,7 +46,7 @@ Stripe::Plan.find_or_create_by_id(
44
46
  :id => 'no-ads-plan'
45
47
  }
46
48
  )
47
- no_ads = PaidUp::Plan.create(
49
+ no_ads_plan = PaidUp::Plan.create(
48
50
  title: 'No Ads',
49
51
  stripe_id: 'no-ads-plan',
50
52
  description: "No frills, just removes the ads.",
@@ -60,7 +62,7 @@ Stripe::Plan.find_or_create_by_id(
60
62
  :id => 'group-leader-plan'
61
63
  }
62
64
  )
63
- group_leader = PaidUp::Plan.create(
65
+ group_leader_plan = PaidUp::Plan.create(
64
66
  title: 'Group Leader',
65
67
  stripe_id: 'group-leader-plan',
66
68
  description: "For leaders of single groups, with configuration.",
@@ -76,7 +78,7 @@ Stripe::Plan.find_or_create_by_id(
76
78
  :id => 'professional-plan'
77
79
  }
78
80
  )
79
- professional = PaidUp::Plan.create(
81
+ professional_plan = PaidUp::Plan.create(
80
82
  title: 'Professional',
81
83
  stripe_id: 'professional-plan',
82
84
  description: "Designed for professionals with unlimited groups, a calendar and configuration.",
@@ -100,40 +102,112 @@ Stripe::Customer.find_or_create_by_id(
100
102
  # Ad Free
101
103
  PaidUp::PlanFeatureSetting.create(
102
104
  feature: 'ad_free',
103
- plan: no_ads,
105
+ plan: no_ads_plan,
104
106
  setting: 1
105
107
  )
106
108
 
107
109
  # Group Leader
108
110
  PaidUp::PlanFeatureSetting.create(
109
111
  feature: 'ad_free',
110
- plan: group_leader,
112
+ plan: group_leader_plan,
111
113
  setting: 1
112
114
  )
113
115
  PaidUp::PlanFeatureSetting.create(
114
116
  feature: 'groups',
115
- plan: group_leader,
116
- setting: 1
117
+ plan: group_leader_plan,
118
+ setting: 5
117
119
  )
118
120
  PaidUp::PlanFeatureSetting.create(
119
121
  feature: 'doodads',
120
- plan: group_leader,
121
- setting: 5
122
+ plan: group_leader_plan,
123
+ setting: 10
122
124
  )
123
125
 
124
126
  # Professional
125
127
  PaidUp::PlanFeatureSetting.create(
126
128
  feature: 'ad_free',
127
- plan: professional,
129
+ plan: professional_plan,
128
130
  setting: 1
129
131
  )
130
132
  PaidUp::PlanFeatureSetting.create(
131
133
  feature: 'groups',
132
- plan: professional,
134
+ plan: professional_plan,
133
135
  setting: PaidUp::Unlimited.to_i(:db)
134
136
  )
135
137
  PaidUp::PlanFeatureSetting.create(
136
138
  feature: 'doodads',
137
- plan: professional,
139
+ plan: professional_plan,
138
140
  setting: PaidUp::Unlimited.to_i(:db)
141
+ )
142
+
143
+ ###############
144
+ # Users #
145
+ ###############
146
+
147
+ free_subscriber = FactoryGirl.create(
148
+ :user,
149
+ name: 'Free Subscriber',
150
+ plan: free_plan
151
+ )
152
+
153
+ no_ads_subscriber = FactoryGirl.create(
154
+ :user,
155
+ name: 'No Ads Subscriber',
156
+ plan: no_ads_plan
157
+ )
158
+
159
+ group_leader_subscriber = FactoryGirl.create(
160
+ :user,
161
+ name: 'Group Leader Subscriber',
162
+ plan: group_leader_plan
163
+ )
164
+
165
+ disabling_subscriber = FactoryGirl.create(
166
+ :user,
167
+ name: 'Disabling Subscriber',
168
+ plan: group_leader_plan
169
+ )
170
+
171
+ professional_subscriber = FactoryGirl.create(
172
+ :user,
173
+ name: 'Professional Subscriber',
174
+ plan: professional_plan
175
+ )
176
+
177
+ blank_subscriber = FactoryGirl.create(
178
+ :user,
179
+ name: 'Blank Subscriber',
180
+ plan: professional_plan
181
+ )
182
+
183
+ ###############
184
+ # Groups #
185
+ ###############
186
+
187
+ FactoryGirl.create(
188
+ :group,
189
+ title: 'First Group',
190
+ owner: group_leader_subscriber
191
+ )
192
+
193
+ FactoryGirl.create(
194
+ :group,
195
+ title: 'Second Group',
196
+ owner: professional_subscriber
197
+ )
198
+
199
+ FactoryGirl.create(
200
+ :group,
201
+ title: 'Third Group',
202
+ owner: professional_subscriber
203
+ )
204
+
205
+ 5.times do
206
+ FactoryGirl.create(:group, owner: disabling_subscriber)
207
+ end
208
+
209
+ FactoryGirl.create(
210
+ :group,
211
+ title: 'Disabled Group',
212
+ owner: disabling_subscriber
139
213
  )
Binary file