Skip to content

Commit

Permalink
Merge pull request #1454 from adamalbrecht/fix_db_ip_com_state_code_m…
Browse files Browse the repository at this point in the history
…apping

Support state_code in results from db-ip.com
  • Loading branch information
alexreisner authored Jun 8, 2020
2 parents a8bda01 + 2c69a21 commit 466539a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/geocoder/results/db_ip_com.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def district
end

def state_code
@data['stateProv']
@data['stateProvCode']
end
alias_method :state, :state_code

Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/db_ip_com_madison_square_garden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"haw",
"fr"
],
"stateProvCode": "CA",
"stateProv": "California",
"district": "Santa Clara County",
"city": "Mountain View",
Expand All @@ -24,4 +25,4 @@
"isp": "Google Fiber Inc.",
"linkType": "fttx",
"organization": "Google Fiber Inc."
}
}
4 changes: 2 additions & 2 deletions test/unit/lookups/db_ip_com_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def test_result_components
result = Geocoder.search('23.255.240.0').first

assert_equal [37.3861, -122.084], result.coordinates
assert_equal 'Mountain View, California 94043, United States', result.address
assert_equal 'Mountain View, CA 94043, United States', result.address
assert_equal 'Mountain View', result.city
assert_equal 'Santa Clara County', result.district
assert_equal 'California', result.state_code
assert_equal 'CA', result.state_code
assert_equal '94043', result.zip_code
assert_equal 'United States', result.country_name
assert_equal 'US', result.country_code
Expand Down

0 comments on commit 466539a

Please sign in to comment.