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
@@ -4,13 +4,15 @@ Devise.setup do |config|
4
4
  # The secret key used by Devise. Devise uses this key to generate
5
5
  # random tokens. Changing this key will render invalid all existing
6
6
  # confirmation, reset password and unlock tokens in the database.
7
- # config.secret_key = '79c56bbc3a599ca06df00c2f65aaa9edac01f37daffb886f5983a5eb03341f5d8eedb4431a557033b04c33ceb7fb3c19e2f367aa3434ac9f58f0af4e903bb0e3'
7
+ # config.secret_key = '79c56bbc3a599ca06df00c2f65aaa9edac01f37daffb886f5983a'\
8
+ # '5eb03341f5d8eedb4431a557033b04c33ceb7fb3c19e2f367aa'\
9
+ # '3434ac9f58f0af4e903bb0e3'
8
10
 
9
11
  # ==> Mailer Configuration
10
12
  # Configure the e-mail address which will be shown in Devise::Mailer,
11
13
  # note that it will be overwritten if you use your own mailer class
12
- # with default "from" parameter.
13
- config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
14
+ # with default 'from' parameter.
15
+ config.mailer_sender = 'do-not-reply@example.com'
14
16
 
15
17
  # Configure the class responsible to send e-mails.
16
18
  # config.mailer = 'Devise::Mailer'
@@ -26,39 +28,44 @@ Devise.setup do |config|
26
28
  # just :email. You can configure it to use [:username, :subdomain], so for
27
29
  # authenticating a user, both parameters are required. Remember that those
28
30
  # parameters are used only when authenticating and not when retrieving from
29
- # session. If you need permissions, you should implement that in a before filter.
31
+ # session. If you need permissions, you should implement that in a before
32
+ # filter.
30
33
  # You can also supply a hash where the value is a boolean determining whether
31
34
  # or not authentication should be aborted when the value is not present.
32
35
  # config.authentication_keys = [ :email ]
33
36
 
34
- # Configure parameters from the request object used for authentication. Each entry
35
- # given should be a request method and it will automatically be passed to the
36
- # find_for_authentication method and considered in your model lookup. For instance,
37
- # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
38
- # The same considerations mentioned for authentication_keys also apply to request_keys.
37
+ # Configure parameters from the request object used for authentication. Each
38
+ # entry given should be a request method and it will automatically be passed
39
+ # to the find_for_authentication method and considered in your model lookup.
40
+ # For instance, if you set :request_keys to [:subdomain], :subdomain will be
41
+ # used on authentication. The same considerations mentioned for
42
+ # authentication_keys also apply to request_keys.
39
43
  # config.request_keys = []
40
44
 
41
45
  # Configure which authentication keys should be case-insensitive.
42
46
  # These keys will be downcased upon creating or modifying a user and when used
43
47
  # to authenticate or find a user. Default is :email.
44
- config.case_insensitive_keys = [ :email ]
48
+ config.case_insensitive_keys = [:email]
45
49
 
46
50
  # Configure which authentication keys should have whitespace stripped.
47
51
  # These keys will have whitespace before and after removed upon creating or
48
- # modifying a user and when used to authenticate or find a user. Default is :email.
49
- config.strip_whitespace_keys = [ :email ]
52
+ # modifying a user and when used to authenticate or find a user.
53
+ # Default is :email.
54
+ config.strip_whitespace_keys = [:email]
50
55
 
51
56
  # Tell if authentication through request.params is enabled. True by default.
52
- # It can be set to an array that will enable params authentication only for the
53
- # given strategies, for example, `config.params_authenticatable = [:database]` will
54
- # enable it only for database (email + password) authentication.
57
+ # It can be set to an array that will enable params authentication only for
58
+ # the given strategies, for example,
59
+ # `config.params_authenticatable = [:database]` will enable it only for
60
+ # database (email + password) authentication.
55
61
  # config.params_authenticatable = true
56
62
 
57
63
  # Tell if authentication through HTTP Auth is enabled. False by default.
58
64
  # It can be set to an array that will enable http authentication only for the
