Hi,

As per the homework we are required to update the title and add a comment to
the first post and also assert that these changes have been done.
Accordingly I have written the following code that updates the title of the
first post and asserts that the update has been done:

*post* 'posts/update', :id => posts(:one).id, :post => {:title => "New
Title"}
assert_equal 'Post was successfully updated.' , flash[:notice]
assert_redirected_to post_path(assigns(:post))

However when I change the first line as follows the test fails:

*put* 'posts/update', :id => posts(:one).id, :post => {:title => "New
Title"}
assert_equal 'Post was successfully updated.' , flash[:notice]
assert_redirected_to post_path(assigns(:post))

I would like to know why the put method does not work here since we are
supposed to use the put method while doing updates.


I also don't understand how the assert_difference works in the below code
and why is it required??

assert_difference('Post.count') do
      post :create, :post => {:title => "my really new post", :body =>"my
really new body" }
end

assert_difference('Post.count', -1) do
      delete :destroy, :id => posts(:one).id
end

Could anyone please clear these doubts?

Thanks & Regards,
Pallavi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to