feat: Ability to unmute muted conversations (#1319)

This commit is contained in:
Dmitriy Shcherbakan
2020-10-08 09:32:08 +03:00
committed by GitHub
parent 2aad33a5be
commit ecebe163e1
13 changed files with 242 additions and 0 deletions

View File

@@ -246,6 +246,31 @@ RSpec.describe 'Conversations API', type: :request do
end
end
describe 'POST /api/v1/accounts/{account.id}/conversations/:id/unmute' do
let(:conversation) { create(:conversation, account: account).tap(&:mute!) }
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/unmute"
expect(response).to have_http_status(:unauthorized)
end
end
context 'when it is an authenticated user' do
let(:agent) { create(:user, account: account, role: :agent) }
it 'unmutes conversation' do
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/unmute",
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(conversation.reload.muted?).to eq(false)
end
end
end
describe 'POST /api/v1/accounts/{account.id}/conversations/:id/transcript' do
let(:conversation) { create(:conversation, account: account) }

View File

@@ -289,6 +289,22 @@ RSpec.describe Conversation, type: :model do
end
end
describe '#unmute!' do
subject(:unmute!) { conversation.unmute! }
let(:conversation) { create(:conversation).tap(&:mute!) }
it 'does not change conversation status' do
expect { unmute! }.not_to(change { conversation.reload.status })
end
it 'marks conversation as muted in redis' do
expect { unmute! }
.to change { Redis::Alfred.get(conversation.send(:mute_key)) }
.to nil
end
end
describe '#muted?' do
subject(:muted?) { conversation.muted? }