feat: Add messages on mute / unmute actions (#1373)

This commit is contained in:
Yih Yang
2020-10-31 00:57:25 +08:00
committed by GitHub
parent 84ce0a9054
commit 12b7358773
3 changed files with 44 additions and 0 deletions

View File

@@ -276,8 +276,14 @@ RSpec.describe Conversation, type: :model do
describe '#mute!' do
subject(:mute!) { conversation.mute! }
let(:user) do
create(:user, email: 'agent2@example.com', account: create(:account), role: :agent)
end
let(:conversation) { create(:conversation) }
before { Current.user = user }
it 'marks conversation as resolved' do
mute!
expect(conversation.reload.resolved?).to eq(true)
@@ -287,13 +293,24 @@ RSpec.describe Conversation, type: :model do
mute!
expect(Redis::Alfred.get(conversation.send(:mute_key))).not_to eq(nil)
end
it 'creates mute message' do
mute!
expect(conversation.messages.pluck(:content)).to include("#{user.name} has muted the conversation")
end
end
describe '#unmute!' do
subject(:unmute!) { conversation.unmute! }
let(:user) do
create(:user, email: 'agent2@example.com', account: create(:account), role: :agent)
end
let(:conversation) { create(:conversation).tap(&:mute!) }
before { Current.user = user }
it 'does not change conversation status' do
expect { unmute! }.not_to(change { conversation.reload.status })
end
@@ -303,6 +320,11 @@ RSpec.describe Conversation, type: :model do
.to change { Redis::Alfred.get(conversation.send(:mute_key)) }
.to nil
end
it 'creates unmute message' do
unmute!
expect(conversation.messages.pluck(:content)).to include("#{user.name} has unmuted the conversation")
end
end
describe '#muted?' do