permissive 0.2.8.alpha → 0.2.9.alpha

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8.alpha
1
+ 0.2.9.alpha
@@ -9,7 +9,12 @@ module Permissive
9
9
  named_scope :on, lambda {|scoped_object|
10
10
  case scoped_object
11
11
  when ActiveRecord::Base
12
- {:conditions => {:scoped_object_id => scoped_object.id, :scoped_object_type => scoped_object.class.to_s}}
12
+ {
13
+ :conditions => [
14
+ "#{table_name}.scoped_object_type = :object_type AND (#{table_name}.scoped_object_id = :object_id OR #{table_name}.scoped_object_id IS NULL)",
15
+ {:object_id => scoped_object.id, :object_type => scoped_object.class.name}
16
+ ]
17
+ }
13
18
  when Class
14
19
  {:conditions => {:scoped_object_id => nil, :scoped_object_type => scoped_object.name}}
15
20
  when String, Symbol
@@ -72,10 +72,15 @@ describe Permissive, "scoped permissions" do
72
72
  end
73
73
 
74
74
  describe "on classes" do
75
- it "should ignore instance-specific permissions" do
75
+ it "should trump instance-specific permissions" do
76
76
  @user.can!(:punch, :on => Permissive::User)
77
77
  @user.can?(:punch, :on => Permissive::User).should be_true
78
- @user.can?(:punch, :on => Permissive::User.create).should be_false
78
+ @user.can?(:punch, :on => Permissive::User.create).should be_true
79
+ end
80
+
81
+ it "should not be trumped by instances" do
82
+ @user.can!(:punch, :on => Permissive::User.create)
83
+ @user.can?(:punch, :on => Permissive::User).should be_false
79
84
  end
80
85
 
81
86
  it "should interpolate symbols" do
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 8
8
+ - 9
9
9
  - alpha
10
- version: 0.2.8.alpha
10
+ version: 0.2.9.alpha
11
11
  platform: ruby
12
12
  authors:
13
13
  - Flip Sasser
@@ -32,7 +32,6 @@ extensions: []
32
32
  extra_rdoc_files:
33
33
  - README.markdown
34
34
  files:
35
- - .gemspec
36
35
  - .gitignore
37
36
  - CHANGELOG
38
37
  - MIT-LICENSE