Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define UserGeo#clear_user_geo. #16004

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions dashboard/app/models/user_geo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@
#

class UserGeo < ActiveRecord::Base
def clear_user_geo
self.ip_address = nil
self.city = nil
self.postal_code = nil
self.latitude = nil
self.longitude = nil

save!
end
end
24 changes: 24 additions & 0 deletions dashboard/test/models/user_geo_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'test_helper'

class UserGeoTest < ActiveSupport::TestCase
test 'clear_user_geo clears data' do
user_geo = UserGeo.create(
user_id: (create :user).id,
ip_address: '127.0.0.1',
city: 'Seattle',
state: 'Washington',
country: 'United States',
postal_code: '98104',
latitude: 2.123,
longitude: 18.123
)
user_geo.clear_user_geo
assert_nil user_geo.ip_address
assert_nil user_geo.city
assert_nil user_geo.postal_code
assert_nil user_geo.latitude
assert_nil user_geo.longitude
refute_nil user_geo.state
refute_nil user_geo.country
end
end