Sha256: 4333c8268cc045245a7a85ff9ec9f3b37b84b84445bc7a9b73ca3dd542ebb965
Contents?: true
Size: 1.71 KB
Versions: 9
Compression:
Stored size: 1.71 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) } describe "client_urn" do it "delegates client_urn to client" do expect(location.client_urn).to eq(client.urn) end it "returns nil if client not found" do expect(create(:location, client_uid: 'madeup').client_urn).to be_nil end end end context "scopes" do let!(:location) { FactoryGirl.create(:location) } let!(:location2) {FactoryGirl.create(:location, client_uid: "something_else", urn: "another_urn") } 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 describe ".by_urn" do it "returns locations" do expect(described_class.by_urn(location.urn)).to eq [location] end end end end
Version data entries
9 entries across 9 versions & 1 rubygems