Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a10a38c82f | ||
|
|
caed4fcee5 | ||
|
|
e893e12260 | ||
|
|
3d7742ea43 |
@@ -1,3 +1,10 @@
|
||||
1.3.3 (August 20, 2010)
|
||||
|
||||
* Switching to Rspec namespace to remove deprecation warning in Rspec 2 - see issue #119
|
||||
|
||||
* Pluralize nested associations for conditions in accessible_by (thanks mlooney) - see issue #123
|
||||
|
||||
|
||||
1.3.2 (August 7, 2010)
|
||||
|
||||
* Fixing slice error when passing in custom resource name - see issue #112
|
||||
@@ -14,8 +21,7 @@
|
||||
|
||||
* Adding :singleton option to load_resource - see issue #93
|
||||
|
||||
* Supporting multiple resources in :through option for polymorphic
|
||||
associations - see issue #73
|
||||
* Supporting multiple resources in :through option for polymorphic associations - see issue #73
|
||||
|
||||
* Supporting Single Table Inheritance for "can" comparisons - see issue #55
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "cancan"
|
||||
s.version = "1.3.2"
|
||||
s.version = "1.3.3"
|
||||
s.author = "Ryan Bates"
|
||||
s.email = "ryan@railscasts.com"
|
||||
s.homepage = "http://github.com/ryanb/cancan"
|
||||
|
||||
@@ -34,14 +34,14 @@ module CanCan
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a hash of conditions, pluralizing the table names
|
||||
def tableized_conditions
|
||||
if @conditions
|
||||
@conditions.inject({}) do |tableized_conditions, (name, value)|
|
||||
name = name.to_s.tableize.to_sym if value.kind_of? Hash
|
||||
tableized_conditions[name] = value
|
||||
tableized_conditions
|
||||
def tableized_conditions(conditions = @conditions)
|
||||
conditions.inject({}) do |result_hash, (name, value)|
|
||||
if value.kind_of? Hash
|
||||
name = name.to_s.tableize.to_sym
|
||||
value = tableized_conditions(value)
|
||||
end
|
||||
result_hash[name] = value
|
||||
result_hash
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Spec::Matchers.define :be_able_to do |*args|
|
||||
RSpec = Spec unless defined? RSpec # for RSpec 1 compatability
|
||||
RSpec::Matchers.define :be_able_to do |*args|
|
||||
match do |ability|
|
||||
ability.can?(*args)
|
||||
end
|
||||
|
||||
@@ -31,8 +31,8 @@ describe CanCan::ActiveRecordAdditions do
|
||||
@ability.can :read, @model_class, :too => {:car => 1, :far => {:bar => 1}}
|
||||
|
||||
condition_variants = [
|
||||
'(toos.far.bar=1 AND toos.car=1) OR (foos.bar=1)', # faked sql sanitizer is stupid ;-)
|
||||
'(toos.car=1 AND toos.far.bar=1) OR (foos.bar=1)'
|
||||
'(toos.fars.bar=1 AND toos.car=1) OR (foos.bar=1)', # faked sql sanitizer is stupid ;-)
|
||||
'(toos.car=1 AND toos.fars.bar=1) OR (foos.bar=1)'
|
||||
]
|
||||
joins_variants = [
|
||||
[:foo, {:too => [:far]}],
|
||||
|
||||
@@ -31,6 +31,18 @@ describe CanCan::CanDefinition do
|
||||
@can.associations_hash.should == {:foo => {:bar => {}}}
|
||||
end
|
||||
|
||||
it "should tableize correctly for absurdly complex permissions" do
|
||||
@conditions[:unit] = {:property=>{:landlord=>{:weasle_id=>560}}}
|
||||
@conditions[:test] = 1
|
||||
@can.tableized_conditions.should == {:units => {:properties => {:landlords=>{:weasle_id=>560}}}, :test => 1}
|
||||
end
|
||||
|
||||
it "should tableize correctly for complex permissions" do
|
||||
@conditions[:unit] = {:property=>{:landlord_id=>560}}
|
||||
@conditions[:test] = 1
|
||||
@can.tableized_conditions.should == {:units => {:properties => {:landlord_id=>560}}, :test => 1}
|
||||
end
|
||||
|
||||
it "should return table names in conditions for association joins" do
|
||||
@conditions[:foo] = {:bar => 1}
|
||||
@conditions[:test] = 1
|
||||
|
||||
Reference in New Issue
Block a user