diff --git a/app/models/data_set.rb b/app/models/data_set.rb index 025baa63..bd13d34c 100644 --- a/app/models/data_set.rb +++ b/app/models/data_set.rb @@ -39,14 +39,14 @@ def number_of_places # location - a Point object representing the centre of the search area # distance (optional) - a Distance object representing the maximum distance # limit (optional) - a maximum number of results to return - # authority_codes (optional) - array of GSS/SNAC codes to scope the results to a local authority + # authority_code (optional) - array of GSS codes to scope the results to a local authority # # Returns: # an array of Place objects - def places_near(location, distance = nil, limit = nil, authority_codes = []) + def places_near(location, distance = nil, limit = nil, authority_code = nil) loc_string = "'SRID=4326;POINT(#{location.longitude} #{location.latitude})'::geometry" query = places - query = query.where(gss: authority_codes) if authority_codes.any? + query = query.where(gss: authority_code) if authority_code query = query.limit(limit) if limit query = query.where(Place.arel_table[:location].st_distance(location).lt(distance.in(:meters))) if distance query = query.reorder(Arel.sql("location <-> #{loc_string}, RANDOM()")) @@ -60,24 +60,24 @@ def places_for_postcode(postcode, distance = nil, limit = nil, local_authority_s location = RGeo::Geographic.spherical_factory.point(location_data["longitude"], location_data["latitude"]) return places_near(location, distance, limit) if service.location_match_type == "nearest" - authority_codes = if local_authority_slug - authority_codes_for_local_authority_slug(local_authority_slug) - else - appropriate_authority_codes_for_postcode(postcode) - end - return [] unless authority_codes + authority_code = if local_authority_slug + authority_code_for_local_authority_slug(local_authority_slug) + else + appropriate_authority_code_for_postcode(postcode) + end + return [] unless authority_code - places_near(location, distance, limit, authority_codes) + places_near(location, distance, limit, authority_code) end - def authority_codes_for_local_authority_slug(local_authority_slug) + def authority_code_for_local_authority_slug(local_authority_slug) local_authorities_response = GdsApi.local_links_manager.local_authority(local_authority_slug) local_authority = local_authorities_response.to_hash["local_authorities"].find do |la| [service.local_authority_hierarchy_match_type, "unitary"].include?(la["tier"]) end - gss_and_snac(local_authority) + local_authority["gss"] end def appropriate_authority_for_local_custodian_code(local_custodian_code) @@ -87,7 +87,7 @@ def appropriate_authority_for_local_custodian_code(local_custodian_code) end end - def appropriate_authority_codes_for_postcode(postcode) + def appropriate_authority_code_for_postcode(postcode) local_custodian_codes = GdsApi.locations_api.local_custodian_code_for_postcode(postcode) return nil if local_custodian_codes.compact.empty? @@ -106,19 +106,11 @@ def appropriate_authority_codes_for_postcode(postcode) end authority_hash = appropriate_authority_for_local_custodian_code(local_custodian_codes.first) # there should be 0-1, return first or nil - gss_and_snac(authority_hash) + authority_hash["gss"] rescue GdsApi::HTTPNotFound nil end - def gss_and_snac(authority_hash) - # Not all LAs have SNACs now, so we return an array including - # GSS and SNAC (or whichever they have) - return [] unless authority_hash - - [authority_hash["gss"], authority_hash["snac"]].compact - end - def duplicating? state == "duplicating" end diff --git a/app/models/place.rb b/app/models/place.rb index 705d9974..bf0ecf77 100644 --- a/app/models/place.rb +++ b/app/models/place.rb @@ -127,7 +127,7 @@ def self.parameters_from_hash(data_set, row) fax: row["fax"], text_phone: row["text_phone"], source_address: row["source_address"] || "#{row['address1']} #{row['address2']} #{row['town']} #{row['postcode']}", - gss: row["gss"] || row["snac"], + gss: row["gss"], } location_parameters = if row["lng"] && row["lat"] { override_lng: row["lng"], override_lat: row["lat"] } diff --git a/features/data_sets.feature b/features/data_sets.feature index 59be38f0..8f37b8c1 100644 --- a/features/data_sets.feature +++ b/features/data_sets.feature @@ -129,17 +129,3 @@ Feature: Managing data sets And I go to the page for the "Register Offices" service Then I should see that the current service has 2 missing GSS codes - -Scenario: Creating a new data set for a service with local authority lookup with a CSV file with SNAC codes - Given I have previously created a service with the following attributes: - | name | Register Offices | - | location_match_type | Local authority | - - When I go to the page for the "Register Offices" service - And I upload a new data set with a CSV with a SNAC column instead of GSS - - When background processing has completed - And I activate the most recent data set for the "Register Offices" service - And I go to the page for the "Register Offices" service - - Then I should see that the current service has 0 missing GSS codes diff --git a/features/step_definitions/data_set_steps.rb b/features/step_definitions/data_set_steps.rb index 8e0c3b14..f1a178f4 100644 --- a/features/step_definitions/data_set_steps.rb +++ b/features/step_definitions/data_set_steps.rb @@ -27,13 +27,6 @@ end end -When(/^I upload a new data set with a CSV with a SNAC column instead of GSS$/) do - within "#new-data" do - attach_file "Data file", Rails.root.join("features/support/data/register-offices-with-snac-codes.csv") - click_button "Create Data set" - end -end - When(/^I upload a new data set with a CSV with missing GSS codes$/) do within "#new-data" do attach_file "Data file", Rails.root.join("features/support/data/register-offices-with-missing-gss-codes.csv") diff --git a/features/support/data/register-offices-with-snac-codes.csv b/features/support/data/register-offices-with-snac-codes.csv deleted file mode 100644 index fd9896d3..00000000 --- a/features/support/data/register-offices-with-snac-codes.csv +++ /dev/null @@ -1,4 +0,0 @@ -name,address1,address2,town,postcode,access_notes,general_notes,url,lat,lng,phone,fax,text_phone,snac -Town Hall,Cauldwell Street,Bedford,,MK42 9AP,,,http://www.bedford.gov.uk/advice_and_benefits/registration_service.aspx,52.1327584352089,-0.4702813074674147,,,,00KB -County Hall,Walton Street,Aylesbury,,HP20 1XF,,,http://www.buckscc.gov.uk/registration/index.stm,51.81525988351161,-0.8119554673823927,,,,00KB -Shire Hall,Castle Hill,Cambridge,,CB3 0AP,,,http://www.cambridgeshire.gov.uk/community/bmd/,52.2128132777458,0.11402791296760088,,,,00KB diff --git a/lib/tasks/once_off/convert_snac_to_gss.rake b/lib/tasks/once_off/convert_snac_to_gss.rake deleted file mode 100644 index 3d2ec467..00000000 --- a/lib/tasks/once_off/convert_snac_to_gss.rake +++ /dev/null @@ -1,43 +0,0 @@ -namespace :once_off do - desc "Creates duplicate datasets with GSS codes instead of SNACs for local authority data_sets" - task convert_snac_to_gss: [:environment] do - snac_to_gss_lookup = load_snac_to_gss_lookup - - affected_services.each do |service| - puts("INFO: Updating Service: #{service.slug}") - duplicate = service.active_data_set.duplicate - - duplicate.change_notes += ", then updated by once_off:convert_snac_to_gss task" - duplicate.save! - - duplicate.places.each do |place| - next if already_gss?(place.gss) - - snac = place.gss - gss = snac_to_gss_lookup[snac] - if gss.nil? - puts(" - ERROR: Failed to update SNAC #{snac} for #{service.slug}") - else - place.gss = gss - place.save! - end - end - end - end -end - -def load_snac_to_gss_lookup - lookup_cache = {} - CSV.foreach("lib/tasks/once_off/snac_to_gss_translation.csv") do |row| - lookup_cache[row[0]] = row[1] - end - lookup_cache -end - -def affected_services - Service.where(location_match_type: "local_authority") -end - -def already_gss?(code) - code.length > 4 -end diff --git a/lib/tasks/once_off/snac_to_gss_translation.csv b/lib/tasks/once_off/snac_to_gss_translation.csv deleted file mode 100644 index f210d673..00000000 --- a/lib/tasks/once_off/snac_to_gss_translation.csv +++ /dev/null @@ -1,407 +0,0 @@ -snac,gss -11,E06000060 -12,E10000003 -16,E10000006 -17,E10000007 -18,E10000008 -21,E10000011 -22,E10000012 -23,E10000013 -24,E10000014 -26,E10000015 -29,E10000016 -30,E10000017 -31,E10000018 -32,E10000019 -33,E10000020 -34,E10000021 -36,E10000023 -37,E10000024 -38,E10000025 -40,E10000027 -41,E10000028 -42,E10000029 -43,E10000030 -44,E10000031 -45,E10000032 -47,E10000034 -00AA,E09000001 -00AB,E09000002 -00AC,E09000003 -00AD,E09000004 -00AE,E09000005 -00AF,E09000006 -00AG,E09000007 -00AH,E09000008 -00AJ,E09000009 -00AK,E09000010 -00AL,E09000011 -00AM,E09000012 -00AN,E09000013 -00AP,E09000014 -00AQ,E09000015 -00AR,E09000016 -00AS,E09000017 -00AT,E09000018 -00AU,E09000019 -00AW,E09000020 -00AX,E09000021 -00AY,E09000022 -00AZ,E09000023 -00BA,E09000024 -00BB,E09000025 -00BC,E09000026 -00BD,E09000027 -00BE,E09000028 -00BF,E09000029 -00BG,E09000030 -00BH,E09000031 -00BJ,E09000032 -00BK,E09000033 -00BL,E08000001 -00BM,E08000002 -00BN,E08000003 -00BP,E08000004 -00BQ,E08000005 -00BR,E08000006 -00BS,E08000007 -00BT,E08000008 -00BU,E08000009 -00BW,E08000010 -00BX,E08000011 -00BY,E08000012 -00BZ,E08000013 -00CA,E08000014 -00CB,E08000015 -00CC,E08000016 -00CE,E08000017 -00CF,E08000018 -00CG,E08000019 -00CH,E08000037 -00CJ,E08000021 -00CK,E08000022 -00CL,E08000023 -00CM,E08000024 -00CN,E08000025 -00CQ,E08000026 -00CR,E08000027 -00CS,E08000028 -00CT,E08000029 -00CU,E08000030 -00CW,E08000031 -00CX,E08000032 -00CY,E08000033 -00CZ,E08000034 -00DA,E08000035 -00DB,E08000036 -00EB,E06000001 -00EC,E06000002 -00EE,E06000003 -00EF,E06000004 -00EH,E06000005 -00EJ,E06000047 -00EM,E06000057 -00EQ,E06000049 -00ET,E06000006 -00EU,E06000007 -00EW,E06000050 -00EX,E06000008 -00EY,E06000009 -00FA,E06000010 -00FB,E06000011 -00FC,E06000012 -00FD,E06000013 -00FF,E06000014 -00FK,E06000015 -00FN,E06000016 -00FP,E06000017 -00FY,E06000018 -00GA,E06000019 -00GF,E06000020 -00GG,E06000051 -00GL,E06000021 -00HA,E06000022 -00HB,E06000023 -00HC,E06000024 -00HD,E06000025 -00HE,E06000052 -00HF,E06000053 -00HG,E06000026 -00HH,E06000027 -00HN,E06000028 -00HP,E06000029 -00HX,E06000030 -00HY,E06000054 -00JA,E06000031 -00KA,E06000032 -00KB,E06000055 -00KC,E06000056 -00KF,E06000033 -00KG,E06000034 -00LC,E06000035 -00MA,E06000036 -00MB,E06000037 -00MC,E06000038 -00MD,E06000039 -00ME,E06000040 -00MF,E06000041 -00MG,E06000042 -00ML,E06000043 -00MR,E06000044 -00MS,E06000045 -00MW,E06000046 -00NA,W06000001 -00NC,W06000002 -00NE,W06000003 -00NG,W06000004 -00NJ,W06000005 -00NL,W06000006 -00NN,W06000023 -00NQ,W06000008 -00NS,W06000009 -00NU,W06000010 -00NX,W06000011 -00NZ,W06000012 -00PB,W06000013 -00PD,W06000014 -00PF,W06000016 -00PH,W06000024 -00PK,W06000018 -00PL,W06000019 -00PM,W06000020 -00PP,W06000021 -00PR,W06000022 -00PT,W06000015 -00QA,S12000033 -00QB,S12000034 -00QC,S12000041 -00QD,S12000035 -00QE,S12000026 -00QF,S12000005 -00QG,S12000039 -00QH,S12000006 -00QJ,S12000042 -00QK,S12000008 -00QL,S12000045 -00QM,S12000010 -00QN,S12000011 -00QP,S12000036 -00QQ,S12000014 -00QR,S12000015 -00QS,S12000046 -00QT,S12000017 -00QU,S12000018 -00QW,S12000019 -00QX,S12000020 -00QY,S12000021 -00QZ,S12000044 -00RA,S12000023 -00RB,S12000024 -00RC,S12000038 -00RD,S12000027 -00RE,S12000028 -00RF,S12000029 -00RG,S12000030 -00RH,S12000040 -00RJ,S12000013 -11UB,E07000004 -11UC,E07000005 -11UE,E07000006 -11UF,E07000007 -12UB,E07000008 -12UC,E07000009 -12UD,E07000010 -12UE,E07000011 -12UG,E07000012 -16UB,E07000026 -16UC,E07000027 -16UD,E07000028 -16UE,E07000029 -16UF,E07000030 -16UG,E07000031 -17UB,E07000032 -17UC,E07000033 -17UD,E07000034 -17UF,E07000035 -17UG,E07000036 -17UH,E07000037 -17UJ,E07000038 -17UK,E07000039 -18UB,E07000040 -18UC,E07000041 -18UD,E07000042 -18UE,E07000043 -18UG,E07000044 -18UH,E07000045 -18UK,E07000046 -18UL,E07000047 -19UC,E07000048 -19UD,E07000049 -19UE,E07000050 -19UG,E07000051 -19UH,E07000052 -19UJ,E07000053 -21UC,E07000061 -21UD,E07000062 -21UF,E07000063 -21UG,E07000064 -21UH,E07000065 -22UB,E07000066 -22UC,E07000067 -22UD,E07000068 -22UE,E07000069 -22UF,E07000070 -22UG,E07000071 -22UH,E07000072 -22UJ,E07000073 -22UK,E07000074 -22UL,E07000075 -22UN,E07000076 -22UQ,E07000077 -23UB,E07000078 -23UC,E07000079 -23UD,E07000080 -23UE,E07000081 -23UF,E07000082 -23UG,E07000083 -24UB,E07000084 -24UC,E07000085 -24UD,E07000086 -24UE,E07000087 -24UF,E07000088 -24UG,E07000089 -24UH,E07000090 -24UJ,E07000091 -24UL,E07000092 -24UN,E07000093 -24UP,E07000094 -26UB,E07000095 -26UC,E07000096 -26UD,E07000242 -26UE,E07000098 -26UF,E07000099 -26UG,E07000240 -26UH,E07000243 -26UJ,E07000102 -26UK,E07000103 -26UL,E07000241 -29UB,E07000105 -29UC,E07000106 -29UD,E07000107 -29UE,E07000108 -29UG,E07000109 -29UH,E07000110 -29UK,E07000111 -29UL,E07000112 -29UM,E07000113 -29UN,E07000114 -29UP,E07000115 -29UQ,E07000116 -30UD,E07000117 -30UE,E07000118 -30UF,E07000119 -30UG,E07000120 -30UH,E07000121 -30UJ,E07000122 -30UK,E07000123 -30UL,E07000124 -30UM,E07000125 -30UN,E07000126 -30UP,E07000127 -30UQ,E07000128 -31UB,E07000129 -31UC,E07000130 -31UD,E07000131 -31UE,E07000132 -31UG,E07000133 -31UH,E07000134 -31UJ,E07000135 -32UB,E07000136 -32UC,E07000137 -32UD,E07000138 -32UE,E07000139 -32UF,E07000140 -32UG,E07000141 -32UH,E07000142 -33UB,E07000143 -33UC,E07000144 -33UD,E07000145 -33UE,E07000146 -33UF,E07000147 -33UG,E07000148 -33UH,E07000149 -34UB,E07000150 -34UC,E07000151 -34UD,E07000152 -34UE,E07000153 -34UF,E07000154 -34UG,E07000155 -34UH,E07000156 -36UB,E07000163 -36UC,E07000164 -36UD,E07000165 -36UE,E07000166 -36UF,E07000167 -36UG,E07000168 -36UH,E07000169 -37UB,E07000170 -37UC,E07000171 -37UD,E07000172 -37UE,E07000173 -37UF,E07000174 -37UG,E07000175 -37UJ,E07000176 -38UB,E07000177 -38UC,E07000178 -38UD,E07000179 -38UE,E07000180 -38UF,E07000181 -40UB,E07000187 -40UC,E07000188 -40UD,E07000189 -40UE,E07000190 -40UF,E07000191 -41UB,E07000192 -41UC,E07000193 -41UD,E07000194 -41UE,E07000195 -41UF,E07000196 -41UG,E07000197 -41UH,E07000198 -41UK,E07000199 -42UB,E07000200 -42UC,E07000201 -42UD,E07000202 -42UE,E07000203 -42UF,E07000204 -42UG,E07000205 -42UH,E07000206 -43UB,E07000207 -43UC,E07000208 -43UD,E07000209 -43UE,E07000210 -43UF,E07000211 -43UG,E07000212 -43UH,E07000213 -43UJ,E07000214 -43UK,E07000215 -43UL,E07000216 -43UM,E07000217 -44UB,E07000218 -44UC,E07000219 -44UD,E07000220 -44UE,E07000221 -44UF,E07000222 -45UB,E07000223 -45UC,E07000224 -45UD,E07000225 -45UE,E07000226 -45UF,E07000227 -45UG,E07000228 -45UH,E07000229 -47UB,E07000234 -47UC,E07000235 -47UD,E07000236 -47UE,E07000237 -47UF,E07000238 -47UG,E07000239 \ No newline at end of file diff --git a/test/integration/places_api_test.rb b/test/integration/places_api_test.rb index 996272d7..ca5b4807 100644 --- a/test/integration/places_api_test.rb +++ b/test/integration/places_api_test.rb @@ -164,7 +164,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place1 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "18UK", + gss: "E12345678", latitude: 51.0519276, longitude: -4.1907002, name: "John's Of Appledore", @@ -172,7 +172,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place2 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "18UK", + gss: "E12345678", latitude: 51.053834, longitude: -4.191422, name: "Susie's Tea Rooms", @@ -180,7 +180,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place3 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "00AG", + gss: "E12345679", latitude: 51.500728, longitude: -0.124626, name: "Palace of Westminster", @@ -188,7 +188,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place4 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "00AG", + gss: "E12345679", latitude: 51.51837458322272, longitude: -0.12133586354538765, name: "FreeState Coffee", @@ -196,7 +196,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place5 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "18", + gss: "E12345680", latitude: 51.05420, longitude: -4.19096, name: "The Coffee Cabin", @@ -204,7 +204,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest @place6 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "18", + gss: "E12345680", latitude: 51.05289, longitude: -4.19111, name: "The Quay Restaurant and Gallery", @@ -254,9 +254,9 @@ class PlacesAPITest < ActionDispatch::IntegrationTest { "address" => "House 3", "local_custodian_code" => "3" }, ], ) - stub_local_links_manager_has_a_local_authority("achester", local_custodian_code: 1, snac: "18UK") - stub_local_links_manager_has_a_local_authority("beechester", local_custodian_code: 2, snac: "00AG") - stub_local_links_manager_has_a_local_authority("ceechester", local_custodian_code: 3, snac: "18") + stub_local_links_manager_has_a_local_authority("achester", local_custodian_code: 1, gss: "E12345678") + stub_local_links_manager_has_a_local_authority("beechester", local_custodian_code: 2, gss: "E12345679") + stub_local_links_manager_has_a_local_authority("ceechester", local_custodian_code: 3, gss: "E12345680") stub_local_links_manager_does_not_have_an_authority("deechester") end @@ -295,7 +295,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest should "return the district places in order of nearness, not the county ones for postcodes in a county+district council hierarchy" do stub_locations_api_has_location("EX39 1QS", [{ "latitude" => 51.05318361810428, "longitude" => -4.191071523498792, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_district_and_county_local_authority("my-district", "my-county", district_snac: "18UK", county_snac: "18", local_custodian_code: 1234) + stub_local_links_manager_has_a_district_and_county_local_authority("my-district", "my-county", district_gss: "E12345678", county_gss: "E12345680", local_custodian_code: 1234) get "/places/#{@service.slug}.json?postcode=EX39+1QS" data = JSON.parse(last_response.body) @@ -306,7 +306,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest should "return all the places in order of nearness for postcodes not in a county+district council hierarchy" do stub_locations_api_has_location("WC2B 6NH", [{ "latitude" => 51.51695975170424, "longitude" => -0.12058693935709164, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_local_authority("county1", country_name: "England", snac: "00AG", local_custodian_code: 1234) + stub_local_links_manager_has_a_local_authority("county1", country_name: "England", gss: "E12345679", local_custodian_code: 1234) get "/places/#{@service.slug}.json?postcode=WC2B+6NH" data = JSON.parse(last_response.body) @@ -323,7 +323,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest should "only return the county results in order of nearness, not the district ones for postcodes in a county+district council hierarchy" do stub_locations_api_has_location("EX39 1QS", [{ "latitude" => 51.05318361810428, "longitude" => -4.191071523498792, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_district_and_county_local_authority("my-district", "my-county", district_snac: "18UK", county_snac: "18", local_custodian_code: 1234) + stub_local_links_manager_has_a_district_and_county_local_authority("my-district", "my-county", district_gss: "E12345678", county_gss: "E12345680", local_custodian_code: 1234) get "/places/#{@service.slug}.json?postcode=EX39+1QS" data = JSON.parse(last_response.body) @@ -334,7 +334,7 @@ class PlacesAPITest < ActionDispatch::IntegrationTest should "return all the places in order of nearness for postcodes not in a county+district council hierarchy" do stub_locations_api_has_location("WC2B 6NH", [{ "latitude" => 51.51695975170424, "longitude" => -0.12058693935709164, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_local_authority("county1", country_name: "England", snac: "00AG", local_custodian_code: 1234) + stub_local_links_manager_has_a_local_authority("county1", country_name: "England", gss: "E12345679", local_custodian_code: 1234) get "/places/#{@service.slug}.json?postcode=WC2B+6NH" data = JSON.parse(last_response.body) @@ -343,23 +343,6 @@ class PlacesAPITest < ActionDispatch::IntegrationTest assert_equal @place3.name, data["places"][1]["name"] end end - - context "when the service is missing a SNAC" do - setup do - @service.update(local_authority_hierarchy_match_type: Service::LOCAL_AUTHORITY_COUNTY_MATCH) - end - - should "only return the county results in order of nearness, not the district ones for postcodes in a county+district council hierarchy" do - stub_locations_api_has_location("EX39 1QS", [{ "latitude" => 51.05318361810428, "longitude" => -4.191071523498792, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_local_authority("my-county", snac: nil, gss: "E060000063", local_custodian_code: 1234) - - get "/places/#{@service.slug}.json?postcode=EX39+1QS" - data = JSON.parse(last_response.body) - assert_equal 2, data["places"].length - assert_equal @place8.name, data["places"][0]["name"] - assert_equal @place7.name, data["places"][1]["name"] - end - end end end end diff --git a/test/unit/data_set_test.rb b/test/unit/data_set_test.rb index 9a30e85d..3ae12d5f 100644 --- a/test/unit/data_set_test.rb +++ b/test/unit/data_set_test.rb @@ -450,7 +450,7 @@ class DataSetTest < ActiveSupport::TestCase @place1 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "18UK", + gss: "E12345678", postcode: "EX39 1QS", latitude: 51.05318361810428, longitude: -4.191071523498792, @@ -468,7 +468,7 @@ class DataSetTest < ActiveSupport::TestCase @place3 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "00AG", + gss: "E12345679", postcode: "WC2B 6NH", latitude: 51.51695975170424, longitude: -0.12058693935709164, @@ -477,7 +477,7 @@ class DataSetTest < ActiveSupport::TestCase @place4 = FactoryBot.create( :place, service_slug: @service.slug, - gss: "00AG", + gss: "E12345679", postcode: "WC1B 5HA", latitude: 51.51837458322272, longitude: -0.12133586354538765, @@ -485,22 +485,22 @@ class DataSetTest < ActiveSupport::TestCase ) end - should "return places in the same district/unitary authority as the postcode, matching by GSS or SNAC" do + should "return places in the same district/unitary authority as the postcode, matching by GSS" do stub_locations_api_has_location("EX39 1LH", [{ "latitude" => 51.0413792674, "longitude" => -4.23640704632, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_local_authority("county1", country_name: "England", gss: "E12345678", snac: "18UK", local_custodian_code: 1234) + stub_local_links_manager_has_a_local_authority("county1", country_name: "England", gss: "E12345678", local_custodian_code: 1234) place_names = @data_set.places_for_postcode("EX39 1LH").map(&:name) assert_equal ["John's Of Appledore", "Susie's Tea Rooms"], place_names end should "return multiple places in order of nearness if there are more than one in the district" do stub_locations_api_has_location("WC2B 6NH", [{ "latitude" => 51.51695975170424, "longitude" => -0.12058693935709164, "local_custodian_code" => 1234 }]) - stub_local_links_manager_has_a_local_authority("county1", country_name: "England", snac: "00AG", local_custodian_code: 1234) + stub_local_links_manager_has_a_local_authority("county1", country_name: "England", gss: "E12345679", local_custodian_code: 1234) place_names = @data_set.places_for_postcode("WC2B 6NH").map(&:name) assert_equal ["Aviation House", "FreeState Coffee"], place_names end - should "return empty array if no SNAC/GSS can be found for the postcode" do + should "return empty array if no GSS can be found for the postcode" do stub_locations_api_has_location("BT1 5GS", [{ "latitude" => 21.54, "longitude" => -5.93 }]) assert_equal [], @data_set.places_for_postcode("BT1 5GS").to_a