2
0

Convert age verification controller to system specs (#36026)

This commit is contained in:
Matt Jankowski
2025-09-05 08:44:09 -04:00
committed by GitHub
parent 3efba15b3c
commit 05a655f33e
3 changed files with 83 additions and 40 deletions

View File

@@ -110,9 +110,12 @@ RSpec.describe '/api/v1/accounts' do
let(:date_of_birth) { 13.years.ago.strftime('%d.%m.%Y') }
it 'returns http unprocessable entity' do
subject
expect { subject }
.to not_change(User, :count)
.and not_change(Account, :count)
expect(response).to have_http_status(422)
expect(response)
.to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
@@ -122,9 +125,27 @@ RSpec.describe '/api/v1/accounts' do
let(:date_of_birth) { 17.years.ago.strftime('%d.%m.%Y') }
it 'creates a user', :aggregate_failures do
subject
expect { subject }
.to change(User, :count).by(1)
.and change(Account, :count).by(1)
expect(response).to have_http_status(200)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
context 'when date of birth is over age limit in ISO-8601 format' do
let(:date_of_birth) { 17.years.ago.to_date.iso8601 }
it 'creates a user', :aggregate_failures do
expect { subject }
.to change(User, :count).by(1)
.and change(Account, :count).by(1)
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end