59
- # given strategies, for example, `config.http_authenticatable = [:database]` will
60
- # enable it only for database authentication. The supported strategies are:
61
- # :database = Support basic authentication with authentication key + password
65
+ # given strategies, for example, `config.http_authenticatable = [:database]`
66
+ # will enable it only for database authentication. The supported strategies
67
+ # are:
68
+ # :database = Support basic authentication with authentication key + password
62
69
  # config.http_authenticatable = false
63
70
 
64
71
  # If 401 status code should be returned for AJAX requests. True by default.
@@ -87,17 +94,21 @@ Devise.setup do |config|
87
94
 
88
95
  # ==> Configuration for :database_authenticatable
89
96
  # For bcrypt, this is the cost for hashing the password and defaults to 10. If
90
- # using other encryptors, it sets how many times you want the password re-encrypted.
97
+ # using other encryptors, it sets how many times you want the password
98
+ # re-encrypted.
91
99
  #
92
- # Limiting the stretches to just one in testing will increase the performance of
93
- # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
94
- # a value less than 10 in other environments. Note that, for bcrypt (the default
95
- # encryptor), the cost increases exponentially with the number of stretches (e.g.
96
- # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
100
+ # Limiting the stretches to just one in testing will increase the performance
101
+ # of your test suite dramatically. However, it is STRONGLY RECOMMENDED to not
102
+ # use a value less than 10 in other environments. Note that, for bcrypt
103
+ # (the default encryptor), the cost increases exponentially with the number of
104
+ # stretches (e.g. a value of 20 is already extremely slow: approx. 60 seconds
105
+ # for 1 calculation).
97
106
  config.stretches = Rails.env.test? ? 1 : 10
98
107
 
99
108
  # Setup a pepper to generate the encrypted password.
100
- # config.pepper = 'bb8297994955970522d4c4d11d015f3ad97d00cf168464ba0542934583ce1d1a960a5111f385b1176a311bd9c44c6c5eea1804828485457eb2931d6cdbd2fcdf'
109
+ # config.pepper = 'bb8297994955970522d4c4d11d015f3ad97d00cf168464ba054293458'\
110
+ # '3ce1d1a960a5111f385b1176a311bd9c44c6c5eea1804828485457e'\
111
+ # 'b2931d6cdbd2fcdf'
101
112
 
102
113
  # ==> Configuration for :confirmable
103
114
  # A period that the user is allowed to access the website even without
@@ -116,9 +127,10 @@ Devise.setup do |config|
116
127
  # config.confirm_within = 3.days
117
128
 
118
129
  # If true, requires any email changes to be confirmed (exactly the same way as
119
- # initial account confirmation) to be applied. Requires additional unconfirmed_email
120
- # db field (see migrations). Until confirmed, new email is stored in
121
- # unconfirmed_email column, and copied to email column on successful confirmation.
130
+ # initial account confirmation) to be applied. Requires additional
131
+ # unconfirmed_email db field (see migrations). Until confirmed, new email is
132
+ # stored in unconfirmed_email column, and copied to email column on successful
133
+ # confirmation.
122
134
  config.reconfirmable = true
123
135
 
124
136
  # Defines which key will be used when confirming an account
@@ -157,7 +169,8 @@ Devise.setup do |config|
157
169
 
158
170
  # ==> Configuration for :lockable
159
171
  # Defines which strategy will be used to lock an account.
160
- # :failed_attempts = Locks an account after a number of failed attempts to sign in.
172
+ # :failed_attempts = Locks an account after a number of failed attempts to
173
+ # sign in.
161
174
  # :none = No lock strategy. You should handle locking by yourself.
162
175
  # config.lock_strategy = :failed_attempts
163
176
 
@@ -166,7 +179,8 @@ Devise.setup do |config|
166
179
 
167
180
  # Defines which strategy will be used to unlock an account.
168
181
  # :email = Sends an unlock link to the user email
169
- # :time = Re-enables login after a certain amount of time (see :unlock_in below)
182
+ # :time = Re-enables login after a certain amount of time (see :unlock_in
183
+ # below)
170
184
  # :both = Enables both strategies
