I am trying to test a controller method with the following code:
it "should set an approved_at date and email the campaign client" do @campaign = Campaign.create(valid_attributes) post :approve, id: @campaign.id.to_s @campaign.reload @campaign.approved_at.should_not be(nil) end
However, when I run this test, I get the following error:
Failure/Error: @campaign.reload ActiveRecord::RecordNotFound: Couldn't find Campaign without an ID
When I run similar lines in the rails console, the reboot works, and the value is set as I need. Why does rebooting work for me when I run the code in the rspec test?
source share