add tests for note locks
fix naming scheme for mod actions
This commit is contained in:
@@ -1496,25 +1496,25 @@ class Post < ApplicationRecord
|
|||||||
def create_mod_action_for_lock_change
|
def create_mod_action_for_lock_change
|
||||||
if is_note_locked != is_note_locked_was
|
if is_note_locked != is_note_locked_was
|
||||||
if is_note_locked
|
if is_note_locked
|
||||||
ModAction.log("locked notes for post ##{id}", :post_note_lock)
|
ModAction.log("locked notes for post ##{id}", :post_note_lock_create)
|
||||||
else
|
else
|
||||||
ModAction.log("unlocked notes for post ##{id}", :post_note_unlock)
|
ModAction.log("unlocked notes for post ##{id}", :post_note_lock_delete)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_rating_locked != is_rating_locked_was
|
if is_rating_locked != is_rating_locked_was
|
||||||
if is_rating_locked
|
if is_rating_locked
|
||||||
ModAction.log("locked rating for post ##{id}", :post_rating_lock)
|
ModAction.log("locked rating for post ##{id}", :post_rating_lock_create)
|
||||||
else
|
else
|
||||||
ModAction.log("unlocked rating for post ##{id}", :post_rating_unlock)
|
ModAction.log("unlocked rating for post ##{id}", :post_rating_lock_delete)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_status_locked != is_status_locked_was
|
if is_status_locked != is_status_locked_was
|
||||||
if is_status_locked
|
if is_status_locked
|
||||||
ModAction.log("locked status for post ##{id}", :post_status_lock)
|
ModAction.log("locked status for post ##{id}", :post_status_lock_create)
|
||||||
else
|
else
|
||||||
ModAction.log("unlocked status for post ##{id}", :post_status_unlock)
|
ModAction.log("unlocked status for post ##{id}", :post_status_lock_delete)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -534,6 +534,52 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_includes(approval.errors.full_messages, "Post is locked and cannot be approved")
|
assert_includes(approval.errors.full_messages, "Post is locked and cannot be approved")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Locking post fields" do
|
||||||
|
should "create ModAction entries" do
|
||||||
|
@post = create(:post)
|
||||||
|
assert_difference("ModAction.post_note_lock_create.count", 1) do
|
||||||
|
@post.is_note_locked = true
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_note_lock_delete.count", 1) do
|
||||||
|
@post.is_note_locked = false
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_rating_lock_create.count", 1) do
|
||||||
|
@post.is_rating_locked = true
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_rating_lock_delete.count", 1) do
|
||||||
|
@post.is_rating_locked = false
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_status_lock_create.count", 1) do
|
||||||
|
@post.is_status_locked = true
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_status_lock_delete.count", 1) do
|
||||||
|
@post.is_status_locked = false
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_difference("ModAction.post_status_lock_create.count", 1) do
|
||||||
|
assert_difference("ModAction.post_rating_lock_create.count", 1) do
|
||||||
|
assert_difference("ModAction.post_note_lock_create.count", 1) do
|
||||||
|
@post.is_status_locked = true
|
||||||
|
@post.is_rating_locked = true
|
||||||
|
@post.is_note_locked = true
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Tagging:" do
|
context "Tagging:" do
|
||||||
|
|||||||
Reference in New Issue
Block a user