vendredi 18 mai 2018

How to use the edit_path in Rails for testing

I am setting up automatic testing for my Rails application. I am working on my controller test and I am getting an unrecognized id error. I know the edit route works for the app right now because I can go to the actual link(/adjusters/3293/edit), but I cannot get my test to past.

 def setup
    @adjuster = Adjuster.new(adjuster_name: "TestLastName", address_1: "4511 W 200 S", id: 1)
 end

 test "should get edit" do
   get edit_adjuster_path(@adjuster)
   assert_response :success
 end

When I rake my routes the edit route shows.

edit_adjuster GET    /adjusters/:id/edit(.:format) adjusters#edit

Here is the error I am receiving

Couldn't find Adjuster with 'id'=1

My show route works though

test "should get show" do
  get adjusters_path(@adjuster)
  assert_response :success
end

Aucun commentaire:

Enregistrer un commentaire