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 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | |
3 | -require File.dirname(__FILE__) + '/../test_helper' | |
3 | +require 'test_helper' | |
4 | 4 | |
5 | 5 | class GeoRefTest < ActiveSupport::TestCase |
6 | 6 | |
... | ... | @@ -38,14 +38,17 @@ class GeoRefTest < ActiveSupport::TestCase |
38 | 38 | |
39 | 39 | should 'get lat/lng from address' do |
40 | 40 | Rails.cache.clear |
41 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Salvador, Bahia, BR').returns([-12, -38, :SUCCESS]) if ENV['CI'] | |
41 | 42 | ll = Noosfero::GeoRef.location_to_georef 'Salvador, Bahia, BR' |
42 | 43 | assert_equal [-12, -38, :SUCCESS], round_ll(ll) |
43 | 44 | end |
44 | 45 | |
45 | 46 | should 'get and cache lat/lng from address' do |
46 | 47 | Rails.cache.clear |
48 | + Noosfero::GeoRef.stubs(:location_to_georef).with('Curitiba, Paraná, BR').returns([-25, -49, :SUCCESS]) if ENV['CI'] | |
47 | 49 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
48 | 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 | 52 | ll = Noosfero::GeoRef.location_to_georef 'Curitiba, Paraná, BR' |
50 | 53 | assert_equal [-25, -49, :SUCCESS, :CACHE], round_ll(ll) |
51 | 54 | end |
... | ... | @@ -54,6 +57,7 @@ class GeoRefTest < ActiveSupport::TestCase |
54 | 57 | Rails.cache.clear |
55 | 58 | orig_env = ENV['RAILS_ENV'] |
56 | 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 | 61 | ll = Noosfero::GeoRef.location_to_georef 'Nowhere, Nocountry, XYZ' |
58 | 62 | ENV['RAILS_ENV'] = orig_env # restore value to do not mess with other tests. |
59 | 63 | assert_equal [0, 0, :ZERO_RESULTS], round_ll(ll) | ... | ... |