Skip to content

Instantly share code, notes, and snippets.

@mrgenixus
Created January 12, 2015 22:56
Show Gist options
  • Select an option

  • Save mrgenixus/7df56a06dcf3064c9822 to your computer and use it in GitHub Desktop.

Select an option

Save mrgenixus/7df56a06dcf3064c9822 to your computer and use it in GitHub Desktop.
context "policy_scope" do
let(:user) { create :user }
let(:admin_user) { create :user, :admin }
let!(:bookings) { create_list :booking, 2 }
let!(:user_bookings) { create_list :booking, 2, user: user }
it "should not include any models for non-admins" do
BookingPolicy::Scope.new(user, Bookings).resolve.tap do |scope|
expect(scope.all.count).to eq 0
end
end
it "should not include any models for non-admins" do
BookingPolicy::Scope.new(admin_user, Bookings).resolve.tap do |scope|
expect(scope.all.count).to eq Bookings.all.count
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment