Sha256: 1f38c8f0f1506652ac70f7e649b79929898e03d9566778f5492f81ff93046bb3
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
# This is used to wrap the CanCan ORM adapters, that enable convenient # 'simple' queries using hashes similar to 'metawhere' gem require 'spec_helper' require 'migration_helper' class Poster < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => "user_id" end class User < ActiveRecord::Base has_many :posters end module CanTango::Ability class Base def permit_rules can :read, Poster, :owner => user end end end describe CanTango::Adaptor::ActiveRecord do before do migrate! @user = User.create :name => 'admin', :email => 'admin@mail.ru' @stranger = User.create :name => 'stranger', :email => 'strange@mail.ru' @poster = Poster.create :owner => @user @poster.owner = @user end context 'subject is owner of poster' do subject { CanTango::Ability::Executor::Base.new @user } specify { subject.should be_allowed_to(:read, @poster) } end context 'subject is NOT owner of poster' do subject { CanTango::Ability::Executor::Base.new @stranger } specify { subject.should_not be_allowed_to(:read, @poster) } end end
Version data entries
6 entries across 6 versions & 1 rubygems