I am trying to run this test
setup do
@comment = comments(:hello)
@comment.commenter = "cleb"
@comment.body = "hello"
@comment.user_id = 1
end
test "should create comment" do
assert_difference('Comment.count') do
post :create, :comment => @comment.attributes
end
assert_redirected_to comment_path(assigns(:comment))
end
It comes up with
test_should_create_comment(CommentsControllerTest):
ActiveRecord::RecordNotFound: Couldn't find User without an ID
This is from comments.yml
hello:
commenter: cleb
body: hello
user_id: 1
This is from comments.controller
def create
@cuser = @current_user
@user = User.find(params[:user_id])
@user.comments.create(:user_id => @user.id, :commenter =>
@cuser.login, :body => params[:comment][:body])
respond_to do |format|
format.js
format.html {redirect_to user_path}
end
end
What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment