Commit f22a56c9b858ceb72378180013a86dd2d7fa2e7d
1 parent
1d694250
Exists in
staging
and in
41 other branches
geo_ref: mock when CI env is used
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
test/unit/geo_ref_test.rb
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | 2 | ||
3 | -require File.dirname(__FILE__) + '/../test_helper' | 3 | +require 'test_helper' |
4 | 4 | ||
5 | class GeoRefTest < ActiveSupport::TestCase | 5 | class GeoRefTest < ActiveSupport::TestCase |
6 | 6 | ||
@@ -38,14 +38,17 @@ class GeoRefTest < ActiveSupport::TestCase | @@ -38,14 +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 | ll = Noosfero::GeoRef.location_to_georef 'Salvador, Bahia, BR' | 42 | ll = Noosfero::GeoRef.location_to_georef 'Salvador, Bahia, BR' |
42 | assert_equal [-12, -38, :SUCCESS], round_ll(ll) | 43 | assert_equal [-12, -38, :SUCCESS], round_ll(ll) |
43 | end | 44 | end |
44 | 45 | ||
45 | should 'get and cache lat/lng from address' do | 46 | should 'get and cache lat/lng from address' do |
46 | 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'] | ||
47 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' | 49 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
48 | 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'] | ||
49 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' | 52 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
50 | assert_equal [-25, -49, :SUCCESS, :CACHE], round_ll(ll) | 53 | assert_equal [-25, -49, :SUCCESS, :CACHE], round_ll(ll) |
51 | end | 54 | end |
@@ -54,6 +57,7 @@ class GeoRefTest < ActiveSupport::TestCase | @@ -54,6 +57,7 @@ class GeoRefTest < ActiveSupport::TestCase | ||
54 | Rails.cache.clear | 57 | Rails.cache.clear |
55 | orig_env = ENV['RAILS_ENV'] | 58 | orig_env = ENV['RAILS_ENV'] |
56 | 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'] | ||
57 | ll = Noosfero::GeoRef.location_to_georef 'Nowhere, Nocountry, XYZ' | 61 | ll = Noosfero::GeoRef.location_to_georef 'Nowhere, Nocountry, XYZ' |
58 | 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. |
59 | assert_equal [0, 0, :ZERO_RESULTS], round_ll(ll) | 63 | assert_equal [0, 0, :ZERO_RESULTS], round_ll(ll) |