From c2f014e59fbb53f46f256917984425e143ba13e3 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Wed, 19 Oct 2016 11:33:21 +0200 Subject: [PATCH] =?UTF-8?q?Add=20"99=20-=20=C3=89tranger"=20in=20Champ=20d?= =?UTF-8?q?=C3=A9partement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/champ.rb | 2 +- .../cassettes/call_geo_api_departements.yml | 70 +++++++++++++++++++ spec/models/champ_shared_example.rb | 6 ++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/cassettes/call_geo_api_departements.yml diff --git a/app/models/champ.rb b/app/models/champ.rb index de33c3fc9..cf4325b0e 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -39,7 +39,7 @@ class Champ < ActiveRecord::Base end def self.departements - JSON.parse(Carto::GeoAPI::Driver.departements).inject([]){|acc, liste| acc.push(liste['code'] + ' - ' + liste['nom']) } + JSON.parse(Carto::GeoAPI::Driver.departements).inject([]){|acc, liste| acc.push(liste['code'] + ' - ' + liste['nom']) }.push('99 - Étranger') end def self.pays diff --git a/spec/fixtures/cassettes/call_geo_api_departements.yml b/spec/fixtures/cassettes/call_geo_api_departements.yml new file mode 100644 index 000000000..c33905578 --- /dev/null +++ b/spec/fixtures/cassettes/call_geo_api_departements.yml @@ -0,0 +1,70 @@ +--- +http_interactions: +- request: + method: get + uri: https://geo.api.gouv.fr/departements?fields=nom + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Wed, 19 Oct 2016 09:31:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Vary: + - Accept-Encoding + - Accept-Encoding + X-Powered-By: + - Express + Access-Control-Allow-Origin: + - "*" + Etag: + - W/"cc1-lXUcIlpPmDfvrGONl0WWsQ" + Strict-Transport-Security: + - max-age=15552000 + Content-Encoding: + - gzip + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA22Wy27bMBBFfyXwJpsKqF96dOfYrZsibow4MFAUXTARGxOQ + xZYSjbpF/yfZ5w/0YyVlpDq0sxTmajg8vJzh1z+9Um9773oTVfbe9O51Lt3H + 237v75suUpUSsQFjRaGkQXAYBH/IKspl9FHYWkZLo3eyvGeqEdStqIomhfsJ + CccnCRfCqFptA1VMlcmbx/sN10nCsCzL4O80CKvm8YE/Z4zaO4T6b4OQQ/ef + YD8guJN7o8G3T4YX2rpqHSgb3WyaZ7LuE+dUFDuRa8Dpk99UlLUoUAHJTTfC + yLJmgUT2Eo5e2CIN2U03POw+uU21Mc3jb65AcC5cSb/Flc275IPJsQGiVgjF + BRTT5tn5KD+/huMGBN0KHMnzidlqish7aqQNliDkmTa5fuAZDAh5pu0dDmBA + xjPTPG9ZOgm/t4YhQvWhSNbRlVYsmXA/qFJVdfMY5CDeuTDAOqQvD5fPCbRz + fQd2SG5zabCrIWnNlfuRzh4S18fmyQhb1MhLXJdF0W5trQqhgtUJ7rLMubEh + ubWxFzosnwQvqxDNkOw+WSNQHqldCbczbHxEbv44/MKh50fE5iWoaURuB+zH + CrJrY9GkLtzFVT8tE5FhKwPgEdFdaUYIzkV89SfnPiK4K/07JDciuYU/s1fY + j8hwIcqg147J0LUTnvqY8A6AjhVEuBB736m7wxsT30JaU2/a+ha6ks5pEBKg + E/K6j8lvoc2d2gi05jEhniYmvc9uUuxogDHpfXadBBWR2bViQTGJXQfAYgJb + inaYujEgFEwbE9nS7r1mFnaimNyWe9M8lc2Tn7X/vcd8rwzl7p9uRzE5Ium1 + UW7SiIIXKybUC7ePmw2fGzGpel8cx8n1eEbGJHsw1UqEYzQh4UPwFVsnhL0S + 3lzdbhNSXomdVgwGLbF97JxISHXpXjAgnpDkSvpLdzqHEyI8iLzzwwuWEOSX + nSxcLi5EjjNpf0Wr1sGUkOZKbznQUmK8dSt3eFKy86FXe09KiGuBaZeS4FrY + +yK4synprWWZO/ticfJbO/exZ6TkdrDHiYTU1rp6IJCUzL6EMzQlrFtp3LvU + N+uzXJ5dyOK7NmjOGeG9r6owU3bcGdur3h5zt88s8GDrk5Vr0XU0k+55AF0I + s/CpjoySBUCFk5yHTSkj07kVuSy0/cFiguvi0tfujRJMsSy4M3O7F8FmkmAW + irOb5smWiq/kLAnauNjrmi/YzF+Jb/8A5ygzwMEMAAA= + http_version: + recorded_at: Wed, 19 Oct 2016 09:31:33 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/models/champ_shared_example.rb b/spec/models/champ_shared_example.rb index bf70d0012..fdef3929a 100644 --- a/spec/models/champ_shared_example.rb +++ b/spec/models/champ_shared_example.rb @@ -35,4 +35,10 @@ shared_examples 'champ_spec' do it { is_expected.to eq 'typeahead' } end end + + describe '.departement', vcr: {cassette_name: 'call_geo_api_departements'} do + subject { Champ.departements } + + it { expect(subject).to include '99 - Étranger' } + end end \ No newline at end of file