Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

My Rails app geocodes users' IP when they are created and also when they update their data only if they change their city. The geocoding is slowing down my tests ridiculously.

This seems to me to be a poor way to avoid endless geocoding when running tests but I am unsure of a better way to do this.

   if Rails.env == 'production' || Rails.env == 'development'

       after_save :geocode, if: ->(user){ user.ip_address.present? and user.ip_address_changed? }

   end
share|improve this question
1  
1) Using Rails.env.test? is cleaner, 2) but don't do that either! Instead, look into mocking and stubbing. I'd elaborate, but this question may be better for StackOverflow. There's not a lot a code to review, and you already know you're looking for a different solution altogether. –  Flambino Jun 21 at 21:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.