Feature: Contact Merge Action (#378)
This commit is contained in:
@@ -4,7 +4,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
let(:account) { create(:account) }
|
||||
|
||||
describe 'GET /api/v1/profile' do
|
||||
context 'when unauthenticated user' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
it 'returns unauthorized' do
|
||||
get '/api/v1/profile'
|
||||
|
||||
@@ -12,7 +12,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it authenticated user' do
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
|
||||
it 'returns current user information' do
|
||||
@@ -29,7 +29,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
end
|
||||
|
||||
describe 'PUT /api/v1/profile' do
|
||||
context 'when unauthenticated user' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
it 'returns unauthorized' do
|
||||
put '/api/v1/profile'
|
||||
|
||||
@@ -37,12 +37,13 @@ RSpec.describe 'Profile API', type: :request do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it authenticated user' do
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
|
||||
it 'updates the name & email' do
|
||||
new_email = Faker::Internet.email
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { name: 'test', 'email': 'test@test.com' } },
|
||||
params: { profile: { name: 'test', 'email': new_email } },
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
@@ -51,7 +52,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
agent.reload
|
||||
expect(json_response['id']).to eq(agent.id)
|
||||
expect(json_response['email']).to eq(agent.email)
|
||||
expect(agent.email).to eq('test@test.com')
|
||||
expect(agent.email).to eq(new_email)
|
||||
end
|
||||
|
||||
it 'updates the password' do
|
||||
@@ -68,7 +69,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
expect(agent.avatar.attached?).to eq(false)
|
||||
file = fixture_file_upload(Rails.root.join('spec/assets/avatar.png'), 'image/png')
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { name: 'test', 'email': 'test@test.com', avatar: file } },
|
||||
params: { profile: { avatar: file } },
|
||||
headers: agent.create_new_auth_token
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
|
||||
Reference in New Issue
Block a user