171
185
  # :none = No unlock strategy. You should handle unlocking by yourself.
172
186
  # config.unlock_strategy = :both
@@ -192,19 +206,19 @@ Devise.setup do |config|
192
206
  config.reset_password_within = 6.hours
193
207
 
194
208
  # ==> Configuration for :encryptable
195
- # Allow you to use another encryption algorithm besides bcrypt (default). You can use
196
- # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
197
- # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
198
- # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
199
- # REST_AUTH_SITE_KEY to pepper).
209
+ # Allow you to use another encryption algorithm besides bcrypt (default).
210
+ # You can use :sha1, :sha512 or encryptors from others authentication tools as
211
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to
212
+ # 20 for default behavior) and :restful_authentication_sha1 (then you should
213
+ # set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
200
214
  #
201
215
  # Require the `devise-encryptable` gem when using anything other than bcrypt
202
216
  # config.encryptor = :sha512
203
217
 
204
218
  # ==> Scopes configuration
205
- # Turn scoped views on. Before rendering "sessions/new", it will first check for
206
- # "users/sessions/new". It's turned off by default because it's slower if you
207
- # are using only default views.
219
+ # Turn scoped views on. Before rendering 'sessions/new', it will first check
220
+ # for "users/sessions/new". It's turned off by default because it's slower if
221
+ # you are using only default views.
208
222
  # config.scoped_views = false
209
223
 
210
224
  # Configure the default scope given to Warden. By default it's the first
@@ -223,7 +237,7 @@ Devise.setup do |config|
223
237
  # If you have any extra navigational formats, like :iphone or :mobile, you
224
238
  # should add them to the navigational formats lists.
225
239
  #
226
- # The "*/*" below is required to match Internet Explorer requests.
240
+ # The '*/*' below is required to match Internet Explorer requests.
227
241
  # config.navigational_formats = ['*/*', :html]
228
242
 
229
243
  # The default HTTP method used to sign out a resource. Default is :delete.
@@ -236,7 +250,8 @@ Devise.setup do |config|
236
250
 
237
251
  # ==> Warden configuration
238
252
  # If you want to use other strategies, that are not supported by Devise, or
239
- # change the failure app, you can configure them inside the config.warden block.
253
+ # change the failure app, you can configure them inside the config.warden
254
+ # block.
240
255
  #
241
256
  # config.warden do |manager|
242
257
  # manager.intercept_401 = false
@@ -244,8 +259,9 @@ Devise.setup do |config|
244
259
  # end
245
260
 
246
261
  # ==> Mountable engine configurations
247
- # When using Devise inside an engine, let's call it `MyEngine`, and this engine
248
- # is mountable, there are some extra configurations to be taken into account.
262
+ # When using Devise inside an engine, let's call it `MyEngine`, and this
263
+ # engine is mountable, there are some extra configurations to be taken into
264
+ # account.
249
265
  # The following options are available, assuming the engine is mounted as:
250
266
  #
251
267
  # mount MyEngine, at: '/my_engine'
@@ -1,3 +1,3 @@
1
1
  HighVoltage.configure do |config|
2
2
  config.home_page = 'index'
3
- end
3
+ end
@@ -1,4 +1,4 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
4
+ # Mime::Type.register 'text/richtext', :rtf
@@ -4,22 +4,24 @@ PaidUp.configure do |config|
4
4
  config.free_plan_stripe_id = 'free-plan'
5
5
 
6
6
  PaidUp.add_feature(
7
- slug: 'ad_free',
8
- title: 'Ad Free',
9
- description: 'Are ads removed from the site with this plan?',
10
- setting_type: 'boolean'
7
+ slug: 'ad_free',
8
+ title: 'Ad Free',
9
+ description: 'Are ads removed from the site with this plan?',
10
+ setting_type: 'boolean'
11
11
  )
