Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from apneadiving/mongoid_adapter
Mongoid adapter
- Loading branch information
Showing
12 changed files
with
184 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
if RUBY_VERSION == "1.9.3" | ||
|
||
require 'mongoid' | ||
|
||
class Place | ||
include Mongoid::Document | ||
include Gmaps4rails::ActsAsGmappable | ||
|
||
acts_as_gmappable :address => :address, :position => :pos | ||
|
||
field :pos, :type => Array | ||
field :address, :type => String | ||
field :gmaps, :type => Boolean | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FactoryGirl.define do | ||
factory :place do | ||
|
||
trait :paris do | ||
address "Paris, France" | ||
end | ||
|
||
trait :invalid do | ||
address "home" | ||
end | ||
|
||
address "Toulon, France" | ||
|
||
factory :place_paris, :traits => [:paris] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
if RUBY_VERSION == "1.9.3" | ||
|
||
require 'spec_helper' | ||
|
||
include Geocoding | ||
|
||
set_gmaps4rails_options! | ||
|
||
# Mongoid 3.x only | ||
require 'mongoid' | ||
require 'moped' | ||
|
||
Mongoid.configure do |config| | ||
config.connect_to('mongoid_geo_test') | ||
end | ||
|
||
describe Gmaps4rails::ActsAsGmappable do | ||
|
||
let(:place) { Factory(:place) } | ||
let(:invalid_place) { Factory.build(:invalid_place) } | ||
|
||
before(:each) do | ||
Geocoding.stub_geocoding | ||
end | ||
|
||
context "standard configuration, valid place" do | ||
it "should save longitude and latitude to the customized position array" do | ||
set_gmaps4rails_options!(:position => 'location') | ||
place.pos.should_not be_nil | ||
place.should have_same_position_as TOULON | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters