Skip to content

Commit

Permalink
move mobile cassettes to root spec folder (#12847)
Browse files Browse the repository at this point in the history
* move mobile cassettes to root

* lint fix
  • Loading branch information
aherzberg authored Jun 1, 2023
1 parent e9abb7c commit e8564ad
Show file tree
Hide file tree
Showing 184 changed files with 443 additions and 621 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/iam_session_helper'

RSpec.describe Mobile::ApplicationController, type: :controller do
controller do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/sis_session_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/sis_session_helper'
require_relative '../support/helpers/iam_session_helper'
require_relative '../support/matchers/json_schema_matcher'

RSpec.shared_examples 'sso logging' do |type|
Expand Down
51 changes: 22 additions & 29 deletions modules/mobile/spec/request/addresses_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/iam_session_helper'
require_relative '../support/matchers/json_schema_matcher'

RSpec.describe 'address', type: :request do
Expand All @@ -20,19 +20,12 @@
end

describe 'update endpoints' do
before(:all) do
@original_cassette_dir = VCR.configure(&:cassette_library_dir)
VCR.configure { |c| c.cassette_library_dir = 'modules/mobile/spec/support/vcr_cassettes' }
end

after(:all) { VCR.configure { |c| c.cassette_library_dir = @original_cassette_dir } }

describe 'POST /mobile/v0/user/addresses' do
context 'with a valid address that takes two tries to complete' do
before do
VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/post_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/post_address_initial') do
post '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand All @@ -58,10 +51,10 @@
allow_any_instance_of(Mobile::V0::Profile::SyncUpdateService)
.to receive(:seconds_elapsed_since).and_return(61)

VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete_2') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/post_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete_2') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/post_address_initial') do
post '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand Down Expand Up @@ -109,9 +102,9 @@
describe 'PUT /mobile/v0/user/addresses' do
context 'with a valid address that takes two tries to complete' do
before do
VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/put_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/put_address_initial') do
put '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand All @@ -137,10 +130,10 @@
allow_any_instance_of(Mobile::V0::Profile::SyncUpdateService)
.to receive(:seconds_elapsed_since).and_return(61)

VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete_2') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/put_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete_2') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/put_address_initial') do
put '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand Down Expand Up @@ -188,9 +181,9 @@
describe 'DELETE /mobile/v0/user/addresses' do
context 'with a valid address that takes two tries to complete' do
before do
VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/put_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/put_address_initial') do
delete '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand All @@ -216,10 +209,10 @@
allow_any_instance_of(Mobile::V0::Profile::SyncUpdateService)
.to receive(:seconds_elapsed_since).and_return(61)

VCR.use_cassette('profile/get_address_status_complete') do
VCR.use_cassette('profile/get_address_status_incomplete_2') do
VCR.use_cassette('profile/get_address_status_incomplete') do
VCR.use_cassette('profile/put_address_initial') do
VCR.use_cassette('mobile/profile/get_address_status_complete') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete_2') do
VCR.use_cassette('mobile/profile/get_address_status_incomplete') do
VCR.use_cassette('mobile/profile/put_address_initial') do
delete '/mobile/v0/user/addresses', params: address.to_json, headers: iam_headers(json_body_headers)
end
end
Expand Down
15 changes: 4 additions & 11 deletions modules/mobile/spec/request/appointments_cancel_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/iam_session_helper'
require_relative '../support/matchers/json_schema_matcher'

RSpec.describe 'appointments', type: :request do
Expand All @@ -13,18 +13,11 @@
allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token')
end

before(:all) do
@original_cassette_dir = VCR.configure(&:cassette_library_dir)
VCR.configure { |c| c.cassette_library_dir = 'modules/mobile/spec/support/vcr_cassettes' }
end

after(:all) { VCR.configure { |c| c.cassette_library_dir = @original_cassette_dir } }

describe 'PUT /mobile/v0/appointments/cancel', :aggregate_failures do
let(:cancel_id) { '70060' }

