paid_up 0.11.3 → 0.11.4
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/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +299 -944
- data/lib/paid_up/mixins/subscriber.rb +1 -1
- data/paid_up.gemspec +3 -2
- data/spec/dummy/db/seeds.rb +3 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/doodad.rb +6 -0
- data/spec/models/user_spec.rb +77 -22
- metadata +2 -1
@@ -89,7 +89,7 @@ module PaidUp
|
|
89
89
|
end
|
90
90
|
send(:define_method, :table_rows) do |table_name|
|
91
91
|
model = table_name.classify.constantize
|
92
|
-
model.paid_for_scope.size
|
92
|
+
model.where(user: self).paid_for_scope.size
|
93
93
|
end
|
94
94
|
send(:define_method, :rolify_rows_unlimited?) do |table_name|
|
95
95
|
rolify_rows_allowed(table_name) == PaidUp::Unlimited.to_i
|
data/paid_up.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.11.
|
5
|
+
# stub: paid_up 0.11.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "paid_up"
|
9
|
-
s.version = "0.11.
|
9
|
+
s.version = "0.11.4"
|
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"]
|
@@ -162,6 +162,7 @@ Gem::Specification.new do |s|
|
|
162
162
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf",
|
163
163
|
"spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2",
|
164
164
|
"spec/dummy/public/favicon.ico",
|
165
|
+
"spec/factories/doodad.rb",
|
165
166
|
"spec/factories/group.rb",
|
166
167
|
"spec/factories/plan.rb",
|
167
168
|
"spec/factories/plan_feature_setting.rb",
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -241,9 +241,9 @@ FactoryGirl.create(
|
|
241
241
|
active: true
|
242
242
|
)
|
243
243
|
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
FactoryGirl.create_list(:group, 5, owner: disabling_subscriber, active: true)
|
245
|
+
FactoryGirl.create_list(:doodad, 10, user: disabling_subscriber)
|
246
|
+
FactoryGirl.create_list(:post, 10, user: disabling_subscriber, active: true)
|
247
247
|
|
248
248
|
FactoryGirl.create(
|
249
249
|
:group,
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/models/user_spec.rb
CHANGED
@@ -340,33 +340,88 @@ describe User do
|
|
340
340
|
it { should_not be_able_to(:create, Doodad) }
|
341
341
|
end
|
342
342
|
context 'when on group plan' do
|
343
|
-
|
344
|
-
let(:group) do
|
345
|
-
FactoryGirl.create(:group, owner: group_leader_subscriber)
|
346
|
-
end
|
343
|
+
describe 'misc abilities' do
|
347
344
|
let(:user) { group_leader_subscriber }
|
348
345
|
subject(:ability) { Ability.new(user) }
|
349
|
-
it { should be_able_to(:index, group) }
|
350
|
-
it { should be_able_to(:show, group) }
|
351
|
-
it { should be_able_to(:manage, group) }
|
352
|
-
it { should be_able_to(:own, Group) }
|
353
|
-
it { should be_able_to(:create, Group) }
|
354
346
|
it { should be_able_to(:use, :ad_free) }
|
355
|
-
it { should be_able_to(:create, Doodad) }
|
356
347
|
end
|
357
|
-
|
358
|
-
|
359
|
-
|
348
|
+
describe 'using groups' do
|
349
|
+
context 'given no groups are owned' do
|
350
|
+
let(:group) do
|
351
|
+
FactoryGirl.create(:group, owner: group_leader_subscriber)
|
352
|
+
end
|
353
|
+
let(:user) { group_leader_subscriber }
|
354
|
+
subject(:ability) { Ability.new(user) }
|
355
|
+
it { should be_able_to(:index, group) }
|
356
|
+
it { should be_able_to(:show, group) }
|
357
|
+
it { should be_able_to(:manage, group) }
|
358
|
+
it { should be_able_to(:own, Group) }
|
359
|
+
it { should be_able_to(:create, Group) }
|
360
|
+
end
|
361
|
+
context 'given all allowed groups are owned' do
|
362
|
+
let(:group) do
|
363
|
+
FactoryGirl.create(:group, owner: disabling_subscriber)
|
364
|
+
end
|
365
|
+
let(:user) { disabling_subscriber }
|
366
|
+
subject(:ability) { Ability.new(user) }
|
367
|
+
it { should be_able_to(:index, group) }
|
368
|
+
it { should be_able_to(:show, group) }
|
369
|
+
it { should be_able_to(:manage, group) }
|
370
|
+
it { should be_able_to(:own, Group) }
|
371
|
+
it { should_not be_able_to(:create, Group) }
|
372
|
+
end
|
373
|
+
end
|
374
|
+
describe 'using doodads' do
|
375
|
+
context 'given no doodads are owned' do
|
376
|
+
let(:doodad) do
|
377
|
+
FactoryGirl.create(:doodad, user: group_leader_subscriber)
|
378
|
+
end
|
379
|
+
let(:user) { group_leader_subscriber }
|
380
|
+
subject(:ability) { Ability.new(user) }
|
381
|
+
it { should be_able_to(:index, doodad) }
|
382
|
+
it { should be_able_to(:show, doodad) }
|
383
|
+
it { should be_able_to(:manage, doodad) }
|
384
|
+
it { should be_able_to(:own, Doodad) }
|
385
|
+
it { should be_able_to(:create, Doodad) }
|
386
|
+
end
|
387
|
+
context 'given all allowed doodads are owned' do
|
388
|
+
let(:doodad) do
|
389
|
+
FactoryGirl.create(:doodad, user: disabling_subscriber)
|
390
|
+
end
|
391
|
+
let(:user) { disabling_subscriber }
|
392
|
+
subject(:ability) { Ability.new(user) }
|
393
|
+
it { should be_able_to(:index, doodad) }
|
394
|
+
it { should be_able_to(:show, doodad) }
|
395
|
+
it { should be_able_to(:manage, doodad) }
|
396
|
+
it { should be_able_to(:own, Doodad) }
|
397
|
+
it { should_not be_able_to(:create, Doodad) }
|
398
|
+
end
|
399
|
+
end
|
400
|
+
describe 'using posts' do
|
401
|
+
context 'given no posts are owned' do
|
402
|
+
let(:post) do
|
403
|
+
FactoryGirl.create(:post, user: group_leader_subscriber)
|
404
|
+
end
|
405
|
+
let(:user) { group_leader_subscriber }
|
406
|
+
subject(:ability) { Ability.new(user) }
|
407
|
+
it { should be_able_to(:index, post) }
|
408
|
+
it { should be_able_to(:show, post) }
|
409
|
+
it { should be_able_to(:manage, post) }
|
410
|
+
it { should be_able_to(:own, Post) }
|
411
|
+
it { should be_able_to(:create, Post) }
|
412
|
+
end
|
413
|
+
context 'given all allowed posts are owned' do
|
414
|
+
let(:post) do
|
415
|
+
FactoryGirl.create(:post, user: disabling_subscriber)
|
416
|
+
end
|
417
|
+
let(:user) { disabling_subscriber }
|
418
|
+
subject(:ability) { Ability.new(user) }
|
419
|
+
it { should be_able_to(:index, post) }
|
420
|
+
it { should be_able_to(:show, post) }
|
421
|
+
it { should be_able_to(:manage, post) }
|
422
|
+
it { should be_able_to(:own, Post) }
|
423
|
+
it { should_not be_able_to(:create, Post) }
|
360
424
|
end
|
361
|
-
let(:user) { disabling_subscriber }
|
362
|
-
subject(:ability) { Ability.new(user) }
|
363
|
-
it { should be_able_to(:index, group) }
|
364
|
-
it { should be_able_to(:show, group) }
|
365
|
-
it { should be_able_to(:manage, group) }
|
366
|
-
it { should be_able_to(:own, Group) }
|
367
|
-
it { should_not be_able_to(:create, Group) }
|
368
|
-
it { should be_able_to(:use, :ad_free) }
|
369
|
-
it { should be_able_to(:create, Doodad) }
|
370
425
|
end
|
371
426
|
end
|
372
427
|
context 'when on professional plan' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paid_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karen Lundgren
|
@@ -526,6 +526,7 @@ files:
|
|
526
526
|
- spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf
|
527
527
|
- spec/dummy/public/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2
|
528
528
|
- spec/dummy/public/favicon.ico
|
529
|
+
- spec/factories/doodad.rb
|
529
530
|
- spec/factories/group.rb
|
530
531
|
- spec/factories/plan.rb
|
531
532
|
- spec/factories/plan_feature_setting.rb
|