Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created January 13, 2009 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/46637 to your computer and use it in GitHub Desktop.
Save patmaddox/46637 to your computer and use it in GitHub Desktop.
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe IncentivesController do
integrate_views
describe "GET /incentives" do
it "should work" do
get :index
response.should be_success
end
end
describe "GET /incentives/new" do
it "should work" do
get :new
response.should be_success
end
end
describe "POST /incentives, multiple criteria" do
def do_post
post :create, :incentive => {:name => "new incentive", :model => 'Cart'},
:criteria => [{:finder => 'total_greater_than', :param => 200},
{:finder => 'containing_item', :param => 1}]
end
it "should create a new incentive" do
lambda { do_post }.should change(Incentive, :count).by(1)
end
it "should create a new criterium for the incentive" do
do_post
i = Incentive.find :first
i.should have(2).criteria
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment