models: remove belongs_to_creator macro.
The belongs_to_creator macro was used to initialize the creator_id field to the CurrentUser. This made tests complicated because it meant you had to create and set the current user every time you wanted to create an object, when lead to the current user being set over and over again. It also meant you had to constantly be aware of what the CurrentUser was in many different contexts, which was often confusing. Setting creators explicitly simplifies everything greatly.
This commit is contained in:
@@ -188,7 +188,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "create action" do
|
||||
should "create a comment" do
|
||||
assert_difference("Comment.count", 1) do
|
||||
post_auth comments_path, @user, params: {comment: FactoryBot.attributes_for(:comment, post_id: @post.id)}
|
||||
post_auth comments_path, @user, params: { comment: { post_id: @post.id, body: "blah" } }
|
||||
end
|
||||
comment = Comment.last
|
||||
assert_redirected_to post_path(comment.post)
|
||||
@@ -196,7 +196,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
should "not allow commenting on nonexistent posts" do
|
||||
assert_difference("Comment.count", 0) do
|
||||
post_auth comments_path, @user, params: {comment: FactoryBot.attributes_for(:comment, post_id: -1)}
|
||||
post_auth comments_path, @user, params: { comment: { post_id: -1, body: "blah" } }
|
||||
end
|
||||
assert_redirected_to comments_path
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user