12
12
  PaidUp.add_feature(
13
- slug: 'groups',
14
- title: 'Groups',
15
- description: 'How many groups are allowed with this plan?',
16
- setting_type: 'rolify_rows' # Enables table row counting that is enabled by a positive value
17
- # for the PaidUp::PlanFeatureSetting.setting associated with this PaidUp::Feature
13
+ slug: 'groups',
14
+ title: 'Groups',
15
+ description: 'How many groups are allowed with this plan?',
16
+ # Enables table row counting that is enabled by a positive value
17
+ # for the PaidUp::PlanFeatureSetting.setting associated with this
18
+ # PaidUp::Feature
19
+ setting_type: 'rolify_rows'
18
20
  )
19
21
  PaidUp.add_feature(
20
- slug: 'doodads',
21
- title: 'Doodads',
22
- description: 'How many doodads included with this plan?',
23
- setting_type: 'table_rows'
22
+ slug: 'doodads',
23
+ title: 'Doodads',
24
+ description: 'How many doodads included with this plan?',
25
+ setting_type: 'table_rows'
24
26
  )
25
- end
27
+ end
@@ -2,6 +2,7 @@ Rolify.configure do |config|
2
2
  # By default ORM adapter is ActiveRecord. uncomment to use mongoid
3
3
  # config.use_mongoid
4
4
 
5
- # Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
5
+ # Dynamic shortcuts for User class (user.is_admin? like methods).
6
+ # Default is: false
6
7
  # config.use_dynamic_shortcuts
7
- end
8
+ end
@@ -3,7 +3,8 @@
3
3
  # This file contains settings for ActionController::ParamsWrapper which
4
4
  # is enabled by default.
5
5
 
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
6
+ # Enable parameter wrapping for JSON. You can disable this by setting
7
+ # :format to an empty array.
7
8
  ActiveSupport.on_load(:action_controller) do
8
9
  wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
10
  end
@@ -1,4 +1,4 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
- mount PaidUp::Engine => '/', :as => 'paid_up'
4
- end
3
+ mount PaidUp::Engine => '/', as: 'paid_up'
4
+ end
@@ -2,8 +2,8 @@ class AddDeviseToUsers < ActiveRecord::Migration
2
2
  def self.up
3
3
  change_table(:users) do |t|
4
4
  ## Database authenticatable
5
- t.string :email, null: false, default: ""
6
- t.string :encrypted_password, null: false, default: ""
5
+ t.string :email, null: false, default: ''
6
+ t.string :encrypted_password, null: false, default: ''
7
7
 
8
8
  ## Recoverable
9
9
  t.string :reset_password_token
@@ -2,12 +2,12 @@ class RolifyCreateRoles < ActiveRecord::Migration
2
2
  def change
3
3
  create_table(:roles) do |t|
4
4
  t.string :name
5
- t.references :resource, :polymorphic => true
5
+ t.references :resource, polymorphic: true
6
6
 
7
7
  t.timestamps
8
8
  end
9
9
 
10
- create_table(:users_roles, :id => false) do |t|
10
+ create_table(:users_roles, id: false) do |t|
11
11
  t.references :user
12
12
  t.references :role
13
13
  end
@@ -9,7 +9,7 @@ class CreatePaidUpPlansTable < ActiveRecord::Migration
9
9
 
10
10
  t.timestamps
11
11
  end
12
- add_index :paid_up_plans, :title, :unique => true
13
- add_index :paid_up_plans, :stripe_id, :unique => true
12
+ add_index :paid_up_plans, :title, unique: true
13
+ add_index :paid_up_plans, :stripe_id, unique: true
14
14
  end
15
- end
15
+ end
@@ -13,77 +13,77 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20160210165341) do
15
15
 
16
- create_table "doodads", force: :cascade do |t|
17
- t.string "user_id"
18
- t.string "name"
19
- t.text "description"
16
+ create_table 'doodads', force: :cascade do |t|
17
+ t.string 'user_id'
18
+ t.string 'name'
19
+ t.text 'description'
20
20
  end
21
21
 
22
- add_index "doodads", ["user_id"], name: "index_doodads_on_user_id"
22
+ add_index "doodads", ['user_id'], name: "index_doodads_on_user_id"
23
23
 
