Here is the error in rspec:
CategoriesController GET 'update' should be successful
Failure/Error: get 'update'
ActiveRecord::RecordNotFound:
Couldn't find Category without an ID
# c:in `find'
# ./app/controllers/categories_controller.rb:45:in `update'
# ./spec/controllers/categories_controller_spec.rb:35:in `block (3 levels) in <top (required)>'
Here is the code in controller:
def edit
@category = Category.find(params[:id])
end
def update
@category = Category.find(params[:id])
#@category.reload. caused nil.reload error
if @category.update_attributes(params[:category], :as => :roles_update)
@category = Category.find(params[:id])
redirect_to @category, :notice => 'Category was successfully updated'
else
@categories = Category.all
render 'index'
end
end
Here is the rspec code:
describe "GET 'update'" do
it "should be successful" do
get 'update'
response.should be_success
end
end
Any thoughts? Thanks.