summaryrefslogtreecommitdiff
path: root/spec/requests/user_accounts_controller/update_spec.rb
blob: fcfb28e87c1dd576fa7bf445346d4152cba55eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'PUT /api/account', type: :request do
  let(:user) { create(:user_account) }
  let(:data) { build(:user_account) }
  let(:token) { jwt(user) }

  it_behaves_like 'a PUT request', account: true do
    let(:route) { '/api/account' }
    let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } }
    let(:params) do
      { email: data.email, password: data.password, first_name: data.first_name, last_name: data.last_name }
    end
    let(:expected_text) { [] }
    let(:desired_error_status) { 422 }
    let(:wrong_params) { { email: 'notanemail', password: '', first_name: '', last_name: '' } }
    let(:expected_error_messages) do
      ['Email is invalid', "First name can't be blank", "Last name can't be blank"]
    end
  end
end