Sha256: 42f2166bcf2f6fec7c0ade3ec43cf1cf33e7da26b402dd3433f2f4c493862086

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

require "cancan/matchers"

describe Spree::AuctionAbility do
  context 'permissions' do
    let(:admin_user) { create(:admin_user) }
    let(:admin_user2) { create(:admin_user) }
    let(:user) { create(:user) }
    let(:product) { create(:product) }
    let!(:auction) {
      create(:auction, {
        product: product,
        creator: admin_user
      })}

    it 'only allows admins to create an auction' do
       expect(Spree::AuctionAbility.new(admin_user)).to be_able_to(:create, Spree::Auction.new)
       expect(Spree::AuctionAbility.new(user)).to_not be_able_to(:create, Spree::Auction.new)
    end

    it 'only allows certain admins to edit an auction' do
       expect(Spree::AuctionAbility.new(admin_user)).to be_able_to(:edit, auction)
       expect(Spree::AuctionAbility.new(admin_user2)).to_not be_able_to(:edit, auction)
    end

    it 'only allows certain admins to update an auction' do
       expect(Spree::AuctionAbility.new(admin_user)).to be_able_to(:update, auction)
       expect(Spree::AuctionAbility.new(admin_user2)).to_not be_able_to(:update, auction)
    end

    it 'only allows certain admins to delete an auction' do
       expect(Spree::AuctionAbility.new(admin_user)).to be_able_to(:destroy, auction)
       expect(Spree::AuctionAbility.new(admin_user2)).to_not be_able_to(:destroy, auction)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_auction-0.0.6 spec/models/auction_ability_spec.rb
solidus_auction-0.0.5 spec/models/auction_ability_spec.rb