3 Commits
1.3.3 ... 1.3.4

Author SHA1 Message Date
Ryan Bates
04b523eea4 releasing version 1.3.4 2010-08-31 15:46:26 -07:00
Ryan Bates
5a353c1cba don't stop at cannot definition when checking class - closes #131 2010-08-30 15:20:06 -07:00
Ryan Bates
4fe44af45d be more clear about blocks not working with accessible_by - closes #130 2010-08-30 13:40:31 -07:00
6 changed files with 17 additions and 4 deletions

View File

@@ -1,3 +1,8 @@
1.3.4 (August 31, 2010)
* Don't stop at +cannot+ with hash conditions when checking class (thanks tamoya) - see issue #131
1.3.3 (August 20, 2010) 1.3.3 (August 20, 2010)
* Switching to Rspec namespace to remove deprecation warning in Rspec 2 - see issue #119 * Switching to Rspec namespace to remove deprecation warning in Rspec 2 - see issue #119

View File

@@ -135,7 +135,7 @@ In the controller +index+ action you may want to fetch only the records which th
@articles = Article.accessible_by(current_ability) @articles = Article.accessible_by(current_ability)
See {Fetching Records}[http://wiki.github.com/ryanb/cancan/fetching-records] for more information. This will only work when abilities are defined using hash conditions, not blocks. See {Fetching Records}[http://wiki.github.com/ryanb/cancan/fetching-records] for more information.
== Additional Docs == Additional Docs

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.3.3" s.version = "1.3.4"
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

@@ -216,7 +216,7 @@ module CanCan
def relevant_can_definitions_for_query(action, subject) def relevant_can_definitions_for_query(action, subject)
relevant_can_definitions(action, subject).each do |can_definition| relevant_can_definitions(action, subject).each do |can_definition|
if can_definition.only_block? if can_definition.only_block?
raise Error, "Cannot determine SQL conditions or joins from block for #{action.inspect} #{subject.inspect}" raise Error, "The accessible_by call cannot be used with a block 'can' definition. The SQL cannot be determined for #{action.inspect} #{subject.inspect}"
end end
end end
end end

View File

@@ -30,7 +30,7 @@ module CanCan
elsif @conditions.kind_of?(Hash) && subject.class != Class elsif @conditions.kind_of?(Hash) && subject.class != Class
matches_conditions_hash?(subject) matches_conditions_hash?(subject)
else else
true @base_behavior
end end
end end

View File

@@ -246,6 +246,14 @@ describe CanCan::Ability do
@ability.can?(:read, [[4, 5, 6]]).should be_false @ability.can?(:read, [[4, 5, 6]]).should be_false
end end
it "should not stop at cannot definition when comparing class" do
@ability.can :read, Array
@ability.cannot :read, Array, :first => 1
@ability.can?(:read, [2, 3, 5]).should be_true
@ability.can?(:read, [1, 3, 5]).should be_false
@ability.can?(:read, Array).should be_true
end
it "should has eated cheezburger" do it "should has eated cheezburger" do
lambda { lambda {
@ability.can? :has, :cheezburger @ability.can? :has, :cheezburger