1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'PUT /api/account/addresses', type: :request do
let(:user) { create(:user_account, role: 'regular') }
let(:card) { create(:card, user_account: user) }
let(:new_card) { build(:card) }
let(:token) { jwt(user) }
let(:headers) { { 'Authorization' => "Bearer #{token['token']}" } }
let(:params) do
{ number: new_card.number, expiration_year: new_card.expiration_year, expiration_month: new_card.expiration_month,
expiration_day: new_card.expiration_day, security_code: new_card.security_code }
end
it_behaves_like 'a PUT request' do
let(:route) { "/api/account/cards/#{card.id}" }
let(:wrong_route) { "/api/account/cards/#{SecureRandom.hex(8)}" }
let(:expected_error_messages) do
['is the wrong length (should be 16 characters)',
'must be greater than 1970',
'is not included in the list',
'is not included in the list',
"can't be blank"]
end
let(:expected_text) do
[new_card.number, new_card.expiration_year, new_card.expiration_month, new_card.expiration_day,
new_card.security_code]
end
let(:wrong_params) do
{ number: SecureRandom.hex(24), expiration_year: -20, expiration_month: 13, expiration_day: 33,
security_code: '' }
end
end
end
|