Commit 438e2c7d1f235ed9240547ed5fb3b3b0a91e5536
1 parent
f22a56c9
Exists in
master
and in
29 other branches
geo_ref: always mock external requests
As talked with terceiro, it is not a good idea to depend on ENV vars
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
test/unit/geo_ref_test.rb
@@ -38,17 +38,17 @@ class GeoRefTest < ActiveSupport::TestCase | @@ -38,17 +38,17 @@ class GeoRefTest < ActiveSupport::TestCase | ||
38 | 38 | ||
39 | should 'get lat/lng from address' do | 39 | should 'get lat/lng from address' do |
40 | Rails.cache.clear | 40 | Rails.cache.clear |
41 | - Noosfero::GeoRef.stubs(:location_to_georef).with('Salvador, Bahia, BR').returns([-12, -38, :SUCCESS]) if ENV['CI'] | 41 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Salvador, Bahia, BR').returns([-12, -38, :SUCCESS]) |
42 | ll = Noosfero::GeoRef.location_to_georef 'Salvador, Bahia, BR' | 42 | ll = Noosfero::GeoRef.location_to_georef 'Salvador, Bahia, BR' |
43 | assert_equal [-12, -38, :SUCCESS], round_ll(ll) | 43 | assert_equal [-12, -38, :SUCCESS], round_ll(ll) |
44 | end | 44 | end |
45 | 45 | ||
46 | should 'get and cache lat/lng from address' do | 46 | should 'get and cache lat/lng from address' do |
47 | Rails.cache.clear | 47 | Rails.cache.clear |
48 | - Noosfero::GeoRef.stubs(:location_to_georef).with('Curitiba, Paraná, BR').returns([-25, -49, :SUCCESS]) if ENV['CI'] | 48 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Curitiba, Paraná, BR').returns([-25, -49, :SUCCESS]) |
49 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' | 49 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
50 | assert_equal [-25, -49, :SUCCESS], round_ll(ll) | 50 | assert_equal [-25, -49, :SUCCESS], round_ll(ll) |
51 | - Noosfero::GeoRef.stubs(:location_to_georef).with('Curitiba, Paraná, BR').returns([-25, -49, :SUCCESS, :CACHE]) if ENV['CI'] | 51 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Curitiba, Paraná, BR').returns([-25, -49, :SUCCESS, :CACHE]) |
52 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' | 52 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
53 | assert_equal [-25, -49, :SUCCESS, :CACHE], round_ll(ll) | 53 | assert_equal [-25, -49, :SUCCESS, :CACHE], round_ll(ll) |
54 | end | 54 | end |
@@ -57,7 +57,7 @@ class GeoRefTest < ActiveSupport::TestCase | @@ -57,7 +57,7 @@ class GeoRefTest < ActiveSupport::TestCase | ||
57 | Rails.cache.clear | 57 | Rails.cache.clear |
58 | orig_env = ENV['RAILS_ENV'] | 58 | orig_env = ENV['RAILS_ENV'] |
59 | ENV['RAILS_ENV'] = 'X' # cancel throw for test mode on process_rest_req. | 59 | ENV['RAILS_ENV'] = 'X' # cancel throw for test mode on process_rest_req. |
60 | - Noosfero::GeoRef.stubs(:location_to_georef).with('Nowhere, Nocountry, XYZ').returns([0, 0, :ZERO_RESULTS]) if ENV['CI'] | 60 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Nowhere, Nocountry, XYZ').returns([0, 0, :ZERO_RESULTS]) |
61 | ll = Noosfero::GeoRef.location_to_georef 'Nowhere, Nocountry, XYZ' | 61 | ll = Noosfero::GeoRef.location_to_georef 'Nowhere, Nocountry, XYZ' |
62 | ENV['RAILS_ENV'] = orig_env # restore value to do not mess with other tests. | 62 | ENV['RAILS_ENV'] = orig_env # restore value to do not mess with other tests. |
63 | assert_equal [0, 0, :ZERO_RESULTS], round_ll(ll) | 63 | assert_equal [0, 0, :ZERO_RESULTS], round_ll(ll) |