paid_up 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/models/paid_up/ability.rb +4 -2
- data/app/models/paid_up/plan.rb +8 -1
- data/config/locales/en.yml +1 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +282 -1387
- data/lib/paid_up/mixins/paid_for.rb +51 -1
- data/lib/paid_up/mixins/subscriber.rb +6 -1
- data/paid_up.gemspec +6 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150517175135_create_groups_table.rb +1 -1
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +241 -0
- data/spec/factories/group.rb +5 -0
- data/spec/models/group_spec.rb +54 -0
- data/spec/support/groups.rb +34 -0
- metadata +5 -2
@@ -2,8 +2,10 @@ module PaidUp::Mixins
|
|
2
2
|
module PaidFor
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
class_methods do
|
5
|
+
def feature
|
6
|
+
PaidUp::Feature.find_by_slug(table_name)
|
7
|
+
end
|
5
8
|
def paid_for
|
6
|
-
feature = PaidUp::Feature.find_by_slug(table_name)
|
7
9
|
if feature.nil?
|
8
10
|
raise :feature_not_found_feature.l feature: table_name
|
9
11
|
else
|
@@ -18,6 +20,54 @@ module PaidUp::Mixins
|
|
18
20
|
raise :value_is_not_a_valid_setting_type.l(value: feature.setting_type)
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
24
|
+
send(:define_method, :owners) do
|
25
|
+
User.with_role(:owner, self)
|
26
|
+
end
|
27
|
+
|
28
|
+
send(:define_method, :save_with_owner) do |owner|
|
29
|
+
result = save
|
30
|
+
if result
|
31
|
+
owner.add_role :owner, self
|
32
|
+
result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
send(:define_method, :owners_enabled_count) do
|
37
|
+
setting = 0
|
38
|
+
for subscriber in owners
|
39
|
+
setting += subscriber.plan.feature_setting(self.class.table_name)
|
40
|
+
end
|
41
|
+
setting
|
42
|
+
end
|
43
|
+
|
44
|
+
send(:define_method, :owners_records) do
|
45
|
+
ids = []
|
46
|
+
for subscriber in owners
|
47
|
+
case self.class.feature.setting_type
|
48
|
+
when 'table_rows'
|
49
|
+
ids += subscriber.send(self.class.table_name).pluck(:id)
|
50
|
+
when 'rolify_rows'
|
51
|
+
ids += self.class.with_role(:owner, subscriber).pluck(:id)
|
52
|
+
else
|
53
|
+
raise :no_features_associated_with_table.l(table: self.class.table_name)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
self.class.where(id: ids)
|
57
|
+
end
|
58
|
+
|
59
|
+
send(:define_method, :owners_records_count) do
|
60
|
+
owners_records.count
|
61
|
+
end
|
62
|
+
|
63
|
+
send(:define_method, :enabled?) do
|
64
|
+
if owners_enabled_count >= owners_records_count
|
65
|
+
true
|
66
|
+
else
|
67
|
+
enabled_records = owners_records.order('created_at ASC').limit(owners_enabled_count)
|
68
|
+
enabled_records.include? self
|
69
|
+
end
|
70
|
+
end
|
21
71
|
end
|
22
72
|
end
|
23
73
|
end
|
@@ -51,6 +51,7 @@ module PaidUp::Mixins
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
if result
|
54
|
+
Rails.cache.delete("#{stripe_id}/stripe_data")
|
54
55
|
reload
|
55
56
|
return true
|
56
57
|
else
|
@@ -127,7 +128,11 @@ module PaidUp::Mixins
|
|
127
128
|
end
|
128
129
|
working_stripe_id = stripe_id
|
129
130
|
end
|
130
|
-
|
131
|
+
|
132
|
+
@customer_stripe_data = Rails.cache.fetch("#{working_stripe_id}/stripe_data", expires_in: 12.hours) do
|
133
|
+
Stripe::Customer.retrieve working_stripe_id
|
134
|
+
end
|
135
|
+
|
131
136
|
if @customer_stripe_data.nil?
|
132
137
|
raise :could_not_load_subscription.l
|
133
138
|
end
|
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.7.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.7.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-
|
14
|
+
s.date = "2015-06-03"
|
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 = [
|
@@ -148,9 +148,11 @@ Gem::Specification.new do |s|
|
|
148
148
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf",
|
149
149
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2",
|
150
150
|
"spec/dummy/public/favicon.ico",
|
151
|
+
"spec/factories/group.rb",
|
151
152
|
"spec/factories/plan.rb",
|
152
153
|
"spec/factories/plan_feature_setting.rb",
|
153
154
|
"spec/factories/user.rb",
|
155
|
+
"spec/models/group_spec.rb",
|
154
156
|
"spec/models/paid_up/feature_spec.rb",
|
155
157
|
"spec/models/paid_up/plan_feature_setting_spec.rb",
|
156
158
|
"spec/models/paid_up/plan_spec.rb",
|
@@ -162,6 +164,7 @@ Gem::Specification.new do |s|
|
|
162
164
|
"spec/spec_helper.rb",
|
163
165
|
"spec/support/controller_macros.rb",
|
164
166
|
"spec/support/factory_girl.rb",
|
167
|
+
"spec/support/groups.rb",
|
165
168
|
"spec/support/plans_and_features.rb",
|
166
169
|
"spec/support/stripe.rb",
|
167
170
|
"spec/support/subscribers.rb",
|
Binary file
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -22,7 +22,7 @@ ActiveRecord::Schema.define(version: 20150523010840) do
|
|
22
22
|
add_index "doodads", ["user_id"], name: "index_doodads_on_user_id"
|
23
23
|
|
24
24
|
create_table "groups", force: :cascade do |t|
|
25
|
-
t.string "
|
25
|
+
t.string "title"
|
26
26
|
t.text "description"
|
27
27
|
t.datetime "created_at"
|
28
28
|
t.datetime "updated_at"
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -3538,3 +3538,244 @@ SQLite3::IOException: disk I/O error: INSERT INTO "schema_migrations" (version)
|
|
3538
3538
|
[1m[36m (82.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150406154440')[0m
|
3539
3539
|
[1m[35m (82.8ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20150523010837')
|
3540
3540
|
[1m[36m (107.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150523010827')[0m
|
3541
|
+
[1m[36m (85.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3542
|
+
[1m[35m (0.2ms)[0m select sqlite_version(*)
|
3543
|
+
[1m[36m (103.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3544
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3545
|
+
Migrating to CreateUsersTable (20150406154440)
|
3546
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3547
|
+
[1m[35m (0.4ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar)
|
3548
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150406154440"]]
|
3549
|
+
[1m[35m (103.5ms)[0m commit transaction
|
3550
|
+
Migrating to CreateGroupsTable (20150517175135)
|
3551
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3552
|
+
DEPRECATION WARNING: `#timestamp` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /home/work/Gems/paid_up/spec/dummy/db/migrate/20150517175135_create_groups_table.rb:7)
|
3553
|
+
[1m[35m (0.5ms)[0m CREATE TABLE "groups" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "description" text, "created_at" datetime, "updated_at" datetime)
|
3554
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150517175135"]]
|
3555
|
+
[1m[35m (95.2ms)[0m commit transaction
|
3556
|
+
Migrating to CreateDoodadsTable (20150517175136)
|
3557
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3558
|
+
[1m[35m (0.3ms)[0m CREATE TABLE "doodads" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" varchar, "name" varchar, "description" text)
|
3559
|
+
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_doodads_on_user_id" ON "doodads" ("user_id")[0m
|
3560
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150517175136"]]
|
3561
|
+
[1m[36m (110.6ms)[0m [1mcommit transaction[0m
|
3562
|
+
Migrating to AddDeviseToUsers (20150523010827)
|
3563
|
+
[1m[35m (0.1ms)[0m begin transaction
|
3564
|
+
[1m[36m (0.3ms)[0m [1mALTER TABLE "users" ADD "email" varchar DEFAULT '' NOT NULL[0m
|
3565
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "users" ADD "encrypted_password" varchar DEFAULT '' NOT NULL
|
3566
|
+
[1m[36m (0.2ms)[0m [1mALTER TABLE "users" ADD "reset_password_token" varchar[0m
|
3567
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "users" ADD "reset_password_sent_at" datetime
|
3568
|
+
[1m[36m (0.2ms)[0m [1mALTER TABLE "users" ADD "remember_created_at" datetime[0m
|
3569
|
+
[1m[35m (0.1ms)[0m ALTER TABLE "users" ADD "sign_in_count" integer DEFAULT 0 NOT NULL
|
3570
|
+
[1m[36m (0.1ms)[0m [1mALTER TABLE "users" ADD "current_sign_in_at" datetime[0m
|
3571
|
+
[1m[35m (0.1ms)[0m ALTER TABLE "users" ADD "last_sign_in_at" datetime
|
3572
|
+
[1m[36m (0.1ms)[0m [1mALTER TABLE "users" ADD "current_sign_in_ip" varchar[0m
|
3573
|
+
[1m[35m (0.1ms)[0m ALTER TABLE "users" ADD "last_sign_in_ip" varchar
|
3574
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")[0m
|
3575
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3576
|
+
FROM sqlite_master
|
3577
|
+
WHERE name='index_users_on_email' AND type='index'
|
3578
|
+
UNION ALL
|
3579
|
+
SELECT sql
|
3580
|
+
FROM sqlite_temp_master
|
3581
|
+
WHERE name='index_users_on_email' AND type='index'
|
3582
|
+
|
3583
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")[0m
|
3584
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150523010827"]]
|
3585
|
+
[1m[36m (381.7ms)[0m [1mcommit transaction[0m
|
3586
|
+
Migrating to RolifyCreateRoles (20150523010837)
|
3587
|
+
[1m[35m (0.1ms)[0m begin transaction
|
3588
|
+
DEPRECATION WARNING: `#timestamp` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /home/work/Gems/paid_up/spec/dummy/db/migrate/20150523010837_rolify_create_roles.rb:7)
|
3589
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "roles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "resource_id" integer, "resource_type" varchar, "created_at" datetime, "updated_at" datetime) [0m
|
3590
|
+
[1m[35m (0.1ms)[0m CREATE TABLE "users_roles" ("user_id" integer, "role_id" integer)
|
3591
|
+
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_roles_on_name" ON "roles" ("name")[0m
|
3592
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3593
|
+
FROM sqlite_master
|
3594
|
+
WHERE name='index_roles_on_name' AND type='index'
|
3595
|
+
UNION ALL
|
3596
|
+
SELECT sql
|
3597
|
+
FROM sqlite_temp_master
|
3598
|
+
WHERE name='index_roles_on_name' AND type='index'
|
3599
|
+
|
3600
|
+
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_roles_on_name_and_resource_type_and_resource_id" ON "roles" ("name", "resource_type", "resource_id")[0m
|
3601
|
+
[1m[35m (0.2ms)[0m CREATE INDEX "index_users_roles_on_user_id_and_role_id" ON "users_roles" ("user_id", "role_id")
|
3602
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150523010837"]]
|
3603
|
+
[1m[35m (119.8ms)[0m commit transaction
|
3604
|
+
Migrating to CreatePaidUpPlanFeatureSettingsTable (20150523010838)
|
3605
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3606
|
+
[1m[35m (0.3ms)[0m CREATE TABLE "paid_up_plan_feature_settings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plan_id" integer, "feature" varchar, "setting" integer)
|
3607
|
+
[1m[36m (0.2ms)[0m [1mCREATE INDEX "index_paid_up_plan_feature_settings_on_plan_id" ON "paid_up_plan_feature_settings" ("plan_id")[0m
|
3608
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3609
|
+
FROM sqlite_master
|
3610
|
+
WHERE name='index_paid_up_plan_feature_settings_on_plan_id' AND type='index'
|
3611
|
+
UNION ALL
|
3612
|
+
SELECT sql
|
3613
|
+
FROM sqlite_temp_master
|
3614
|
+
WHERE name='index_paid_up_plan_feature_settings_on_plan_id' AND type='index'
|
3615
|
+
|
3616
|
+
[1m[36m (0.2ms)[0m [1mCREATE INDEX "index_paid_up_plan_feature_settings_on_feature" ON "paid_up_plan_feature_settings" ("feature")[0m
|
3617
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150523010838"]]
|
3618
|
+
[1m[36m (125.0ms)[0m [1mcommit transaction[0m
|
3619
|
+
Migrating to CreatePaidUpPlansTable (20150523010839)
|
3620
|
+
[1m[35m (0.1ms)[0m begin transaction
|
3621
|
+
DEPRECATION WARNING: `#timestamp` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /home/work/Gems/paid_up/spec/dummy/db/migrate/20150523010839_create_paid_up_plans_table.paid_up.rb:10)
|
3622
|
+
[1m[36m (0.4ms)[0m [1mCREATE TABLE "paid_up_plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "title" varchar, "description" text, "sort_order" integer, "created_at" datetime, "updated_at" datetime) [0m
|
3623
|
+
[1m[35m (0.2ms)[0m CREATE UNIQUE INDEX "index_paid_up_plans_on_title" ON "paid_up_plans" ("title")
|
3624
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3625
|
+
FROM sqlite_master
|
3626
|
+
WHERE name='index_paid_up_plans_on_title' AND type='index'
|
3627
|
+
UNION ALL
|
3628
|
+
SELECT sql
|
3629
|
+
FROM sqlite_temp_master
|
3630
|
+
WHERE name='index_paid_up_plans_on_title' AND type='index'
|
3631
|
+
[0m
|
3632
|
+
[1m[35m (0.2ms)[0m CREATE UNIQUE INDEX "index_paid_up_plans_on_stripe_id" ON "paid_up_plans" ("stripe_id")
|
3633
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150523010839"]]
|
3634
|
+
[1m[35m (135.4ms)[0m commit transaction
|
3635
|
+
Migrating to AddStripeIdColumnToUsers (20150523010840)
|
3636
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
3637
|
+
[1m[35m (0.4ms)[0m ALTER TABLE "users" ADD "stripe_id" varchar
|
3638
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150523010840"]]
|
3639
|
+
[1m[35m (104.5ms)[0m commit transaction
|
3640
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3641
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3642
|
+
FROM sqlite_master
|
3643
|
+
WHERE name='index_doodads_on_user_id' AND type='index'
|
3644
|
+
UNION ALL
|
3645
|
+
SELECT sql
|
3646
|
+
FROM sqlite_temp_master
|
3647
|
+
WHERE name='index_doodads_on_user_id' AND type='index'
|
3648
|
+
|
3649
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3650
|
+
FROM sqlite_master
|
3651
|
+
WHERE name='index_paid_up_plan_feature_settings_on_feature' AND type='index'
|
3652
|
+
UNION ALL
|
3653
|
+
SELECT sql
|
3654
|
+
FROM sqlite_temp_master
|
3655
|
+
WHERE name='index_paid_up_plan_feature_settings_on_feature' AND type='index'
|
3656
|
+
[0m
|
3657
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3658
|
+
FROM sqlite_master
|
3659
|
+
WHERE name='index_paid_up_plan_feature_settings_on_plan_id' AND type='index'
|
3660
|
+
UNION ALL
|
3661
|
+
SELECT sql
|
3662
|
+
FROM sqlite_temp_master
|
3663
|
+
WHERE name='index_paid_up_plan_feature_settings_on_plan_id' AND type='index'
|
3664
|
+
|
3665
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3666
|
+
FROM sqlite_master
|
3667
|
+
WHERE name='index_paid_up_plans_on_stripe_id' AND type='index'
|
3668
|
+
UNION ALL
|
3669
|
+
SELECT sql
|
3670
|
+
FROM sqlite_temp_master
|
3671
|
+
WHERE name='index_paid_up_plans_on_stripe_id' AND type='index'
|
3672
|
+
[0m
|
3673
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3674
|
+
FROM sqlite_master
|
3675
|
+
WHERE name='index_paid_up_plans_on_title' AND type='index'
|
3676
|
+
UNION ALL
|
3677
|
+
SELECT sql
|
3678
|
+
FROM sqlite_temp_master
|
3679
|
+
WHERE name='index_paid_up_plans_on_title' AND type='index'
|
3680
|
+
|
3681
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3682
|
+
FROM sqlite_master
|
3683
|
+
WHERE name='index_roles_on_name_and_resource_type_and_resource_id' AND type='index'
|
3684
|
+
UNION ALL
|
3685
|
+
SELECT sql
|
3686
|
+
FROM sqlite_temp_master
|
3687
|
+
WHERE name='index_roles_on_name_and_resource_type_and_resource_id' AND type='index'
|
3688
|
+
[0m
|
3689
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3690
|
+
FROM sqlite_master
|
3691
|
+
WHERE name='index_roles_on_name' AND type='index'
|
3692
|
+
UNION ALL
|
3693
|
+
SELECT sql
|
3694
|
+
FROM sqlite_temp_master
|
3695
|
+
WHERE name='index_roles_on_name' AND type='index'
|
3696
|
+
|
3697
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3698
|
+
FROM sqlite_master
|
3699
|
+
WHERE name='index_users_on_reset_password_token' AND type='index'
|
3700
|
+
UNION ALL
|
3701
|
+
SELECT sql
|
3702
|
+
FROM sqlite_temp_master
|
3703
|
+
WHERE name='index_users_on_reset_password_token' AND type='index'
|
3704
|
+
[0m
|
3705
|
+
[1m[35m (0.1ms)[0m SELECT sql
|
3706
|
+
FROM sqlite_master
|
3707
|
+
WHERE name='index_users_on_email' AND type='index'
|
3708
|
+
UNION ALL
|
3709
|
+
SELECT sql
|
3710
|
+
FROM sqlite_temp_master
|
3711
|
+
WHERE name='index_users_on_email' AND type='index'
|
3712
|
+
|
3713
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
3714
|
+
FROM sqlite_master
|
3715
|
+
WHERE name='index_users_roles_on_user_id_and_role_id' AND type='index'
|
3716
|
+
UNION ALL
|
3717
|
+
SELECT sql
|
3718
|
+
FROM sqlite_temp_master
|
3719
|
+
WHERE name='index_users_roles_on_user_id_and_role_id' AND type='index'
|
3720
|
+
[0m
|
3721
|
+
[1m[36m (104.4ms)[0m [1mCREATE TABLE "doodads" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" varchar, "name" varchar, "description" text) [0m
|
3722
|
+
[1m[35m (0.2ms)[0m select sqlite_version(*)
|
3723
|
+
[1m[36m (105.7ms)[0m [1mCREATE INDEX "index_doodads_on_user_id" ON "doodads" ("user_id")[0m
|
3724
|
+
[1m[35m (114.7ms)[0m CREATE TABLE "groups" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "description" text, "created_at" datetime, "updated_at" datetime)
|
3725
|
+
[1m[36m (114.5ms)[0m [1mCREATE TABLE "paid_up_plan_feature_settings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plan_id" integer, "feature" varchar, "setting" integer) [0m
|
3726
|
+
[1m[35m (98.2ms)[0m CREATE INDEX "index_paid_up_plan_feature_settings_on_feature" ON "paid_up_plan_feature_settings" ("feature")
|
3727
|
+
[1m[36m (0.3ms)[0m [1m SELECT sql
|
3728
|
+
FROM sqlite_master
|
3729
|
+
WHERE name='index_paid_up_plan_feature_settings_on_feature' AND type='index'
|
3730
|
+
UNION ALL
|
3731
|
+
SELECT sql
|
3732
|
+
FROM sqlite_temp_master
|
3733
|
+
WHERE name='index_paid_up_plan_feature_settings_on_feature' AND type='index'
|
3734
|
+
[0m
|
3735
|
+
[1m[35m (113.8ms)[0m CREATE INDEX "index_paid_up_plan_feature_settings_on_plan_id" ON "paid_up_plan_feature_settings" ("plan_id")
|
3736
|
+
[1m[36m (107.8ms)[0m [1mCREATE TABLE "paid_up_plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "title" varchar, "description" text, "sort_order" integer, "created_at" datetime, "updated_at" datetime) [0m
|
3737
|
+
[1m[35m (90.0ms)[0m CREATE UNIQUE INDEX "index_paid_up_plans_on_stripe_id" ON "paid_up_plans" ("stripe_id")
|
3738
|
+
[1m[36m (0.2ms)[0m [1m SELECT sql
|
3739
|
+
FROM sqlite_master
|
3740
|
+
WHERE name='index_paid_up_plans_on_stripe_id' AND type='index'
|
3741
|
+
UNION ALL
|
3742
|
+
SELECT sql
|
3743
|
+
FROM sqlite_temp_master
|
3744
|
+
WHERE name='index_paid_up_plans_on_stripe_id' AND type='index'
|
3745
|
+
[0m
|
3746
|
+
[1m[35m (89.1ms)[0m CREATE UNIQUE INDEX "index_paid_up_plans_on_title" ON "paid_up_plans" ("title")
|
3747
|
+
[1m[36m (90.0ms)[0m [1mCREATE TABLE "roles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "resource_id" integer, "resource_type" varchar, "created_at" datetime, "updated_at" datetime) [0m
|
3748
|
+
[1m[35m (98.3ms)[0m CREATE INDEX "index_roles_on_name_and_resource_type_and_resource_id" ON "roles" ("name", "resource_type", "resource_id")
|
3749
|
+
[1m[36m (0.3ms)[0m [1m SELECT sql
|
3750
|
+
FROM sqlite_master
|
3751
|
+
WHERE name='index_roles_on_name_and_resource_type_and_resource_id' AND type='index'
|
3752
|
+
UNION ALL
|
3753
|
+
SELECT sql
|
3754
|
+
FROM sqlite_temp_master
|
3755
|
+
WHERE name='index_roles_on_name_and_resource_type_and_resource_id' AND type='index'
|
3756
|
+
[0m
|
3757
|
+
[1m[35m (122.0ms)[0m CREATE INDEX "index_roles_on_name" ON "roles" ("name")
|
3758
|
+
[1m[36m (126.6ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "stripe_id" varchar) [0m
|
3759
|
+
[1m[35m (122.5ms)[0m CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
|
3760
|
+
[1m[36m (0.3ms)[0m [1m SELECT sql
|
3761
|
+
FROM sqlite_master
|
3762
|
+
WHERE name='index_users_on_email' AND type='index'
|
3763
|
+
UNION ALL
|
3764
|
+
SELECT sql
|
3765
|
+
FROM sqlite_temp_master
|
3766
|
+
WHERE name='index_users_on_email' AND type='index'
|
3767
|
+
[0m
|
3768
|
+
[1m[35m (130.2ms)[0m CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
|
3769
|
+
[1m[36m (106.8ms)[0m [1mCREATE TABLE "users_roles" ("user_id" integer, "role_id" integer) [0m
|
3770
|
+
[1m[35m (106.4ms)[0m CREATE INDEX "index_users_roles_on_user_id_and_role_id" ON "users_roles" ("user_id", "role_id")
|
3771
|
+
[1m[36m (95.7ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
3772
|
+
[1m[35m (91.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
3773
|
+
[1m[36m (0.3ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
3774
|
+
[1m[35m (106.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20150523010840')
|
3775
|
+
[1m[36m (115.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150523010838')[0m
|
3776
|
+
[1m[35m (115.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20150523010839')
|
3777
|
+
[1m[36m (115.5ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150517175136')[0m
|
3778
|
+
[1m[35m (115.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20150517175135')
|
3779
|
+
[1m[36m (115.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150406154440')[0m
|
3780
|
+
[1m[35m (173.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20150523010837')
|
3781
|
+
[1m[36m (107.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20150523010827')[0m
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
require "cancan/matchers"
|
3
|
+
|
4
|
+
describe Group do
|
5
|
+
include_context 'groups'
|
6
|
+
|
7
|
+
describe '#owners' do
|
8
|
+
subject { first_group.owners }
|
9
|
+
it { should include group_leader_subscriber }
|
10
|
+
it { should_not include professional_subscriber }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#save_with_owner' do
|
14
|
+
subject {
|
15
|
+
new_group = Group.new({title: 'Saved Group'})
|
16
|
+
new_group.save_with_owner(professional_subscriber)
|
17
|
+
new_group.reload.owners
|
18
|
+
}
|
19
|
+
it { should include professional_subscriber }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#owners_enabled_count' do
|
23
|
+
describe 'when limited' do
|
24
|
+
subject { first_group.owners_enabled_count }
|
25
|
+
it { should eq 1 }
|
26
|
+
end
|
27
|
+
describe 'when unlimited' do
|
28
|
+
subject { second_group.owners_enabled_count }
|
29
|
+
it { should eq PaidUp::Unlimited.to_i }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#owners_records' do
|
34
|
+
subject { second_group.owners_records }
|
35
|
+
it { should include third_group }
|
36
|
+
it { should_not include first_group }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#owners_records_count' do
|
40
|
+
subject { second_group.owners_records_count }
|
41
|
+
it { should eq 2 }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#enabled?' do
|
45
|
+
describe 'when true' do
|
46
|
+
subject { first_group.enabled? }
|
47
|
+
it { should eq true }
|
48
|
+
end
|
49
|
+
describe 'when false' do
|
50
|
+
subject { disabled_group.enabled? }
|
51
|
+
it { should eq false }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
shared_context 'groups' do
|
2
|
+
include_context 'subscribers'
|
3
|
+
|
4
|
+
let!(:first_group) {
|
5
|
+
FactoryGirl.create(
|
6
|
+
:group,
|
7
|
+
title: 'First Group'
|
8
|
+
)
|
9
|
+
}
|
10
|
+
let!(:second_group) {
|
11
|
+
FactoryGirl.create(
|
12
|
+
:group,
|
13
|
+
title: 'Second Group'
|
14
|
+
)
|
15
|
+
}
|
16
|
+
let!(:third_group) {
|
17
|
+
FactoryGirl.create(
|
18
|
+
:group,
|
19
|
+
title: 'Third Group'
|
20
|
+
)
|
21
|
+
}
|
22
|
+
let!(:disabled_group) {
|
23
|
+
FactoryGirl.create(
|
24
|
+
:group,
|
25
|
+
title: 'Disabled Group'
|
26
|
+
)
|
27
|
+
}
|
28
|
+
before do
|
29
|
+
group_leader_subscriber.add_role(:owner, first_group)
|
30
|
+
group_leader_subscriber.add_role(:owner, disabled_group)
|
31
|
+
professional_subscriber.add_role(:owner, second_group)
|
32
|
+
professional_subscriber.add_role(:owner, third_group)
|
33
|
+
end
|
34
|
+
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.
|
4
|
+
version: 0.7.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-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -414,9 +414,11 @@ files:
|
|
414
414
|
- spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf
|
415
415
|
- spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2
|
416
416
|
- spec/dummy/public/favicon.ico
|
417
|
+
- spec/factories/group.rb
|
417
418
|
- spec/factories/plan.rb
|
418
419
|
- spec/factories/plan_feature_setting.rb
|
419
420
|
- spec/factories/user.rb
|
421
|
+
- spec/models/group_spec.rb
|
420
422
|
- spec/models/paid_up/feature_spec.rb
|
421
423
|
- spec/models/paid_up/plan_feature_setting_spec.rb
|
422
424
|
- spec/models/paid_up/plan_spec.rb
|
@@ -428,6 +430,7 @@ files:
|
|
428
430
|
- spec/spec_helper.rb
|
429
431
|
- spec/support/controller_macros.rb
|
430
432
|
- spec/support/factory_girl.rb
|
433
|
+
- spec/support/groups.rb
|
431
434
|
- spec/support/plans_and_features.rb
|
432
435
|
- spec/support/stripe.rb
|
433
436
|
- spec/support/subscribers.rb
|