it 'returns a no content code' do
VCR.use_cassette('appointments/VAOS_v2/cancel_appointment_200', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/VAOS_v2/cancel_appointment_200', match_requests_on: %i[method uri]) do
put "/mobile/v0/appointments/cancel/#{cancel_id}", params: nil, headers: iam_headers

expect(response).to have_http_status(:no_content)
Expand All @@ -34,7 +27,7 @@

context 'when the appointment cannot be found' do
it 'returns a 400 code' do
VCR.use_cassette('appointments/VAOS_v2/cancel_appointment_400', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/VAOS_v2/cancel_appointment_400', match_requests_on: %i[method uri]) do
put "/mobile/v0/appointments/cancel/#{cancel_id}", params: nil, headers: iam_headers

expect(response.status).to eq(400)
Expand All @@ -48,7 +41,7 @@

context 'when the backend service cannot handle the request' do
it 'returns a 502 code' do
VCR.use_cassette('appointments/VAOS_v2/cancel_appointment_500', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/VAOS_v2/cancel_appointment_500', match_requests_on: %i[method uri]) do
put "/mobile/v0/appointments/cancel/#{cancel_id}", params: nil, headers: iam_headers
expect(response.status).to eq(502)
expect(JSON.parse(response.body)['errors'][0]['code']).to eq('VAOS_502')
Expand Down
21 changes: 8 additions & 13 deletions modules/mobile/spec/request/appointments_create_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'
require 'mobile/v0/vaos_appointments/appointments_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/iam_session_helper'
require_relative '../support/matchers/json_schema_matcher'

RSpec.describe 'vaos appointments', type: :request, skip_mvi: true do
Expand All @@ -27,14 +27,7 @@
# rubocop:enable Layout/LineLength
end

before(:all) do
@original_cassette_dir = VCR.configure(&:cassette_library_dir)
VCR.configure { |c| c.cassette_library_dir = 'modules/mobile/spec/support/vcr_cassettes' }
end

after(:all) do
VCR.configure { |c| c.cassette_library_dir = @original_cassette_dir }

Flipper.disable('va_online_scheduling')
end

Expand All @@ -52,13 +45,14 @@
it 'clears the cache' do
expect(Mobile::V0::Appointment).to receive(:clear_cache).once

VCR.use_cassette('appointments/post_appointments_va_proposed_clinic_200', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/post_appointments_va_proposed_clinic_200',
match_requests_on: %i[method uri]) do
post '/mobile/v0/appointment', params: va_proposed_request_body, headers: iam_headers
end
end

it 'returns a descriptive 400 error when given invalid params' do
VCR.use_cassette('appointments/post_appointments_400', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/post_appointments_400', match_requests_on: %i[method uri]) do
post '/mobile/v0/appointment', params: {}, headers: iam_headers
expect(response).to have_http_status(:bad_request)
expect(JSON.parse(response.body)['errors'][0]['status']).to eq('400')
Expand All @@ -70,7 +64,7 @@

context 'for CC facility' do
it 'creates the cc appointment' do
VCR.use_cassette('appointments/post_appointments_cc_200_2222022', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/post_appointments_cc_200_2222022', match_requests_on: %i[method uri]) do
post '/mobile/v0/appointment', params: community_cares_request_body, headers: iam_headers
expect(response).to have_http_status(:created)
expect(json_body_for(response)).to match_camelized_schema('vaos/v2/appointment', { strict: false })
Expand All @@ -80,7 +74,8 @@

context 'for va facility' do
it 'creates the va appointment - proposed' do
VCR.use_cassette('appointments/post_appointments_va_proposed_clinic_200', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/post_appointments_va_proposed_clinic_200',
match_requests_on: %i[method uri]) do
post '/mobile/v0/appointment', params: {}, headers: iam_headers

expect(response).to have_http_status(:created)
Expand All @@ -89,7 +84,7 @@
end

it 'creates the va appointment - booked' do
VCR.use_cassette('appointments/post_appointments_va_booked_200_JACQUELINE_M',
VCR.use_cassette('mobile/appointments/post_appointments_va_booked_200_JACQUELINE_M',
match_requests_on: %i[method uri]) do
post '/mobile/v0/appointment', params: {}, headers: iam_headers
expect(response).to have_http_status(:created)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/iam_session_helper'
require_relative '../support/helpers/iam_session_helper'
require_relative '../support/matchers/json_schema_matcher'

RSpec.describe 'appointment preferences', type: :request do
Expand All @@ -14,16 +14,9 @@
allow_any_instance_of(VAOS::UserService).to receive(:session).and_return('stubbed_token')
end

before(:all) do
@original_cassette_dir = VCR.configure(&:cassette_library_dir)
VCR.configure { |c| c.cassette_library_dir = 'modules/mobile/spec/support/vcr_cassettes' }
end

after(:all) { VCR.configure { |c| c.cassette_library_dir = @original_cassette_dir } }

describe 'GET /appointments/preferences', :aggregate_failures do
it 'returns a 200 with the correct schema' do
VCR.use_cassette('appointments/get_preferences', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/get_preferences', match_requests_on: %i[method uri]) do
get '/mobile/v0/appointments/preferences', headers: iam_headers

expect(response).to have_http_status(:ok)
Expand All @@ -50,7 +43,7 @@
end

it 'returns a 200 code' do
VCR.use_cassette('appointments/put_preferences', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/put_preferences', match_requests_on: %i[method uri]) do
put '/mobile/v0/appointments/preferences', headers: iam_headers, params: request_body

expect(response).to have_http_status(:ok)
Expand All @@ -60,7 +53,7 @@

context 'when only required fields are included in params' do
it 'returns a 200 code' do
VCR.use_cassette('appointments/put_preferences_minimal_payload', match_requests_on: %i[method uri]) do
VCR.use_cassette('mobile/appointments/put_preferences_minimal_payload', match_requests_on: %i[method uri]) do
put '/mobile/v0/appointments/preferences', headers: iam_headers, params: request_body

expect(response).to have_http_status(:ok)
Expand Down
Loading

0 comments on commit e8564ad

Please sign in to comment.