24
- create_table "groups", force: :cascade do |t|
25
- t.string "title"
26
- t.text "description"
27
- t.datetime "created_at"
28
- t.datetime "updated_at"
24
+ create_table 'groups', force: :cascade do |t|
25
+ t.string 'title'
26
+ t.text 'description'
27
+ t.datetime 'created_at'
28
+ t.datetime 'updated_at'
29
29
  end
30
30
 
31
- create_table "paid_up_plan_feature_settings", force: :cascade do |t|
32
- t.integer "paid_up_plan_id"
33
- t.string "feature"
34
- t.integer "setting"
31
+ create_table 'paid_up_plan_feature_settings', force: :cascade do |t|
32
+ t.integer 'paid_up_plan_id'
33
+ t.string 'feature'
34
+ t.integer 'setting'
35
35
  end
36
36
 
37
- add_index "paid_up_plan_feature_settings", ["feature"], name: "index_paid_up_plan_feature_settings_on_feature"
38
- add_index "paid_up_plan_feature_settings", ["paid_up_plan_id"], name: "index_paid_up_plan_feature_settings_on_paid_up_plan_id"
37
+ add_index "paid_up_plan_feature_settings", ['feature'], name: "index_paid_up_plan_feature_settings_on_feature"
38
+ add_index "paid_up_plan_feature_settings", ['paid_up_plan_id'], name: "index_paid_up_plan_feature_settings_on_paid_up_plan_id"
39
39
 
40
- create_table "paid_up_plans", force: :cascade do |t|
41
- t.string "stripe_id"
42
- t.string "title"
43
- t.text "description"
44
- t.integer "sort_order"
45
- t.datetime "created_at"
46
- t.datetime "updated_at"
40
+ create_table 'paid_up_plans', force: :cascade do |t|
41
+ t.string 'stripe_id'
42
+ t.string 'title'
43
+ t.text 'description'
44
+ t.integer 'sort_order'
45
+ t.datetime 'created_at'
46
+ t.datetime 'updated_at'
47
47
  end
48
48
 
49
- add_index "paid_up_plans", ["stripe_id"], name: "index_paid_up_plans_on_stripe_id", unique: true
50
- add_index "paid_up_plans", ["title"], name: "index_paid_up_plans_on_title", unique: true
49
+ add_index "paid_up_plans", ["stripe_id"], name: 'index_paid_up_plans_on_stripe_id', unique: true
50
+ add_index "paid_up_plans", ["title"], name: 'index_paid_up_plans_on_title', unique: true
51
51
 
52
- create_table "roles", force: :cascade do |t|
53
- t.string "name"
54
- t.integer "resource_id"
55
- t.string "resource_type"
56
- t.datetime "created_at"
57
- t.datetime "updated_at"
52
+ create_table 'roles', force: :cascade do |t|
53
+ t.string 'name'
54
+ t.integer 'resource_id'
55
+ t.string 'resource_type'
56
+ t.datetime 'created_at'
57
+ t.datetime 'updated_at'
58
58
  end
59
59
 
60
- add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
61
- add_index "roles", ["name"], name: "index_roles_on_name"
60
+ add_index "roles", ["name", "resource_type", 'resource_id'], name: "index_roles_on_name_and_resource_type_and_resource_id"
61
+ add_index "roles", ['name'], name: "index_roles_on_name"
62
62
 
63
- create_table "users", force: :cascade do |t|
64
- t.string "name"
65
- t.string "email", default: "", null: false
66
- t.string "encrypted_password", default: "", null: false
67
- t.string "reset_password_token"
68
- t.datetime "reset_password_sent_at"
69
- t.datetime "remember_created_at"
70
- t.integer "sign_in_count", default: 0, null: false
71
- t.datetime "current_sign_in_at"
72
- t.datetime "last_sign_in_at"
73
- t.string "current_sign_in_ip"
74
- t.string "last_sign_in_ip"
75
- t.string "stripe_id"
76
- t.string "coupon_code"
63
+ create_table 'users', force: :cascade do |t|
64
+ t.string 'name'
65
+ t.string "email", default: '', null: false
66
+ t.string "encrypted_password", default: '', null: false
67
+ t.string 'reset_password_token'
68
+ t.datetime 'reset_password_sent_at'
69
+ t.datetime 'remember_created_at'
70
+ t.integer 'sign_in_count', default: 0, null: false
71
+ t.datetime 'current_sign_in_at'
72
+ t.datetime 'last_sign_in_at'
73
+ t.string 'current_sign_in_ip'
74
+ t.string 'last_sign_in_ip'
75
+ t.string 'stripe_id'
76
+ t.string 'coupon_code'
77
77
  end
