Sha256: 3a75894ec97d79bec091712579ff0c440f7b475786c28b8fce1c673664599ef0
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
require "spec_helper" describe G5Updatable::ClientUpdater do let(:uid) { "http://example.com/uid" } let(:properties) { {uid: uid, urn: "urn", name: "Client Name", } } let(:g5_client) { G5FoundationClient::Client.new(properties) } let(:updater) { described_class.new(g5_client) } describe "#update" do subject { G5Updatable::Client.first } context "with no existing Client records" do before { updater.update } let(:name) { 'Client Name' } it "creates a Client" do expect(G5Updatable::Client.count).to eq(1) end it 'does not redact keys in properties' do expect(subject.properties.keys.collect(&:to_sym)).to eq(properties.keys) end its(:uid) { should eq(uid) } its(:urn) { should eq("urn") } its(:name) { should eq(name) } it 'sets name field so that consumers can easily sort by name' do subject expect(G5Updatable::Client.find_by_name(name)).to eq(subject) end end context "with an existing Client record" do before do FactoryGirl.create(:client, uid: uid, urn: "old") updater.update end it "does not create a new Client" do expect(G5Updatable::Client.count).to eq(1) end its(:urn) { should eq("urn") } its(:name) { should eq("Client Name") } end context "with an existing identical Client record" do before do client = FactoryGirl.create(:client, uid: uid, urn: "urn", name: "Client Name", properties: properties) @original_updated_at = subject.updated_at updater.update end it "updates its timestamp" do expect(subject.reload.updated_at).to be > @original_updated_at end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
g5_updatable-0.10.3 | spec/lib/g5_updatable/client_updater_spec.rb |
g5_updatable-0.10.2 | spec/lib/g5_updatable/client_updater_spec.rb |