From d77038fd3f91fe3ffbc18dbb9cf08f3dd7e57aa0 Mon Sep 17 00:00:00 2001 From: GcioGregg <117232882+GcioGregg@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:00:42 -0800 Subject: [PATCH] remove unneeded tests --- .../v1/institutions_controller_spec.rb | 55 ++----------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/spec/controllers/v1/institutions_controller_spec.rb b/spec/controllers/v1/institutions_controller_spec.rb index dcffa38ce..d0f38159a 100644 --- a/spec/controllers/v1/institutions_controller_spec.rb +++ b/spec/controllers/v1/institutions_controller_spec.rb @@ -154,16 +154,6 @@ def preview_body(body) expect(response).to match_response_schema('autocomplete') end - it 'filters by state' do - institution = create(:institution, :start_like_harv, :production_version) - create(:institution, :start_like_harv, :production_version, state: 'MD', physical_state: 'MD') - get(:autocomplete, params: { term: 'harv', state: 'ma' }) - expect(JSON.parse(response.body)['data'].count).to eq(1) - expect(JSON.parse(response.body)['data'][0]['id']).to eq(institution.id) - expect(response.media_type).to eq('application/json') - expect(response).to match_response_schema('autocomplete') - end - it 'filters by student_veteran' do institution = create(:institution, :start_like_harv, :production_version, student_veteran: 'true') create(:institution, :start_like_harv, :production_version) @@ -197,7 +187,6 @@ def preview_body(body) end context 'with search results' do - # need to separate methods in order to pass metrics::AbcSize cop def create_facets_keys_array(facets) [ facets['student_vet_group'].keys, @@ -222,7 +211,6 @@ def check_boolean_facets(facets) create_list(:institution, 2, :in_nyc, :production_version) create(:institution, :production_version, :in_chicago, online_only: true) create(:institution, :production_version, :in_new_rochelle, distance_learning: true) - # adding a non approved institutions row create(:institution, :production_version, :contains_harv, approved: false) end @@ -318,13 +306,6 @@ def check_boolean_facets(facets) expect(response).to match_response_schema('institution_search_results') end - it 'filter by uppercase state returns results' do - get(:index, params: { state: 'NY' }) - expect(JSON.parse(response.body)['data'].count).to eq(3) - expect(response.media_type).to eq('application/json') - expect(response).to match_response_schema('institution_search_results') - end - it 'includes vet_tec_provider institutions' do vet_tec = create(:institution, :production_version, :vet_tec_provider) get(:index, params: { name: 'vet tec' }) @@ -344,28 +325,6 @@ def check_boolean_facets(facets) expect(JSON.parse(response.body)['data'].map { |a| a['attributes']['preferred_provider'] }).to all(eq(true)) end - it 'filter by lowercase state returns results' do - get(:index, params: { state: 'ny' }) - expect(JSON.parse(response.body)['data'].count).to eq(3) - expect(response.media_type).to eq('application/json') - expect(response).to match_response_schema('institution_search_results') - end - - it 'includes state search term in facets' do - get(:index, params: { name: 'chicago', state: 'WY' }) - facets = JSON.parse(response.body)['meta']['facets'] - expect(facets['state']['wy']).not_to be_nil - expect(facets['state']['wy']).to eq(0) - end - - it 'includes country search term in facets' do - get(:index, params: { name: 'chicago', country: 'france' }) - facets = JSON.parse(response.body)['meta']['facets'] - match = facets['country'].select { |c| c['name'] == 'FRANCE' }.first - expect(match).not_to be nil - expect(match['count']).to eq(0) - end - it 'includes boolean facets' do get(:index) facets = JSON.parse(response.body)['meta']['facets'] @@ -378,15 +337,14 @@ def check_boolean_facets(facets) create(:version, :production) end - it 'search returns location results' do + it 'returns location-based search results' do create(:institution, :production_version, :location) - get(:location, params: { latitude: '32.7876', longitude: '-79.9403', distance: '50', tab: 'location' }) + get(:location, params: { latitude: '32.7876', longitude: '-79.9403', distance: '50' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_search_results') end - # New tests for combined name and location search it 'returns filtered results when searching by both name and location' do create(:institution, :production_version, :location, institution: 'HARVARD UNIVERSITY') create(:institution, :production_version, :location, institution: 'BOSTON UNIVERSITY') @@ -435,11 +393,10 @@ def check_boolean_facets(facets) expect(response).to match_response_schema('institution_search_results') end - # rubocop:disable RSpec/ExampleLength - it 'maintains other filters when combining name and location search' do + it 'maintains filters with coordinate-based search' do create(:institution, :production_version, :location, institution: 'HARVARD UNIVERSITY', - student_veteran: true) # Factory uses student_veteran + student_veteran: true) create(:institution, :production_version, :location, institution: 'HARVARD COLLEGE', student_veteran: false) @@ -454,10 +411,9 @@ def check_boolean_facets(facets) results = JSON.parse(response.body)['data'] expect(results.count).to eq(1) - expect(results[0]['attributes']['student_veteran']).to be true # Changed from student_veteran_group to student_veteran + expect(results[0]['attributes']['student_veteran']).to be true expect(response).to match_response_schema('institution_search_results') end - # rubocop:enable RSpec/ExampleLength end context 'with compare results' do @@ -542,7 +498,6 @@ def check_boolean_facets(facets) it 'returns institution children' do school = create(:institution, :in_chicago, :production_version) - child_school = create(:institution, :in_chicago, parent_facility_code_id: school.facility_code, version_id: school.version_id) get(:children, params: { id: school.facility_code }) expect(response.media_type).to eq('application/json')