Skip to content

Instantly share code, notes, and snippets.

@fahim
Created November 4, 2011 16:01
Show Gist options
  • Save fahim/1339698 to your computer and use it in GitHub Desktop.
Save fahim/1339698 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Promotion::Rules::OnePerUser do
let(:rule) { Promotion::Rules::OnePerUser.new }
let(:user) { mock_model(User) }
let(:order) { mock_model(Order, :user => user) }
describe "the arel expression" do
before do
PromotionCredit.stub_chain('includes.where')
end
it "limits by promotion credit id" do
promotion_id = 5
rule.stubs(:promotion_id => promotion_id)
table = PromotionCredit.arel_table
table.expects(:[]).with(:source_id)
table[:source_id].expects(:eq).with(promotion_id)
rule.used_promotion_credits(order)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment