chore: Fix emails being sent with the wrong translations (#2236)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose
2021-06-08 22:45:01 +05:30
committed by GitHub
parent 67ce6f5704
commit 1bf7227843
15 changed files with 75 additions and 38 deletions

View File

@@ -374,14 +374,24 @@ RSpec.describe 'Conversations API', type: :request do
let(:params) { { email: 'test@test.com' } }
it 'mutes conversation' do
allow(ConversationReplyMailer).to receive(:conversation_transcript)
mailer = double
allow(ConversationReplyMailer).to receive(:with).and_return(mailer)
allow(mailer).to receive(:conversation_transcript)
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript",
headers: agent.create_new_auth_token,
params: params,
as: :json
expect(response).to have_http_status(:success)
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
expect(mailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
end
it 'renders error when parameter missing' do
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/transcript",
headers: agent.create_new_auth_token,
params: {},
as: :json
expect(response).to have_http_status(:unprocessable_entity)
end
end
end

View File

@@ -104,7 +104,9 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
describe 'POST /api/v1/widget/conversations/transcript' do
context 'with a conversation' do
it 'sends transcript email' do
allow(ConversationReplyMailer).to receive(:conversation_transcript)
mailer = double
allow(ConversationReplyMailer).to receive(:with).and_return(mailer)
allow(mailer).to receive(:conversation_transcript)
post '/api/v1/widget/conversations/transcript',
headers: { 'X-Auth-Token' => token },
@@ -112,7 +114,7 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
as: :json
expect(response).to have_http_status(:success)
expect(ConversationReplyMailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
expect(mailer).to have_received(:conversation_transcript).with(conversation, 'test@test.com')
end
end
end