paid_up 0.2.4 → 0.3.0
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.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +28 -20
- data/VERSION +1 -1
- data/app/helpers/paid_up/features_helper.rb +3 -3
- data/app/models/paid_up/ability.rb +29 -11
- data/app/models/paid_up/feature.rb +70 -8
- data/app/models/paid_up/features_plan.rb +1 -2
- data/app/models/paid_up/plan.rb +9 -13
- data/app/models/paid_up/unlimited.rb +15 -0
- data/app/views/paid_up/features/_abilities_table.html.haml +13 -4
- data/app/views/paid_up/subscriptions/new.html.haml +20 -20
- data/bin/rails +8 -1
- data/config/locales/en.yml +4 -1
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +291 -145
- data/db/migrate/20150407105900_create_paid_up_features_plans_table.rb +1 -1
- data/lib/generators/paid_up/install/install_generator.rb +6 -0
- data/lib/generators/paid_up/install/templates/initializer.rb +21 -1
- data/lib/paid_up/{integer.rb → extensions/integer.rb} +2 -4
- data/lib/paid_up/{stripe_extensions.rb → extensions/stripe.rb} +3 -6
- data/lib/paid_up/mixins/paid_for.rb +24 -0
- data/lib/paid_up/{mixins.rb → mixins/subscriber.rb} +28 -22
- data/lib/paid_up/validators/rolify_rows.rb +9 -0
- data/lib/paid_up/{table_validator.rb → validators/table_rows.rb} +2 -2
- data/lib/paid_up.rb +27 -7
- data/paid_up.gemspec +26 -16
- data/spec/dummy/app/models/ability.rb +0 -1
- data/spec/dummy/app/models/doodad.rb +3 -0
- data/spec/dummy/app/models/group.rb +1 -1
- data/spec/dummy/app/models/role.rb +10 -0
- data/spec/dummy/app/models/user.rb +2 -3
- data/spec/dummy/bin/rspec +3 -0
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/initializers/paid_up.rb +21 -1
- data/spec/dummy/config/initializers/rolify.rb +7 -0
- data/spec/dummy/config/routes.rb +10 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150517175135_create_groups_table.rb +0 -1
- data/spec/dummy/db/migrate/20150517175136_create_doodads_table.rb +9 -0
- data/spec/dummy/db/migrate/{20150518000915_add_devise_to_users.rb → 20150523010827_add_devise_to_users.rb} +0 -0
- data/spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb +19 -0
- 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
- 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
- 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
- data/spec/dummy/db/schema.rb +29 -15
- data/spec/dummy/db/seeds/features_plans.seeds.rb +9 -9
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +932 -108863
- data/spec/models/paid_up/feature_spec.rb +23 -5
- data/spec/models/paid_up/features_plan_spec.rb +2 -1
- data/spec/models/paid_up/plan_spec.rb +8 -32
- data/spec/models/user_spec.rb +110 -37
- data/spec/rails_helper.rb +1 -0
- data/spec/support/plans_and_features.rb +16 -62
- data/spec/views/paid_up/subscriptions_spec.rb +1 -1
- metadata +47 -15
- data/db/migrate/20150407110100_create_paid_up_features_table.rb +0 -11
- data/lib/paid_up/unlimited.rb +0 -17
- data/spec/dummy/db/migrate/20150518000918_create_paid_up_features_table.paid_up.rb +0 -12
- data/spec/dummy/db/seeds/features.seeds.rb +0 -19
- data/spec/dummy/test/controllers/plans_controller_controller_test.rb +0 -7
@@ -1,8 +1,8 @@
|
|
1
1
|
class CreatePaidUpFeaturesPlansTable < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :paid_up_features_plans do |t|
|
4
|
-
t.references :feature, index: true, foreign_key: true
|
5
4
|
t.references :plan, index: true, foreign_key: true
|
5
|
+
t.string :feature, index: true, foreign_key: true
|
6
6
|
t.integer :setting
|
7
7
|
end
|
8
8
|
end
|
@@ -14,6 +14,7 @@ module PaidUp
|
|
14
14
|
|
15
15
|
def install_devise
|
16
16
|
output "To start with, Devise is used to authenticate users. No need to install it separately, I'll do that now.", :magenta
|
17
|
+
gsub_file "config/routes.rb", /devise_for :users/, ''
|
17
18
|
generate("devise:install")
|
18
19
|
generate("devise User")
|
19
20
|
end
|
@@ -23,6 +24,11 @@ module PaidUp
|
|
23
24
|
template "ability.rb", "app/models/ability.rb"
|
24
25
|
end
|
25
26
|
|
27
|
+
def install_rolify
|
28
|
+
output "To provide varying roles for Users, we'll use Rolify. Let's set that up now.", :magenta
|
29
|
+
generate("rolify", "Role User")
|
30
|
+
end
|
31
|
+
|
26
32
|
def add_initializer
|
27
33
|
output "Next, you'll need an initializer. This is where you put your configuration options.", :magenta
|
28
34
|
template "initializer.rb", "config/initializers/paid_up.rb"
|
@@ -2,4 +2,24 @@ PaidUp.configure do |config|
|
|
2
2
|
config.anonymous_customer_stripe_id = 'anonymous-customer'
|
3
3
|
config.anonymous_plan_stripe_id = 'anonymous-plan'
|
4
4
|
config.free_plan_stripe_id = 'free-plan'
|
5
|
-
end
|
5
|
+
end
|
6
|
+
|
7
|
+
PaidUp::Feature.new(
|
8
|
+
slug: 'ad_free',
|
9
|
+
title: 'Ad Free',
|
10
|
+
description: 'Are ads removed from the site with this plan?',
|
11
|
+
setting_type: 'boolean'
|
12
|
+
)
|
13
|
+
PaidUp::Feature.new(
|
14
|
+
slug: 'groups',
|
15
|
+
title: 'Groups',
|
16
|
+
description: 'How many groups are allowed with this plan?',
|
17
|
+
setting_type: 'table_rows' # Enables table row counting that is enabled by a positive value
|
18
|
+
# for the PaidUp::FeaturesPlan.setting associated with this PaidUp::Feature
|
19
|
+
)
|
20
|
+
PaidUp::Feature.new(
|
21
|
+
slug: 'doodads',
|
22
|
+
title: 'Doodads',
|
23
|
+
description: 'How many doodads included with this plan?',
|
24
|
+
setting_type: 'rolify_rows'
|
25
|
+
)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module PaidUp
|
2
|
-
module
|
1
|
+
module PaidUp::Extensions
|
2
|
+
module Stripe
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
class_methods do
|
5
5
|
def find_or_create_by_id(id, item)
|
@@ -11,7 +11,4 @@ module PaidUp
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Stripe::Customer.send(:include, PaidUp::StripeExtensions)
|
17
|
-
Stripe::Plan.send(:include, PaidUp::StripeExtensions)
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module PaidUp::Mixins
|
2
|
+
module PaidFor
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
class_methods do
|
5
|
+
def paid_for
|
6
|
+
feature = PaidUp::Feature.find_by_slug(table_name)
|
7
|
+
if feature.nil?
|
8
|
+
raise :feature_not_found_feature.l feature: table_name
|
9
|
+
else
|
10
|
+
case feature.setting_type
|
11
|
+
when 'boolean'
|
12
|
+
# Nothing needs doing
|
13
|
+
when 'rolify_rows'
|
14
|
+
resourcify
|
15
|
+
when 'table_rows'
|
16
|
+
belongs_to :user
|
17
|
+
else
|
18
|
+
raise :value_is_not_a_valid_setting_type.l(value: feature.setting_type)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,9 +1,12 @@
|
|
1
|
-
module PaidUp
|
2
|
-
module
|
1
|
+
module PaidUp::Mixins
|
2
|
+
module Subscriber
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
class_methods do
|
5
5
|
def subscriber
|
6
|
-
|
6
|
+
features = PaidUp::Feature.find_all_by_setting_type('table_rows')
|
7
|
+
for feature in features
|
8
|
+
has_many feature.slug.to_sym
|
9
|
+
end
|
7
10
|
|
8
11
|
after_initialize :set_default_attributes, :load_stripe_data
|
9
12
|
before_save :remove_anonymous_association
|
@@ -67,10 +70,23 @@ module PaidUp
|
|
67
70
|
table_rows_allowed(table_name) - table_rows(table_name)
|
68
71
|
}
|
69
72
|
self.send(:define_method, :table_rows_allowed) { |table_name|
|
70
|
-
plan.
|
73
|
+
plan.feature_setting table_name
|
71
74
|
}
|
72
75
|
self.send(:define_method, :table_rows) { |table_name|
|
73
|
-
send(table_name).
|
76
|
+
send(table_name).size
|
77
|
+
}
|
78
|
+
self.send(:define_method, :rolify_rows_unlimited?) { |table_name|
|
79
|
+
rolify_rows_allowed(table_name) == PaidUp::Unlimited.to_i
|
80
|
+
}
|
81
|
+
self.send(:define_method, :rolify_rows_remaining) { |table_name|
|
82
|
+
rolify_rows_allowed(table_name) - rolify_rows(table_name)
|
83
|
+
}
|
84
|
+
self.send(:define_method, :rolify_rows_allowed) { |table_name|
|
85
|
+
plan.feature_setting table_name
|
86
|
+
}
|
87
|
+
self.send(:define_method, :rolify_rows) { |table_name|
|
88
|
+
records = table_name.classify.constantize.with_role(:owner, self)
|
89
|
+
records.size
|
74
90
|
}
|
75
91
|
self.send(:define_method, :plan_stripe_id) {
|
76
92
|
if subscription.nil?
|
@@ -96,6 +112,12 @@ module PaidUp
|
|
96
112
|
self.send(:define_method, :using_free_plan?) {
|
97
113
|
plan.stripe_id == PaidUp.configuration.free_plan_stripe_id || stripe_data.delinquent
|
98
114
|
}
|
115
|
+
self.send(:define_method, :set_default_attributes) {
|
116
|
+
if new_record?
|
117
|
+
self.stripe_id = PaidUp.configuration.anonymous_customer_stripe_id
|
118
|
+
end
|
119
|
+
}
|
120
|
+
self.send(:private, :set_default_attributes)
|
99
121
|
self.send(:define_method, :load_stripe_data) {
|
100
122
|
if new_record?
|
101
123
|
working_stripe_id = PaidUp.configuration.anonymous_customer_stripe_id
|
@@ -111,29 +133,13 @@ module PaidUp
|
|
111
133
|
end
|
112
134
|
}
|
113
135
|
self.send(:private, :load_stripe_data)
|
114
|
-
self.send(:define_method, :set_default_attributes) {
|
115
|
-
if new_record?
|
116
|
-
self.stripe_id = PaidUp.configuration.anonymous_customer_stripe_id
|
117
|
-
end
|
118
|
-
}
|
119
|
-
self.send(:private, :set_default_attributes)
|
120
136
|
self.send(:define_method, :remove_anonymous_association) {
|
121
137
|
if stripe_id == PaidUp.configuration.anonymous_customer_stripe_id
|
122
138
|
self.stripe_id = nil
|
123
139
|
end
|
124
140
|
}
|
125
141
|
self.send(:private, :remove_anonymous_association)
|
126
|
-
|
127
|
-
PaidUp::Plan.subscribed_to(self)
|
128
|
-
end
|
129
|
-
|
130
|
-
def subscribed_to(model)
|
131
|
-
has_many :subscribers, :through => :subscriptions, :source => :subscriber, :source_type => model.model_name
|
132
142
|
end
|
133
143
|
end
|
134
144
|
end
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
ActiveRecord::Base.send(:include, PaidUp::Mixins)
|
145
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module PaidUp::Validators
|
2
|
+
class RolifyRows < ActiveModel::Validator
|
3
|
+
def validate(record)
|
4
|
+
if record.send(options[:field]) == options[:comparison] && !ActiveRecord::Base.connection.table_exists?(record.send(options[:found_in]))
|
5
|
+
record.errors[options[:found_in]] << :when_using_rolify_rows_table_must_exist.l
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module PaidUp
|
2
|
-
class
|
1
|
+
module PaidUp::Validators
|
2
|
+
class TableRows < ActiveModel::Validator
|
3
3
|
def validate(record)
|
4
4
|
if record.send(options[:field]) == options[:comparison] && !ActiveRecord::Base.connection.table_exists?(record.send(options[:found_in]))
|
5
5
|
record.errors[options[:found_in]] << :when_using_table_rows_table_must_exist.l
|
data/lib/paid_up.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module PaidUp
|
2
|
-
require 'rails/all'
|
2
|
+
# require 'rails/all'
|
3
|
+
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "action_view/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
|
3
10
|
require 'rails-i18n'
|
11
|
+
|
4
12
|
require 'stripe' # Needs to be required before paid_up/stripe_extensions
|
5
13
|
require 'devise' # Needs to be required before paid_up/mixins
|
6
14
|
|
@@ -9,11 +17,15 @@ module PaidUp
|
|
9
17
|
require 'paid_up/engine'
|
10
18
|
require 'paid_up/localization'
|
11
19
|
require 'paid_up/version'
|
12
|
-
|
13
|
-
require 'paid_up/
|
14
|
-
require 'paid_up/
|
15
|
-
|
16
|
-
require 'paid_up/
|
20
|
+
|
21
|
+
require 'paid_up/extensions/stripe'
|
22
|
+
require 'paid_up/extensions/integer'
|
23
|
+
|
24
|
+
require 'paid_up/mixins/subscriber'
|
25
|
+
require 'paid_up/mixins/paid_for'
|
26
|
+
|
27
|
+
require 'paid_up/validators/table_rows'
|
28
|
+
require 'paid_up/validators/rolify_rows'
|
17
29
|
|
18
30
|
require 'haml-rails'
|
19
31
|
require 'bootstrap_leather'
|
@@ -23,4 +35,12 @@ module PaidUp
|
|
23
35
|
|
24
36
|
require 'seedbank'
|
25
37
|
require 'chronic'
|
26
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Integer.send(:include, PaidUp::Extensions::Integer)
|
41
|
+
|
42
|
+
Stripe::Customer.send(:include, PaidUp::Extensions::Stripe)
|
43
|
+
Stripe::Plan.send(:include, PaidUp::Extensions::Stripe)
|
44
|
+
|
45
|
+
ActiveRecord::Base.send(:include, PaidUp::Mixins::Subscriber)
|
46
|
+
ActiveRecord::Base.send(:include, PaidUp::Mixins::PaidFor)
|
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.
|
5
|
+
# stub: paid_up 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "paid_up"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
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-05-
|
14
|
+
s.date = "2015-05-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.executables = ["rails"]
|
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
"app/models/paid_up/feature.rb",
|
40
40
|
"app/models/paid_up/features_plan.rb",
|
41
41
|
"app/models/paid_up/plan.rb",
|
42
|
+
"app/models/paid_up/unlimited.rb",
|
42
43
|
"app/views/devise/confirmations/new.html.haml",
|
43
44
|
"app/views/devise/passwords/edit.html.haml",
|
44
45
|
"app/views/devise/passwords/new.html.haml",
|
@@ -62,7 +63,6 @@ Gem::Specification.new do |s|
|
|
62
63
|
"coverage/.resultset.json",
|
63
64
|
"coverage/.resultset.json.lock",
|
64
65
|
"db/migrate/20150407105900_create_paid_up_features_plans_table.rb",
|
65
|
-
"db/migrate/20150407110100_create_paid_up_features_table.rb",
|
66
66
|
"db/migrate/20150407110101_create_paid_up_plans_table.rb",
|
67
67
|
"db/migrate/20150519164237_add_stripe_id_column_to_users.rb",
|
68
68
|
"lib/generators/paid_up/install/install_generator.rb",
|
@@ -72,13 +72,14 @@ Gem::Specification.new do |s|
|
|
72
72
|
"lib/paid_up.rb",
|
73
73
|
"lib/paid_up/configuration.rb",
|
74
74
|
"lib/paid_up/engine.rb",
|
75
|
-
"lib/paid_up/integer.rb",
|
75
|
+
"lib/paid_up/extensions/integer.rb",
|
76
|
+
"lib/paid_up/extensions/stripe.rb",
|
76
77
|
"lib/paid_up/localization.rb",
|
77
|
-
"lib/paid_up/mixins.rb",
|
78
|
+
"lib/paid_up/mixins/paid_for.rb",
|
79
|
+
"lib/paid_up/mixins/subscriber.rb",
|
78
80
|
"lib/paid_up/railtie.rb",
|
79
|
-
"lib/paid_up/
|
80
|
-
"lib/paid_up/
|
81
|
-
"lib/paid_up/unlimited.rb",
|
81
|
+
"lib/paid_up/validators/rolify_rows.rb",
|
82
|
+
"lib/paid_up/validators/table_rows.rb",
|
82
83
|
"lib/paid_up/version.rb",
|
83
84
|
"paid_up.gemspec",
|
84
85
|
"spec/controllers/paid_up/plans_spec.rb",
|
@@ -88,13 +89,16 @@ Gem::Specification.new do |s|
|
|
88
89
|
"spec/dummy/app/assets/stylesheets/application.css.scss",
|
89
90
|
"spec/dummy/app/controllers/application_controller.rb",
|
90
91
|
"spec/dummy/app/models/ability.rb",
|
92
|
+
"spec/dummy/app/models/doodad.rb",
|
91
93
|
"spec/dummy/app/models/group.rb",
|
94
|
+
"spec/dummy/app/models/role.rb",
|
92
95
|
"spec/dummy/app/models/user.rb",
|
93
96
|
"spec/dummy/app/views/layouts/application.html.haml",
|
94
97
|
"spec/dummy/app/views/pages/index.html.haml",
|
95
98
|
"spec/dummy/bin/bundle",
|
96
99
|
"spec/dummy/bin/rails",
|
97
100
|
"spec/dummy/bin/rake",
|
101
|
+
"spec/dummy/bin/rspec",
|
98
102
|
"spec/dummy/bin/setup",
|
99
103
|
"spec/dummy/config.ru",
|
100
104
|
"spec/dummy/config/application.rb",
|
@@ -113,6 +117,7 @@ Gem::Specification.new do |s|
|
|
113
117
|
"spec/dummy/config/initializers/inflections.rb",
|
114
118
|
"spec/dummy/config/initializers/mime_types.rb",
|
115
119
|
"spec/dummy/config/initializers/paid_up.rb",
|
120
|
+
"spec/dummy/config/initializers/rolify.rb",
|
116
121
|
"spec/dummy/config/initializers/session_store.rb",
|
117
122
|
"spec/dummy/config/initializers/wrap_parameters.rb",
|
118
123
|
"spec/dummy/config/locales/devise.en.yml",
|
@@ -122,14 +127,14 @@ Gem::Specification.new do |s|
|
|
122
127
|
"spec/dummy/db/development.sqlite3",
|
123
128
|
"spec/dummy/db/migrate/20150406154440_create_users_table.rb",
|
124
129
|
"spec/dummy/db/migrate/20150517175135_create_groups_table.rb",
|
125
|
-
"spec/dummy/db/migrate/
|
126
|
-
"spec/dummy/db/migrate/
|
127
|
-
"spec/dummy/db/migrate/
|
128
|
-
"spec/dummy/db/migrate/
|
129
|
-
"spec/dummy/db/migrate/
|
130
|
+
"spec/dummy/db/migrate/20150517175136_create_doodads_table.rb",
|
131
|
+
"spec/dummy/db/migrate/20150523010827_add_devise_to_users.rb",
|
132
|
+
"spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb",
|
133
|
+
"spec/dummy/db/migrate/20150523010838_create_paid_up_features_plans_table.paid_up.rb",
|
134
|
+
"spec/dummy/db/migrate/20150523010839_create_paid_up_plans_table.paid_up.rb",
|
135
|
+
"spec/dummy/db/migrate/20150523010840_add_stripe_id_column_to_users.paid_up.rb",
|
130
136
|
"spec/dummy/db/schema.rb",
|
131
137
|
"spec/dummy/db/seeds.rb",
|
132
|
-
"spec/dummy/db/seeds/features.seeds.rb",
|
133
138
|
"spec/dummy/db/seeds/features_plans.seeds.rb",
|
134
139
|
"spec/dummy/db/seeds/plans.seeds.rb",
|
135
140
|
"spec/dummy/db/test.sqlite3",
|
@@ -148,7 +153,6 @@ Gem::Specification.new do |s|
|
|
148
153
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf",
|
149
154
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2",
|
150
155
|
"spec/dummy/public/favicon.ico",
|
151
|
-
"spec/dummy/test/controllers/plans_controller_controller_test.rb",
|
152
156
|
"spec/factories/feature.rb",
|
153
157
|
"spec/factories/features_plan.rb",
|
154
158
|
"spec/factories/plan.rb",
|
@@ -191,11 +195,13 @@ Gem::Specification.new do |s|
|
|
191
195
|
s.add_runtime_dependency(%q<money>, ["~> 6.5"])
|
192
196
|
s.add_runtime_dependency(%q<devise>, ["~> 3.4"])
|
193
197
|
s.add_runtime_dependency(%q<cancan>, ["~> 1.6"])
|
198
|
+
s.add_runtime_dependency(%q<rolify>, ["~> 4"])
|
194
199
|
s.add_runtime_dependency(%q<stripe>, ["~> 1.21"])
|
195
200
|
s.add_development_dependency(%q<sqlite3>, ["~> 1.3"])
|
196
201
|
s.add_development_dependency(%q<forgery>, ["~> 0.6"])
|
197
202
|
s.add_development_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
198
203
|
s.add_development_dependency(%q<sass-rails>, ["~> 5.0"])
|
204
|
+
s.add_development_dependency(%q<high_voltage>, ["~> 2.3"])
|
199
205
|
else
|
200
206
|
s.add_dependency(%q<rails>, ["~> 4"])
|
201
207
|
s.add_dependency(%q<rails-i18n>, ["~> 4"])
|
@@ -209,11 +215,13 @@ Gem::Specification.new do |s|
|
|
209
215
|
s.add_dependency(%q<money>, ["~> 6.5"])
|
210
216
|
s.add_dependency(%q<devise>, ["~> 3.4"])
|
211
217
|
s.add_dependency(%q<cancan>, ["~> 1.6"])
|
218
|
+
s.add_dependency(%q<rolify>, ["~> 4"])
|
212
219
|
s.add_dependency(%q<stripe>, ["~> 1.21"])
|
213
220
|
s.add_dependency(%q<sqlite3>, ["~> 1.3"])
|
214
221
|
s.add_dependency(%q<forgery>, ["~> 0.6"])
|
215
222
|
s.add_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
216
223
|
s.add_dependency(%q<sass-rails>, ["~> 5.0"])
|
224
|
+
s.add_dependency(%q<high_voltage>, ["~> 2.3"])
|
217
225
|
end
|
218
226
|
else
|
219
227
|
s.add_dependency(%q<rails>, ["~> 4"])
|
@@ -228,11 +236,13 @@ Gem::Specification.new do |s|
|
|
228
236
|
s.add_dependency(%q<money>, ["~> 6.5"])
|
229
237
|
s.add_dependency(%q<devise>, ["~> 3.4"])
|
230
238
|
s.add_dependency(%q<cancan>, ["~> 1.6"])
|
239
|
+
s.add_dependency(%q<rolify>, ["~> 4"])
|
231
240
|
s.add_dependency(%q<stripe>, ["~> 1.21"])
|
232
241
|
s.add_dependency(%q<sqlite3>, ["~> 1.3"])
|
233
242
|
s.add_dependency(%q<forgery>, ["~> 0.6"])
|
234
243
|
s.add_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
235
244
|
s.add_dependency(%q<sass-rails>, ["~> 5.0"])
|
245
|
+
s.add_dependency(%q<high_voltage>, ["~> 2.3"])
|
236
246
|
end
|
237
247
|
end
|
238
248
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
|
-
|
2
|
+
rolify
|
3
3
|
# Include default devise modules. Others available are:
|
4
4
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
5
5
|
devise :database_authenticatable, :registerable,
|
6
6
|
:recoverable, :rememberable, :trackable, :validatable
|
7
|
-
|
8
|
-
has_many :groups
|
7
|
+
subscriber
|
9
8
|
end
|
@@ -2,4 +2,24 @@ PaidUp.configure do |config|
|
|
2
2
|
config.anonymous_customer_stripe_id = 'anonymous-customer'
|
3
3
|
config.anonymous_plan_stripe_id = 'anonymous-plan'
|
4
4
|
config.free_plan_stripe_id = 'free-plan'
|
5
|
-
end
|
5
|
+
end
|
6
|
+
|
7
|
+
PaidUp::Feature.new(
|
8
|
+
slug: 'ad_free',
|
9
|
+
title: 'Ad Free',
|
10
|
+
description: 'Are ads removed from the site with this plan?',
|
11
|
+
setting_type: 'boolean'
|
12
|
+
)
|
13
|
+
PaidUp::Feature.new(
|
14
|
+
slug: 'groups',
|
15
|
+
title: 'Groups',
|
16
|
+
description: 'How many groups are allowed with this plan?',
|
17
|
+
setting_type: 'rolify_rows' # Enables table row counting that is enabled by a positive value
|
18
|
+
# for the PaidUp::FeaturesPlan.setting associated with this PaidUp::Feature
|
19
|
+
)
|
20
|
+
PaidUp::Feature.new(
|
21
|
+
slug: 'doodads',
|
22
|
+
title: 'Doodads',
|
23
|
+
description: 'How many doodads included with this plan?',
|
24
|
+
setting_type: 'table_rows'
|
25
|
+
)
|
data/spec/dummy/config/routes.rb
CHANGED
Binary file
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class RolifyCreateRoles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:roles) do |t|
|
4
|
+
t.string :name
|
5
|
+
t.references :resource, :polymorphic => true
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table(:users_roles, :id => false) do |t|
|
11
|
+
t.references :user
|
12
|
+
t.references :role
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index(:roles, :name)
|
16
|
+
add_index(:roles, [ :name, :resource_type, :resource_id ])
|
17
|
+
add_index(:users_roles, [ :user_id, :role_id ])
|
18
|
+
end
|
19
|
+
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
class CreatePaidUpFeaturesPlansTable < ActiveRecord::Migration
|
3
3
|
def change
|
4
4
|
create_table :paid_up_features_plans do |t|
|
5
|
-
t.references :feature, index: true, foreign_key: true
|
6
5
|
t.references :plan, index: true, foreign_key: true
|
6
|
+
t.string :feature, index: true, foreign_key: true
|
7
7
|
t.integer :setting
|
8
8
|
end
|
9
9
|
end
|
File without changes
|