using instance_exec to change scope of can blocks to instance of ability, this is a bit ugly so I may end up using methods instead

This commit is contained in:
Ryan Bates
2009-11-16 16:24:36 -08:00
parent be1892cca8
commit c663effc06
4 changed files with 32 additions and 1 deletions

View File

@@ -77,4 +77,11 @@ describe CanCan::Ability do
@ability.can?(:new, 123).should == :create_called
@ability.can?(:edit, 123).should == :update_called
end
it "should be able to access given user" do
@ability_class.can(:preview, :all) { user }
ability = @ability_class.for_user(:some_user)
ability.user.should == :some_user
ability.can?(:preview, 123).should == :some_user
end
end