Displaying 2 results from an estimated 2 matches for "save_coupon".
2008 Jan 15
4
Okay, I''m finally asking for help
...direct back to the index page" do
Coupon.should_receive
(:new).with({"name"=>@expectedName,"amount"=>@expectedAmount}).and_return(@coupon)
@coupon.should_receive(:save)
response.should redirect_to(:action => ''index'')
post
''save_coupon'',{:coupon=>{:name=>@expectedName,:amount=>@expectedAmount}}
end
(the @vars are all set up)
Here''s the method:
def save_coupon
@coupon = Coupon.new(params[:coupon])
@coupon.save
redirect_to :action => :index
end
Now, I''ve tried it through t...
2008 Jan 23
18
Not seeing the failure
All,
I''m missing something simple, I think. I am writing a spec to say that my
CouponController should create a new coupon from the form parameters, then
set the current user. Here''s the spec:
describe CouponController, "When posting to save_coupon" do
before(:each) do
@expectedName = "pepper''s"
@expectedAmount = 5
coupon = mock_model Coupon
current_user = mock_model User
controller.stub!(:current_user).and_return(current_user)
Coupon.should_receive
(:new).with({"name"=>@expecte...