Skip to content
Browse files

fixing issue when using accessible_by with nil can conditions - closes

  • Loading branch information...
1 parent 605063b commit 7543eedd6aa35ef14e66b5614eb38e015f4b4091 John Allison committed with May 20, 2010
Showing with 10 additions and 1 deletion.
  1. +4 −0 CHANGELOG.rdoc
  2. +1 −1 lib/cancan/can_definition.rb
  3. +5 −0 spec/cancan/can_definition_spec.rb
View
4 CHANGELOG.rdoc
@@ -1,3 +1,7 @@
+* Fix issue when using accessible_by with nil can conditions (thanks jrallison) - see issue #66
+
+* Pluralize table name for belongs_to associations in can conditions hash (thanks logandk) - see issue #62
+
* Support has_many association or arrays in can conditions hash
* Adding joins clause to accessible_by when conditions are across associations
View
2 lib/cancan/can_definition.rb
@@ -8,7 +8,7 @@ def initialize(base_behavior, action, subject, conditions, block)
@base_behavior = base_behavior
@actions = [action].flatten
@subjects = [subject].flatten
- @conditions = conditions
+ @conditions = conditions || {}
@block = block
end
View
5 spec/cancan/can_definition_spec.rb
@@ -36,4 +36,9 @@
@conditions[:test] = 1
@can.conditions(:tableize => true).should == { :foos => { :bar => 1}, :test => 1 }
end
+
+ it "should return no association joins if conditions is nil" do
+ can = CanCan::CanDefinition.new(true, :read, Integer, nil, nil)
+ can.association_joins.should be_nil
+ end
end

0 comments on commit 7543eed

Please sign in to comment.
Something went wrong with that request. Please try again.