78
78
 
79
- add_index "users", ["email"], name: "index_users_on_email", unique: true
80
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
79
+ add_index "users", ["email"], name: 'index_users_on_email', unique: true
80
+ add_index "users", ["reset_password_token"], name: 'index_users_on_reset_password_token', unique: true
81
81
 
82
- create_table "users_roles", id: false, force: :cascade do |t|
83
- t.integer "user_id"
84
- t.integer "role_id"
82
+ create_table 'users_roles', id: false, force: :cascade do |t|
83
+ t.integer 'user_id'
84
+ t.integer 'role_id'
85
85
  end
86
86
 
87
- add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
87
+ add_index "users_roles", ["user_id", 'role_id'], name: "index_users_roles_on_user_id_and_role_id"
88
88
 
89
89
  end
@@ -4,27 +4,23 @@
4
4
 
5
5
  Stripe::Plan.find_or_create_by_id(
6
6
  'anonymous-plan',
7
- {
8
- amount: 0,
9
- interval: 'month',
10
- name: 'Anonymous Plan',
11
- currency: 'usd'
12
- }
13
- )
14
- anonymous_plan = PaidUp::Plan.create(
7
+ amount: 0,
8
+ interval: 'month',
9
+ name: 'Anonymous Plan',
10
+ currency: 'usd'
11
+ )
12
+ PaidUp::Plan.create(
15
13
  title: 'Anonymous',
16
14
  stripe_id: 'anonymous-plan',
17
- description: "What you can do without logging in.",
15
+ description: 'What you can do without logging in.',
18
16
  sort_order: -1
19
17
  )
20
18
  Stripe::Plan.find_or_create_by_id(
21
19
  'free-plan',
22
- {
23
- amount: 0,
24
- interval: 'month',
25
- name: 'Free Plan',
26
- currency: 'usd'
27
- }
20
+ amount: 0,
21
+ interval: 'month',
22
+ name: 'Free Plan',
23
+ currency: 'usd'
28
24
  )
