mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FEATURE: add staff action logs for watched words (#13574)
This commit is contained in:
@ -544,7 +544,6 @@ describe StaffActionLogger do
|
||||
expect(user_history.action).to eq(UserHistory.actions[:post_rejected])
|
||||
expect(user_history.details).to include(reviewable.payload['raw'])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'log_topic_closed' do
|
||||
@ -617,4 +616,43 @@ describe StaffActionLogger do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#log_watched_words_creation' do
|
||||
fab!(:watched_word) { Fabricate(:watched_word, action: WatchedWord.actions[:block]) }
|
||||
|
||||
it "raises an error when watched_word is missing" do
|
||||
expect { logger.log_watched_words_creation(nil) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it "creates a new UserHistory record" do
|
||||
logger.log_watched_words_creation(watched_word)
|
||||
|
||||
expect(UserHistory.count).to eq(1)
|
||||
user_history = UserHistory.last
|
||||
|
||||
expect(user_history.subject).to eq(nil)
|
||||
expect(user_history.details).to include(watched_word.word)
|
||||
expect(user_history.context).to eq("block")
|
||||
expect(user_history.action).to eq(UserHistory.actions[:watched_word_create])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#log_watched_words_deletion' do
|
||||
fab!(:watched_word) { Fabricate(:watched_word, action: WatchedWord.actions[:block]) }
|
||||
|
||||
it "raises an error when watched_word is missing" do
|
||||
expect { logger.log_watched_words_deletion(nil) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it "creates a new UserHistory record" do
|
||||
logger.log_watched_words_deletion(watched_word)
|
||||
|
||||
expect(UserHistory.count).to eq(1)
|
||||
user_history = UserHistory.last
|
||||
|
||||
expect(user_history.subject).to eq(nil)
|
||||
expect(user_history.details).to include(watched_word.word)
|
||||
expect(user_history.context).to eq("block")
|
||||
expect(user_history.action).to eq(UserHistory.actions[:watched_word_destroy])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user