models: set more creator names explicitly.
Set creators explicitly for bans, BURs, comment votes, and posts.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory(:comment_vote) do
|
||||
user
|
||||
score {1}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "fail silently on errors" do
|
||||
create(:comment_vote, comment: @comment, score: -1)
|
||||
create(:comment_vote, user: @user, comment: @comment, score: -1)
|
||||
assert_difference("CommentVote.count", 0) do
|
||||
post_auth comment_comment_votes_path(comment_id: @comment.id, score: "down", format: "json"), @user
|
||||
assert_response 422
|
||||
@@ -47,7 +47,7 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "fail on errors" do
|
||||
create(:comment_vote, :comment => @comment, :score => -1)
|
||||
create(:comment_vote, user: @user, comment: @comment, score: -1)
|
||||
assert_difference("CommentVote.count", 0) do
|
||||
post_auth comment_comment_votes_path(comment_id: @comment.id, :score => "down", format: "js"), @user
|
||||
assert_response 422
|
||||
|
||||
@@ -115,12 +115,6 @@ class CommentTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "be created" do
|
||||
comment = FactoryBot.build(:comment)
|
||||
comment.save
|
||||
assert(comment.errors.empty?, comment.errors.full_messages.join(", "))
|
||||
end
|
||||
|
||||
should "not validate if the post does not exist" do
|
||||
comment = FactoryBot.build(:comment, :post_id => -1)
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ class ModActionTest < ActiveSupport::TestCase
|
||||
should "hide ip addresses from non-moderators in ip ban modactions" do
|
||||
as(@mod) { create(:ip_ban, ip_addr: "1.1.1.1", reason: "test") }
|
||||
|
||||
as(@user) { assert_equal(0, ModAction.search({}).count) }
|
||||
as(@mod) { assert_equal(1, ModAction.search({}).count) }
|
||||
assert_equal(0, ModAction.visible(@user).count)
|
||||
assert_equal(1, ModAction.visible(@mod).count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2066,7 +2066,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "return posts for the user:<name> metatag" do
|
||||
users = FactoryBot.create_list(:user, 2)
|
||||
users = FactoryBot.create_list(:user, 2, created_at: 2.weeks.ago)
|
||||
posts = users.map { |u| FactoryBot.create(:post, uploader: u) }
|
||||
|
||||
assert_tag_match([posts[0]], "user:#{users[0].name}")
|
||||
@@ -2105,7 +2105,9 @@ class PostTest < ActiveSupport::TestCase
|
||||
should "return posts for the noter:<name> metatag" do
|
||||
users = FactoryBot.create_list(:user, 2)
|
||||
posts = FactoryBot.create_list(:post, 2)
|
||||
notes = users.zip(posts).map { |u, p| FactoryBot.create(:note, creator: u, post: p) }
|
||||
notes = users.zip(posts).map do |u, p|
|
||||
as(u) { create(:note, post: p) }
|
||||
end
|
||||
|
||||
assert_tag_match([posts[0]], "noter:#{users[0].name}")
|
||||
assert_tag_match([posts[1]], "noter:#{users[1].name}")
|
||||
@@ -2201,7 +2203,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
disapproved = FactoryBot.create(:post, is_pending: true)
|
||||
|
||||
create(:post_flag, post: flagged, creator: create(:user, created_at: 2.weeks.ago))
|
||||
FactoryBot.create(:post_disapproval, post: disapproved, reason: "disinterest")
|
||||
create(:post_disapproval, user: CurrentUser.user, post: disapproved, reason: "disinterest")
|
||||
|
||||
assert_tag_match([pending, flagged], "status:unmoderated")
|
||||
end
|
||||
@@ -2380,7 +2382,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
CurrentUser.scoped(FactoryBot.create(:mod_user)) do
|
||||
pending = FactoryBot.create(:post, is_pending: true)
|
||||
disapproved = FactoryBot.create(:post, is_pending: true)
|
||||
disapproval = FactoryBot.create(:post_disapproval, post: disapproved, reason: "disinterest")
|
||||
disapproval = FactoryBot.create(:post_disapproval, user: CurrentUser.user, post: disapproved, reason: "disinterest")
|
||||
|
||||
assert_tag_match([pending], "disapproval:none")
|
||||
assert_tag_match([disapproved], "disapproval:any")
|
||||
@@ -2412,7 +2414,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
u = create(:user, created_at: 2.weeks.ago)
|
||||
create(:artist_commentary, post: p)
|
||||
create(:comment, post: p, creator: u, do_not_bump_post: false)
|
||||
create(:note, post: p, creator: u)
|
||||
create(:note, post: p)
|
||||
p
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user