Sha256: 178c2bedf494f8ed9a7c5c3d6eb7f90d5f1ad86f6681e3271ca80651feca934d

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe G5Updatable::Location do
  describe "validations" do
    subject(:location) { G5Updatable::Location.new }

    it { expect(location).to validate_presence_of(:uid) }
    it { expect(location).to validate_presence_of(:urn) }
    it { expect(location).to validate_presence_of(:client_uid) }
  end

  it_behaves_like "a model with first-class properties" do
    let(:instance_factory_name) { :location }
  end

  it_behaves_like "a model that uses its URN as its parameter" do
    let(:instance_factory_name) { :location }
  end

  describe "#client" do
    let(:client) { FactoryGirl.create(:client) }
    let(:location) { FactoryGirl.create(:location, client_uid: client.uid) }
    subject { location.client }

    it { should eq(client) }
  end


  context "scopes" do
    let!(:location) { FactoryGirl.create(:location) }
    let!(:location2) {FactoryGirl.create(:location, client_uid: "something_else") }

    describe ".by_client_uid" do
      it "returns locations" do
        expect(described_class.by_client_uid(location.client_uid)).to eq [location]
      end  
    end  

    describe ".max_updated_at" do
      it "returns locations" do
        expect(described_class.max_updated_at.to_s).to eq location2.updated_at.to_s
      end    
    end  

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
g5_updatable-0.5.1 spec/models/g5_updatable/location_spec.rb