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
@@ -1,33 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
PaidUp.configure do |config|
|
2
4
|
config.anonymous_customer_stripe_id = 'anonymous-customer'
|
3
5
|
config.anonymous_plan_stripe_id = 'anonymous-plan'
|
4
6
|
config.free_plan_stripe_id = 'free-plan'
|
5
7
|
|
6
8
|
PaidUp.add_feature(
|
7
|
-
slug: 'ad_free',
|
8
|
-
|
9
|
-
description: 'Are ads removed from the site with this plan?',
|
10
|
-
setting_type: 'boolean'
|
9
|
+
slug: 'ad_free', title: 'Ad Free', setting_type: 'boolean',
|
10
|
+
description: 'Are ads removed from the site with this plan?'
|
11
11
|
)
|
12
12
|
PaidUp.add_feature(
|
13
|
-
slug: 'groups',
|
14
|
-
|
15
|
-
description: 'How many groups are allowed with this plan?',
|
13
|
+
slug: 'groups', title: 'Groups', setting_type: 'rolify_rows',
|
14
|
+
description: 'How many groups are allowed with this plan?'
|
16
15
|
# Enables table row counting that is enabled by a positive value
|
17
16
|
# for the PaidUp::PlanFeatureSetting.setting associated with this
|
18
17
|
# PaidUp::Feature
|
19
|
-
setting_type: 'rolify_rows'
|
20
18
|
)
|
21
19
|
PaidUp.add_feature(
|
22
|
-
slug: 'doodads',
|
23
|
-
|
24
|
-
description: 'How many doodads included with this plan?',
|
25
|
-
setting_type: 'table_rows'
|
20
|
+
slug: 'doodads', title: 'Doodads', setting_type: 'table_rows',
|
21
|
+
description: 'How many doodads included with this plan?'
|
26
22
|
)
|
27
23
|
PaidUp.add_feature(
|
28
|
-
slug: 'posts',
|
29
|
-
|
30
|
-
description: 'How many posts included with this plan?',
|
31
|
-
setting_type: 'table_rows'
|
24
|
+
slug: 'posts', title: 'Posts', setting_type: 'table_rows',
|
25
|
+
description: 'How many posts included with this plan?'
|
32
26
|
)
|
33
27
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/config.ru
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -17,29 +16,26 @@ ActiveRecord::Schema.define(version: 20170220001913) do
|
|
17
16
|
t.string "user_id"
|
18
17
|
t.string "name"
|
19
18
|
t.text "description"
|
19
|
+
t.index ["user_id"], name: "index_doodads_on_user_id"
|
20
20
|
end
|
21
21
|
|
22
|
-
add_index "doodads", ["user_id"], name: "index_doodads_on_user_id"
|
23
|
-
|
24
22
|
create_table "groups", force: :cascade do |t|
|
25
23
|
t.string "title"
|
26
24
|
t.text "description"
|
27
25
|
t.datetime "created_at"
|
28
26
|
t.datetime "updated_at"
|
29
27
|
t.boolean "active", default: false, null: false
|
28
|
+
t.index ["active"], name: "index_groups_on_active"
|
30
29
|
end
|
31
30
|
|
32
|
-
add_index "groups", ["active"], name: "index_groups_on_active"
|
33
|
-
|
34
31
|
create_table "paid_up_plan_feature_settings", force: :cascade do |t|
|
35
32
|
t.integer "paid_up_plan_id"
|
36
33
|
t.string "feature"
|
37
34
|
t.integer "setting"
|
35
|
+
t.index ["feature"], name: "index_paid_up_plan_feature_settings_on_feature"
|
36
|
+
t.index ["paid_up_plan_id"], name: "index_paid_up_plan_feature_settings_on_paid_up_plan_id"
|
38
37
|
end
|
39
38
|
|
40
|
-
add_index "paid_up_plan_feature_settings", ["feature"], name: "index_paid_up_plan_feature_settings_on_feature"
|
41
|
-
add_index "paid_up_plan_feature_settings", ["paid_up_plan_id"], name: "index_paid_up_plan_feature_settings_on_paid_up_plan_id"
|
42
|
-
|
43
39
|
create_table "paid_up_plans", force: :cascade do |t|
|
44
40
|
t.string "stripe_id"
|
45
41
|
t.string "title"
|
@@ -47,33 +43,30 @@ ActiveRecord::Schema.define(version: 20170220001913) do
|
|
47
43
|
t.integer "sort_order"
|
48
44
|
t.datetime "created_at"
|
49
45
|
t.datetime "updated_at"
|
46
|
+
t.index ["stripe_id"], name: "index_paid_up_plans_on_stripe_id", unique: true
|
47
|
+
t.index ["title"], name: "index_paid_up_plans_on_title", unique: true
|
50
48
|
end
|
51
49
|
|
52
|
-
add_index "paid_up_plans", ["stripe_id"], name: "index_paid_up_plans_on_stripe_id", unique: true
|
53
|
-
add_index "paid_up_plans", ["title"], name: "index_paid_up_plans_on_title", unique: true
|
54
|
-
|
55
50
|
create_table "posts", force: :cascade do |t|
|
56
51
|
t.string "user_id"
|
57
52
|
t.string "title"
|
58
53
|
t.boolean "active", default: false, null: false
|
59
54
|
t.datetime "created_at"
|
60
55
|
t.datetime "updated_at"
|
56
|
+
t.index ["active"], name: "index_posts_on_active"
|
57
|
+
t.index ["user_id"], name: "index_posts_on_user_id"
|
61
58
|
end
|
62
59
|
|
63
|
-
add_index "posts", ["active"], name: "index_posts_on_active"
|
64
|
-
add_index "posts", ["user_id"], name: "index_posts_on_user_id"
|
65
|
-
|
66
60
|
create_table "roles", force: :cascade do |t|
|
67
61
|
t.string "name"
|
68
|
-
t.integer "resource_id"
|
69
62
|
t.string "resource_type"
|
63
|
+
t.integer "resource_id"
|
70
64
|
t.datetime "created_at"
|
71
65
|
t.datetime "updated_at"
|
66
|
+
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
67
|
+
t.index ["name"], name: "index_roles_on_name"
|
72
68
|
end
|
73
69
|
|
74
|
-
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
75
|
-
add_index "roles", ["name"], name: "index_roles_on_name"
|
76
|
-
|
77
70
|
create_table "users", force: :cascade do |t|
|
78
71
|
t.string "name"
|
79
72
|
t.string "email", default: "", null: false
|
@@ -88,16 +81,14 @@ ActiveRecord::Schema.define(version: 20170220001913) do
|
|
88
81
|
t.string "last_sign_in_ip"
|
89
82
|
t.string "stripe_id"
|
90
83
|
t.string "coupon_code"
|
84
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
85
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
91
86
|
end
|
92
87
|
|
93
|
-
add_index "users", ["email"], name: "index_users_on_email", unique: true
|
94
|
-
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
95
|
-
|
96
88
|
create_table "users_roles", id: false, force: :cascade do |t|
|
97
89
|
t.integer "user_id"
|
98
90
|
t.integer "role_id"
|
91
|
+
t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
99
92
|
end
|
100
93
|
|
101
|
-
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
|
102
|
-
|
103
94
|
end
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
###############
|
2
4
|
# Plans #
|
3
5
|
###############
|
@@ -178,7 +180,7 @@ FactoryGirl.create(
|
|
178
180
|
plan: no_ads_plan
|
179
181
|
)
|
180
182
|
|
181
|
-
|
183
|
+
leader_subscriber = FactoryGirl.create(
|
182
184
|
:user,
|
183
185
|
name: 'Group Leader Subscriber',
|
184
186
|
plan: group_leader_plan
|
@@ -190,7 +192,7 @@ disabling_subscriber = FactoryGirl.create(
|
|
190
192
|
plan: group_leader_plan
|
191
193
|
)
|
192
194
|
|
193
|
-
|
195
|
+
prof_subscriber = FactoryGirl.create(
|
194
196
|
:user,
|
195
197
|
name: 'Professional Subscriber',
|
196
198
|
plan: professional_plan
|
@@ -216,28 +218,28 @@ past_due_subscriber = FactoryGirl.create(
|
|
216
218
|
FactoryGirl.create(
|
217
219
|
:group,
|
218
220
|
title: 'First Group',
|
219
|
-
owner:
|
221
|
+
owner: leader_subscriber,
|
220
222
|
active: true
|
221
223
|
)
|
222
224
|
|
223
225
|
FactoryGirl.create(
|
224
226
|
:group,
|
225
227
|
title: 'Inactive Group',
|
226
|
-
owner:
|
228
|
+
owner: leader_subscriber,
|
227
229
|
active: false
|
228
230
|
)
|
229
231
|
|
230
232
|
FactoryGirl.create(
|
231
233
|
:group,
|
232
234
|
title: 'Second Group',
|
233
|
-
owner:
|
235
|
+
owner: prof_subscriber,
|
234
236
|
active: true
|
235
237
|
)
|
236
238
|
|
237
239
|
FactoryGirl.create(
|
238
240
|
:group,
|
239
241
|
title: 'Third Group',
|
240
|
-
owner:
|
242
|
+
owner: prof_subscriber,
|
241
243
|
active: true
|
242
244
|
)
|
243
245
|
|
Binary file
|
data/spec/factories/doodad.rb
CHANGED
data/spec/factories/group.rb
CHANGED
data/spec/factories/plan.rb
CHANGED
data/spec/factories/post.rb
CHANGED
data/spec/factories/user.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
FactoryGirl.define do
|
2
4
|
factory :user do
|
3
5
|
sequence :email do |n|
|
@@ -35,7 +37,7 @@ FactoryGirl.define do
|
|
35
37
|
).id
|
36
38
|
trial_end = nil
|
37
39
|
end
|
38
|
-
user.subscribe_to_plan(evaluator.plan, token, trial_end)
|
40
|
+
user.subscribe_to_plan(evaluator.plan, token, nil, trial_end)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/spec/models/group_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
|
|
@@ -6,18 +8,18 @@ describe Group do
|
|
6
8
|
|
7
9
|
describe '#owners' do
|
8
10
|
subject { first_group.owners }
|
9
|
-
it { should include
|
10
|
-
it { should_not include
|
11
|
+
it { should include leader_subscriber }
|
12
|
+
it { should_not include prof_subscriber }
|
11
13
|
end
|
12
14
|
|
13
15
|
describe '#save_with_owner' do
|
14
16
|
let(:new_group) do
|
15
17
|
group = Group.new(title: 'Saved Group')
|
16
|
-
.save_with_owner(
|
18
|
+
.save_with_owner(prof_subscriber)
|
17
19
|
group.reload
|
18
20
|
end
|
19
21
|
subject { new_group.owners }
|
20
|
-
it { should include
|
22
|
+
it { should include prof_subscriber }
|
21
23
|
end
|
22
24
|
|
23
25
|
describe '#owners_enabled_count' do
|
@@ -42,13 +44,13 @@ describe Group do
|
|
42
44
|
it { should eq 2 }
|
43
45
|
end
|
44
46
|
|
45
|
-
describe '#enabled' do
|
47
|
+
describe '#enabled?' do
|
46
48
|
describe 'when true' do
|
47
|
-
subject { first_group.enabled }
|
49
|
+
subject { first_group.enabled? }
|
48
50
|
it { should eq true }
|
49
51
|
end
|
50
52
|
describe 'when false' do
|
51
|
-
subject { disabled_group.enabled }
|
53
|
+
subject { disabled_group.enabled? }
|
52
54
|
it { should eq false }
|
53
55
|
end
|
54
56
|
end
|
data/spec/models/scope_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,24 +12,24 @@ describe 'Scopes' do
|
|
10
12
|
it { should_not include inactive_post }
|
11
13
|
end
|
12
14
|
|
13
|
-
describe 'paid_for#enabled' do
|
15
|
+
describe 'paid_for#enabled?' do
|
14
16
|
describe 'when it is within the limit' do
|
15
|
-
subject { still_enabled_post.enabled }
|
17
|
+
subject { still_enabled_post.enabled? }
|
16
18
|
it { should be true }
|
17
19
|
end
|
18
20
|
describe 'when it is NOT within the limit' do
|
19
|
-
subject { no_longer_enabled_post.enabled }
|
21
|
+
subject { no_longer_enabled_post.enabled? }
|
20
22
|
it { should be false }
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
describe
|
25
|
-
subject { free_subscriber.
|
26
|
+
describe "user#table_setting('posts')#rows_count" do
|
27
|
+
subject { free_subscriber.table_setting('posts').rows_count }
|
26
28
|
it { should eq 4 }
|
27
29
|
end
|
28
30
|
|
29
|
-
describe
|
30
|
-
subject {
|
31
|
+
describe "user#table_setting('groups')#rows_count" do
|
32
|
+
subject { leader_subscriber.rolify_setting('groups').rows_count }
|
31
33
|
it { should eq 1 }
|
32
34
|
end
|
33
35
|
end
|