Bug: Fix conversation not loading from the links in email (#602)

Bug: Load conversation from links
This commit is contained in:
Pranav Raj S
2020-03-08 22:08:25 +05:30
committed by GitHub
parent a8ac048716
commit 2a4fb7b056
14 changed files with 118 additions and 36 deletions

View File

@@ -31,4 +31,29 @@ RSpec.describe 'Conversation Messages API', type: :request do
end
end
end
describe 'GET /api/v1/conversations/:id/messages' do
let(:conversation) { create(:conversation, account: account) }
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
get "/api/v1/conversations/#{conversation.display_id}/messages"
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 'shows the conversation' do
get "/api/v1/conversations/#{conversation.display_id}/messages",
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(JSON.parse(response.body, symbolize_names: true)[:meta][:contact_id]).to eq(conversation.contact_id)
end
end
end
end

View File

@@ -51,7 +51,7 @@ RSpec.describe 'Conversations API', type: :request do
as: :json
expect(response).to have_http_status(:success)
expect(JSON.parse(response.body, symbolize_names: true)[:meta][:contact_id]).to eq(conversation.contact_id)
expect(JSON.parse(response.body, symbolize_names: true)[:id]).to eq(conversation.display_id)
end
end
end