I´m stucked with the same Lab point: Update the title of the first post.

My problem is I don't know how to properly do a PUT call from an integration
Test:

class CreateNewPostAndCommentTest < ActionController::IntegrationTest
...

I receive a return code 200 but when I check the DB there is no change.

I'll be glad if you can give me any tip or link with a good explanation
about RESTful PUT calls.

Thanks, in advance.
Leonardo


On Sun, Aug 16, 2009 at 5:11 PM, miga <[email protected]> wrote:

>
> When running the integration test on create (exercise 3 of the lab),
> I've noticed in test.log that the added comments are not attached to
> any post:
>
> Processing PostsController#post_comment (for 127.0.0.1 at 2009-07-20
> 20:15:00) [POST]
>  Parameters: {"comment"=>{"post_id"=>"1138", "comment"=>"my
> comment"}}
>   [4;36;1mSQL (1.0ms) [0m    [0;1mINSERT INTO `comments` (`post_id`,
> `created_at`, `comment`, `updated_at`) VALUES(NULL, '2009-07-20
> 18:15:00', 'my comment', '2009-07-20 18:15:00') [0m
> Redirected to http://www.example.com/posts/show
> Completed in 71ms (DB: 1) | 302 Found [http://www.example.com/posts/
> post_comment]
>
>
> Notice the value NULL on post_id.
>
> In order to get them attached to the right post I've changed the test
> as following:
>
>  test "should create 1 post and 2 comments" do
>    post '/posts/create', :post => {:title => "Rails", :body => "I
> love Rails"}
>    assert assigns(:post).valid?
>    assert_redirected_to post_path(assigns(:post))
>
>   # Added here
>   post = assigns(:post)
>    get "/posts/#{post.id}"
>   # End of addition
>
>    post '/posts/post_comment', :comment => {:post_id =>
> post.id, :comment => "my comment"}
>    assert assigns(:comment).valid?
>    assert_redirected_to :action => 'show'
>
>    # Added here
>    get "/posts/#{post.id}"
>    # End of addition
>
>    post '/posts/post_comment', :comment => {:post_id =>
> post.id, :comment => "my comment 2"}
>    assert assigns(:comment).valid?
>    assert_redirected_to :action => 'show'
>
> Is this the right way to do?
> >
>

--~--~---------~--~----~------------~-------~--~----~
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