3 Commits
1.6.2 ... 1.6.3

Author SHA1 Message Date
Ryan Bates
fb8e9bde57 releasing 1.6.3 2011-03-25 14:28:26 -07:00
Ryan Bates
89e40987d8 make sure ActiveRecord::Relation is defined before checking conditions against it so Rails 2 is supported again - closes #312 2011-03-25 14:26:33 -07:00
Ryan Bates
1ac8099f7a return subject passed to authorize! - closes #314 2011-03-25 14:24:43 -07:00
5 changed files with 14 additions and 4 deletions

View File

@@ -1,3 +1,10 @@
1.6.3 (March 25, 2011)
* Make sure ActiveRecord::Relation is defined before checking conditions against it so Rails 2 is supported again - see issue #312
* Return subject passed to authorize! - see issue #314
1.6.2 (March 18, 2011) 1.6.2 (March 18, 2011)
* Fixed instance loading when :singleton option is used - see issue #310 * Fixed instance loading when :singleton option is used - see issue #310

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "cancan" s.name = "cancan"
s.version = "1.6.2" s.version = "1.6.3"
s.author = "Ryan Bates" s.author = "Ryan Bates"
s.email = "ryan@railscasts.com" s.email = "ryan@railscasts.com"
s.homepage = "http://github.com/ryanb/cancan" s.homepage = "http://github.com/ryanb/cancan"

View File

@@ -201,6 +201,7 @@ module CanCan
message ||= unauthorized_message(action, subject) message ||= unauthorized_message(action, subject)
raise AccessDenied.new(message, action, subject) raise AccessDenied.new(message, action, subject)
end end
subject
end end
def unauthorized_message(action, subject) def unauthorized_message(action, subject)

View File

@@ -99,7 +99,7 @@ module CanCan
def override_scope def override_scope
conditions = @rules.map(&:conditions).compact conditions = @rules.map(&:conditions).compact
if conditions.any? { |c| c.kind_of?(ActiveRecord::Relation) } if defined?(ActiveRecord::Relation) && conditions.any? { |c| c.kind_of?(ActiveRecord::Relation) }
if conditions.size == 1 if conditions.size == 1
conditions.first conditions.first
else else

View File

@@ -317,9 +317,11 @@ describe CanCan::Ability do
end end
end end
it "should not raise access denied exception if ability is authorized to perform an action" do it "should not raise access denied exception if ability is authorized to perform an action and return subject" do
@ability.can :read, :foo @ability.can :read, :foo
lambda { @ability.authorize!(:read, :foo) }.should_not raise_error lambda {
@ability.authorize!(:read, :foo).should == :foo
}.should_not raise_error
end end
it "should know when block is used in conditions" do it "should know when block is used in conditions" do