Fix pending spec for DataMapper adapter.

This commit is contained in:
Emmanuel Gomez 2011-04-29 00:46:38 -07:00
parent 6d39b0ae07
commit d6851debd4
2 changed files with 8 additions and 12 deletions

View File

@ -16,18 +16,15 @@ module CanCan
def database_records
scope = @model_class.all(:conditions => ["0 = 1"])
conditions.each do |condition|
scope += @model_class.all(:conditions => condition)
end
cans, cannots = @rules.partition { |r| r.base_behavior }
# apply unions first, then differences. this mean cannot overrides can
cans.each { |r| scope += @model_class.all(:conditions => r.conditions) }
cannots.each { |r| scope -= @model_class.all(:conditions => r.conditions) }
scope
end
def conditions
@rules.map(&:conditions)
end
end
end
end
end # class DataMapper
end # module ModelAdapters
end # module CanCan
DataMapper::Model.class_eval do
include CanCan::ModelAdditions::ClassMethods

View File

@ -65,7 +65,6 @@ if ENV["MODEL_ADAPTER"] == "data_mapper"
end
it "should fetch only the articles that are published and not secret" do
pending "the `cannot` may require some custom SQL, maybe abstract out from Active Record adapter"
@ability.can :read, Article, :published => true
@ability.cannot :read, Article, :secret => true
article1 = Article.create(:published => true, :secret => false)