FEATURE: add staff action logs for watched words (#13574)

This commit is contained in:
Arpit Jalan
2021-06-30 11:22:46 +05:30
committed by GitHub
parent ddaa7cc7ea
commit 1ea2880276
7 changed files with 92 additions and 7 deletions

View File

@ -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