Testing ActiveRecord Custom Primary Key Implementation in geocoder
This test suite validates Geocoder’s integration with ActiveRecord models, specifically focusing on custom primary key handling. It ensures proper geocoding functionality when working with non-standard database configurations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
alexreisner/geocoder
test/unit/active_record_test.rb
# encoding: utf-8
require 'test_helper'
class ActiveRecordTest < GeocoderTestCase
def test_exclude_condition_when_model_has_a_custom_primary_key
venue = PlaceWithCustomPrimaryKey.new(*geocoded_object_params(:msg))
# just call private method directly so we don't have to stub .near scope
conditions = venue.class.send(:add_exclude_condition, ["fake_condition"], venue)
assert_match( /#{PlaceWithCustomPrimaryKey.primary_key}/, conditions.join)
end
end