Skip to content

Commit

Permalink
remove unneeded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GcioGregg committed Dec 20, 2024
1 parent b811ffd commit d77038f
Showing 1 changed file with 5 additions and 50 deletions.
55 changes: 5 additions & 50 deletions spec/controllers/v1/institutions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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' })
Expand All @@ -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']
Expand All @@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit d77038f

Please sign in to comment.