Sha256: 979470bca08b3208dea71842067639cdff93663890f19dcae8af164adedef018

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

require 'rails_helper'

RSpec.describe UserLocation, type: :model do
  include LocationHelper
  before :all do
    create_test_airport
  end

  let(:user) { User.make! }

  it "validates the detectable type" do 
    ul = UserLocation.new(user: user, location: Location.last, detectable: Location.last, coords: rand_coords)
    ul.valid?.should == false
    ul.errors[:detectable_type].should == ["is not included in the list"]
  end

  it "logs a user's locations by beacon" do
    beacon = LocationBeacon.last
    user.user_locations.build(location: beacon.location, detectable: beacon, coords: rand_coords)
    user.save.should == true
    p2 = user.user_locations.build(location: beacon.location, detectable: beacon, coords: rand_coords)
    user.save.should == true
    user.user_locations.first.should == p2
  end

  it "logs a user's beacon location by gps" do
    gps = LocationGps.last
    user.user_locations.build(location: gps.location, detectable: gps, coords: rand_coords)
    user.save.should == true
    p2 = user.user_locations.build(location: gps.location, detectable: gps, coords: rand_coords)
    user.save.should == true
    user.user_locations.first.should == p2
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
introspective_grape-0.3.2 spec/models/user_location_spec.rb
introspective_grape-0.3.1 spec/models/user_location_spec.rb
introspective_grape-0.3.0 spec/models/user_location_spec.rb
introspective_grape-0.2.9 spec/models/user_location_spec.rb
introspective_grape-0.2.8 spec/models/user_location_spec.rb
introspective_grape-0.2.7 spec/models/user_location_spec.rb
introspective_grape-0.2.6 spec/models/user_location_spec.rb
introspective_grape-0.2.5 spec/models/user_location_spec.rb
introspective_grape-0.2.4 spec/models/user_location_spec.rb
introspective_grape-0.2.3 spec/models/user_location_spec.rb
introspective_grape-0.2.2 spec/models/user_location_spec.rb
introspective_grape-0.2.0 spec/models/user_location_spec.rb
introspective_grape-0.1.9 spec/models/user_location_spec.rb