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:
@@ -169,7 +169,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "with only deleted comments" do
|
||||
setup do
|
||||
as(@user) { create(:comment, post: @post, is_deleted: true) }
|
||||
as(@user) { create(:comment, creator: @user, post: @post, is_deleted: true) }
|
||||
end
|
||||
|
||||
should "not show deleted comments to regular members" do
|
||||
@@ -194,7 +194,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "with only downvoted comments" do
|
||||
should "not show thresholded comments" do
|
||||
comment = as(@user) { create(:comment, post: @post, score: -10) }
|
||||
comment = as(@user) { create(:comment, creator: @user, post: @post, score: -10) }
|
||||
get_auth post_path(@post), @user, params: { id: @post.id }
|
||||
|
||||
assert_response :success
|
||||
@@ -206,9 +206,9 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
context "with a mix of comments" do
|
||||
should "not show deleted or thresholded comments " do
|
||||
as(@user) { create(:comment, post: @post, do_not_bump_post: true, body: "good") }
|
||||
as(@user) { create(:comment, post: @post, do_not_bump_post: true, body: "bad", score: -10) }
|
||||
as(@user) { create(:comment, post: @post, do_not_bump_post: true, body: "ugly", is_deleted: true) }
|
||||
as(@user) { create(:comment, creator: @user, post: @post, do_not_bump_post: true, body: "good") }
|
||||
as(@user) { create(:comment, creator: @user, post: @post, do_not_bump_post: true, body: "bad", score: -10) }
|
||||
as(@user) { create(:comment, creator: @user, post: @post, do_not_bump_post: true, body: "ugly", is_deleted: true) }
|
||||
|
||||
get_auth post_path(@post), @user, params: { id: @post.id }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user