g5_updatable 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,7 @@ describe G5Updatable::ClientFeedProcessor do
64
64
  end
65
65
 
66
66
  it "updates with the client's associated locations" do
67
- expect(G5Updatable::LocationsUpdater).to have_received(:new).with(client.locations)
67
+ expect(G5Updatable::LocationsUpdater).to have_received(:new).with(client)
68
68
  expect(locations_updater).to have_received(:update)
69
69
  end
70
70
  end
@@ -7,8 +7,14 @@ describe G5Updatable::LocationsUpdater do
7
7
  client_uid: "client_uid",
8
8
  name: "Location Name"} }
9
9
  let(:g5_location) { G5FoundationClient::Location.new(properties) }
10
+ let(:g5_locations) { [g5_location] }
11
+ let(:g5_foundation_client) { G5FoundationClient::Client.new(urn: "urn", uid: "client_uid") }
10
12
 
11
- let(:updater) { described_class.new([g5_location]) }
13
+ let(:updater) { described_class.new(g5_foundation_client) }
14
+
15
+ before do
16
+ allow(g5_foundation_client).to receive(:locations) { g5_locations }
17
+ end
12
18
 
13
19
  describe "#update" do
14
20
  subject { G5Updatable::Location.first }
@@ -63,5 +69,32 @@ describe G5Updatable::LocationsUpdater do
63
69
  expect(subject.reload.updated_at).to be > @original_updated_at
64
70
  end
65
71
  end
72
+
73
+ context "with no locations" do
74
+ let(:g5_locations) { [] }
75
+
76
+ before do
77
+ FactoryGirl.create(:location, uid: uid, urn: "another_urn", client_uid: "client_uid", name: "Location Name", properties: properties)
78
+ FactoryGirl.create(:location, uid: uid, urn: "some_urn", client_uid: "another_client_uid", name: "Location Name", properties: properties)
79
+ updater.update
80
+ end
81
+
82
+ it "deletes locations" do
83
+ expect(G5Updatable::Location.by_client_uid("client_uid").count).to eq(0)
84
+ expect(G5Updatable::Location.by_client_uid("another_client_uid").count).to eq(1)
85
+ end
86
+ end
87
+
88
+ context "with an orphaned location" do
89
+ before do
90
+ FactoryGirl.create(:location, uid: "another_uid", urn: "dead_urn", client_uid: "client_uid")
91
+ updater.update
92
+ end
93
+
94
+ it "deletes locations" do
95
+ expect(G5Updatable::Location.by_urn("urn").by_client_uid("client_uid").count).to eq(1)
96
+ expect(G5Updatable::Location.by_urn("dead_urn").by_client_uid("client_uid").count).to eq(0)
97
+ end
98
+ end
66
99
  end
67
100
  end
@@ -28,7 +28,7 @@ describe G5Updatable::Location do
28
28
 
29
29
  context "scopes" do
30
30
  let!(:location) { FactoryGirl.create(:location) }
31
- let!(:location2) {FactoryGirl.create(:location, client_uid: "something_else") }
31
+ let!(:location2) {FactoryGirl.create(:location, client_uid: "something_else", urn: "another_urn") }
32
32
 
33
33
  describe ".by_client_uid" do
34
34
  it "returns locations" do
@@ -42,5 +42,11 @@ describe G5Updatable::Location do
42
42
  end
43
43
  end
44
44
 
45
+ describe ".by_urn" do
46
+ it "returns locations" do
47
+ expect(described_class.by_urn(location.urn)).to eq [location]
48
+ end
49
+ end
50
+
45
51
  end
46
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g5_updatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.0
33
+ version: 0.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.0
40
+ version: 0.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pg
43
43
  requirement: !ruby/object:Gem::Requirement