29
25
  free_plan = PaidUp::Plan.create(
30
26
  title: 'Free',
@@ -34,47 +30,42 @@ free_plan = PaidUp::Plan.create(
34
30
  )
35
31
  Stripe::Plan.find_or_create_by_id(
36
32
  'no-ads-plan',
37
- {
38
- amount: 100,
39
- interval: 'month',
40
- name: 'No Ads Plan',
41
- currency: 'usd'
42
- }
33
+ amount: 100,
34
+ interval: 'month',
35
+ name: 'No Ads Plan',
36
+ currency: 'usd'
43
37
  )
44
38
  no_ads_plan = PaidUp::Plan.create(
45
39
  title: 'No Ads',
46
40
  stripe_id: 'no-ads-plan',
47
- description: "No frills, just removes the ads.",
41
+ description: 'No frills, just removes the ads.',
48
42
  sort_order: 1
49
43
  )
50
44
  Stripe::Plan.find_or_create_by_id(
51
45
  'group-leader-plan',
52
- {
53
- amount: 500,
54
- interval: 'month',
55
- name: 'Group Leader Plan',
56
- currency: 'usd'
57
- }
46
+ amount: 500,
47
+ interval: 'month',
48
+ name: 'Group Leader Plan',
49
+ currency: 'usd'
58
50
  )
59
51
  group_leader_plan = PaidUp::Plan.create(
60
52
  title: 'Group Leader',
61
53
  stripe_id: 'group-leader-plan',
62
- description: "For leaders of single groups, with configuration.",
54
+ description: 'For leaders of single groups, with configuration.',
63
55
  sort_order: 2
64
56
  )
65
57
  Stripe::Plan.find_or_create_by_id(
66
58
  'professional-plan',
67
- {
68
- amount: 1000,
69
- interval: 'month',
70
- name: 'Professional Plan',
71
- currency: 'usd'
72
- }
59
+ amount: 1000,
60
+ interval: 'month',
61
+ name: 'Professional Plan',
62
+ currency: 'usd'
73
63
  )
74
64
  professional_plan = PaidUp::Plan.create(
75
65
  title: 'Professional',
76
66
  stripe_id: 'professional-plan',
77
- description: "Designed for professionals with unlimited groups, a calendar and configuration.",
67
+ description: 'Designed for professionals with unlimited groups, a calendar '\
68
+ 'and configuration.',
78
69
  sort_order: 3
79
70
  )
80
71
 
@@ -83,21 +74,17 @@ professional_plan = PaidUp::Plan.create(
83
74
  ###############
84
75
 
85
76
  Stripe::Coupon.find_or_create_by_id(
86
- '25OFF',
87
- {
88
- percent_off: 25,
89
- currency: 'usd',
90
- duration: 'forever'
91
- }
77
+ '25OFF',
78
+ percent_off: 25,
79
+ currency: 'usd',
80
+ duration: 'forever'
92
81
  )
93
82
 
94
83
  Stripe::Coupon.find_or_create_by_id(
95
- 'MINUS25',
96
- {
97
- amount_off: 25,
98
- currency: 'usd',
99
- duration: 'forever'
100
- }
84
+ 'MINUS25',
85
+ amount_off: 25,
86
+ currency: 'usd',
87
+ duration: 'forever'
101
88
  )
102
89
 
103
90
  ######################
@@ -105,10 +92,8 @@ Stripe::Coupon.find_or_create_by_id(
105
92
  ######################
106
93
  Stripe::Customer.find_or_create_by_id(
107
94
  'anonymous-customer',
108
- {
109
- description: 'Anonymous Customer',
110
- plan: 'anonymous-plan'
111
- }
95
+ description: 'Anonymous Customer',
96
+ plan: 'anonymous-plan'
112
97
  )
113
98
  #######################
114
99
  # PlanFeatureSettings #
@@ -159,13 +144,13 @@ PaidUp::PlanFeatureSetting.create(
159
144
  # Users #
160
145
  ###############
161
146
 
162
- free_subscriber = FactoryGirl.create(
147
+ FactoryGirl.create(
163
148
  :user,
164
149
  name: 'Free Subscriber',
165
150
  plan: free_plan
166
151
  )
167
152
 
168
- no_ads_subscriber = FactoryGirl.create(
153
+ FactoryGirl.create(
169
154
  :user,
170
155
  name: 'No Ads Subscriber',
171
156
  plan: no_ads_plan
@@ -189,7 +174,7 @@ professional_subscriber = FactoryGirl.create(
189
174
  plan: professional_plan
190
175
  )
191
176
 
192
- blank_subscriber = FactoryGirl.create(
177
+ FactoryGirl.create(
193
178
  :user,
194
179
  name: 'Blank Subscriber',
195
180
  plan: professional_plan
@@ -238,4 +223,4 @@ FactoryGirl.create(
238
223
  :group,
239
224
  title: 'Past Due Group',
240
225
  owner: past_due_subscriber
241
- )
226
+ )
Binary file
@@ -7,6 +7,6 @@ namespace :system do
7
7
  Rake::Task['db:migrate'].invoke
8
8
  Rake::Task['db:seed'].invoke
9
9
  Rake::Task['db:test:prepare'].invoke
10
- puts "========== Completed in #{(Time.now-time).to_s} s =========="
10
+ puts "========== Completed in #{(Time.now - time)} s =========="
11
11
  end
12
- end
12
+ end
@@ -2,7 +2,7 @@ FactoryGirl.define do
2
2
  factory :group do
3
3
  title 'Test Title'
4
4
  transient do
5
- owner { User.order("RANDOM()").first }
5
+ owner { User.order('RANDOM()').first }
6
6
  end
7
7
  # the after(:create) yields two values; the user instance itself and the
8
8
  # evaluator, which stores all values from the factory, including transient