g5_updatable 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,21 +43,18 @@ describe G5Updatable::ClientFeedProcessor do
43
43
  describe "#work" do
44
44
  let(:client_updater) { double(update: nil) }
45
45
  let(:locations_updater) { double(update: nil) }
46
- let(:integration_settings_updater) { double(update: nil) }
47
46
 
48
47
  let(:client) { G5FoundationClient::Client.new(uid: client_uid,
49
48
  urn: "urn",
50
49
  name: "Client Name",
51
- locations: [{uid: location_uid, locations_integration_settings: [{uid: integration_setting_uid, vendor_action: 'inventory'}]}]) }
50
+ locations: [{uid: location_uid}]) }
52
51
  let(:client_uid) { "http://example.com/cilent_uid" }
53
52
  let(:location_uid) { "http://example.com/cilent_uid/locations/location_uid" }
54
- let(:integration_setting_uid) { "http://example.com/cilent_uid/locations/location_uid/integration_setting_uid" }
55
53
 
56
54
  before do
57
55
  stub_client_for_uid(client_uid, client)
58
56
  allow(G5Updatable::ClientUpdater).to receive(:new) { client_updater }
59
57
  allow(G5Updatable::LocationsUpdater).to receive(:new) { locations_updater }
60
- allow(G5Updatable::IntegrationSettingsUpdater).to receive(:new) { integration_settings_updater }
61
58
  G5Updatable::ClientFeedProcessor.new(client_uid).work
62
59
  end
63
60
 
@@ -70,11 +67,6 @@ describe G5Updatable::ClientFeedProcessor do
70
67
  expect(G5Updatable::LocationsUpdater).to have_received(:new).with(client.locations)
71
68
  expect(locations_updater).to have_received(:update)
72
69
  end
73
-
74
- it "updates with location's associated integration settings" do
75
- expect(G5Updatable::IntegrationSettingsUpdater).to have_received(:new).with(client.locations.first.integration_settings)
76
- expect(integration_settings_updater).to have_received(:update)
77
- end
78
70
  end
79
71
 
80
72
  describe :load_all_clients do
@@ -24,11 +24,4 @@ describe G5Updatable::Location do
24
24
 
25
25
  it { should eq(client) }
26
26
  end
27
-
28
- describe :integration_settings do
29
- let!(:integration_setting) { create(:integration_setting, location_uid: subject.uid) }
30
- subject { create(:location) }
31
-
32
- its(:integration_settings) { is_expected.to eq([integration_setting]) }
33
- end
34
27
  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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-12-01 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.1.0
33
+ version: 0.2.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.1.0
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pg
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -155,18 +155,17 @@ files:
155
155
  - app/controllers/g5_updatable/feed_controller.rb
156
156
  - app/helpers/g5_updatable/application_helper.rb
157
157
  - app/models/g5_updatable/client.rb
158
- - app/models/g5_updatable/integration_setting.rb
159
158
  - app/models/g5_updatable/location.rb
160
159
  - app/serializers/g5_updatable/location_serializer.rb
161
160
  - app/views/layouts/g5_updatable/application.html.erb
162
161
  - config/routes.rb
163
162
  - db/migrate/20140709222005_create_g5_updatable_clients_and_locations.rb
164
163
  - db/migrate/20141030211945_create_integration_setting.rb
164
+ - db/migrate/20141122211945_remove_integration_setting.rb
165
165
  - lib/g5_updatable.rb
166
166
  - lib/g5_updatable/client_feed_processor.rb
167
167
  - lib/g5_updatable/client_updater.rb
168
168
  - lib/g5_updatable/engine.rb
169
- - lib/g5_updatable/integration_settings_updater.rb
170
169
  - lib/g5_updatable/locations_updater.rb
171
170
  - lib/g5_updatable/rspec.rb
172
171
  - lib/g5_updatable/rspec/factories.rb
@@ -193,6 +192,7 @@ files:
193
192
  - spec/dummy/config/boot.rb
194
193
  - spec/dummy/config/database.sample.yml
195
194
  - spec/dummy/config/database.travis.yml
195
+ - spec/dummy/config/database.yml
196
196
  - spec/dummy/config/environment.rb
197
197
  - spec/dummy/config/environments/development.rb
198
198
  - spec/dummy/config/environments/production.rb
@@ -222,14 +222,12 @@ files:
222
222
  - spec/dummy/tmp/pids/server.pid
223
223
  - spec/lib/g5_updatable/client_feed_processor_spec.rb
224
224
  - spec/lib/g5_updatable/client_updater_spec.rb
225
- - spec/lib/g5_updatable/integration_settings_updater_spec.rb
226
225
  - spec/lib/g5_updatable/locations_updater_spec.rb
227
226
  - spec/lib/g5_updatable/version.rb
228
227
  - spec/lib/generators/g5_updatable/install_generator_spec.rb
229
228
  - spec/lib/generators/tmp/config/routes.rb
230
229
  - spec/lib/tmp/config/routes.rb
231
230
  - spec/models/g5_updatable/client_spec.rb
232
- - spec/models/g5_updatable/integration_setting_spec.rb
233
231
  - spec/models/g5_updatable/location_spec.rb
234
232
  - spec/serializers/g5_updatable/location_serializer_spec.rb
235
233
  - spec/spec_helper.rb
@@ -276,6 +274,7 @@ test_files:
276
274
  - spec/dummy/config/boot.rb
277
275
  - spec/dummy/config/database.sample.yml
278
276
  - spec/dummy/config/database.travis.yml
277
+ - spec/dummy/config/database.yml
279
278
  - spec/dummy/config/environment.rb
280
279
  - spec/dummy/config/environments/development.rb
281
280
  - spec/dummy/config/environments/production.rb
@@ -308,14 +307,12 @@ test_files:
308
307
  - spec/dummy/tmp/pids/server.pid
309
308
  - spec/lib/g5_updatable/client_feed_processor_spec.rb
310
309
  - spec/lib/g5_updatable/client_updater_spec.rb
311
- - spec/lib/g5_updatable/integration_settings_updater_spec.rb
312
310
  - spec/lib/g5_updatable/locations_updater_spec.rb
313
311
  - spec/lib/g5_updatable/version.rb
314
312
  - spec/lib/generators/g5_updatable/install_generator_spec.rb
315
313
  - spec/lib/generators/tmp/config/routes.rb
316
314
  - spec/lib/tmp/config/routes.rb
317
315
  - spec/models/g5_updatable/client_spec.rb
318
- - spec/models/g5_updatable/integration_setting_spec.rb
319
316
  - spec/models/g5_updatable/location_spec.rb
320
317
  - spec/serializers/g5_updatable/location_serializer_spec.rb
321
318
  - spec/spec_helper.rb
@@ -1,20 +0,0 @@
1
- module G5Updatable
2
- class IntegrationSetting < ActiveRecord::Base
3
- include G5Updatable::FirstClassProperties
4
- include G5Updatable::UrnAsParameter
5
-
6
- validates :uid, presence: true
7
- validates :location_uid, presence: true
8
-
9
- INVENTORY = 'inventory'
10
- LEAD = 'lead'
11
-
12
- scope :by_vendor_action, -> (vendor_action) { where(vendor_action: vendor_action) }
13
- scope :by_inventory, -> { by_vendor_action(INVENTORY) }
14
- scope :by_lead, -> { by_vendor_action(LEAD) }
15
-
16
- def location
17
- @client ||= G5Updatable::Location.find_by_uid(location_uid)
18
- end
19
- end
20
- end
@@ -1,21 +0,0 @@
1
- class G5Updatable::IntegrationSettingsUpdater
2
- def initialize(g5_integration_settings)
3
- @g5_integration_settings = g5_integration_settings
4
- end
5
-
6
- def update
7
- @g5_integration_settings.each do |g5_integration_setting|
8
- attributes = g5_integration_setting.integration_setting_hash.dup
9
-
10
- G5Updatable::IntegrationSetting.
11
- find_or_initialize_by(uid: attributes[:uid]).
12
- update_attributes!(
13
- urn: attributes[:urn],
14
- location_uid: attributes[:location_uid],
15
- vendor_action: attributes[:vendor_action],
16
- job_frequency_in_minutes: attributes[:job_frequency_in_minutes],
17
- properties: attributes
18
- )
19
- end
20
- end
21
- end
@@ -1,48 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe G5Updatable::IntegrationSettingsUpdater do
4
- let(:uid) { "http://example.com/uid" }
5
- let(:name) { "integration setting name" }
6
- let(:properties) { {uid: uid,
7
- urn: "urn",
8
- vendor_action: "inventory",
9
- location_uid: "location_uid",
10
- job_frequency_in_minutes: 22,
11
- name: name} }
12
- let(:integration_setting) { G5FoundationClient::IntegrationSetting.new(properties) }
13
-
14
- let(:updater) { described_class.new([integration_setting]) }
15
-
16
- describe "#update" do
17
- subject { G5Updatable::IntegrationSetting.first }
18
-
19
- context "with no existing integration-setting records" do
20
- before { updater.update }
21
-
22
- it "creates a Location" do
23
- expect(G5Updatable::IntegrationSetting.count).to eq(1)
24
- end
25
-
26
- its(:job_frequency_in_minutes) { should eq(22) }
27
- its(:uid) { should eq(uid) }
28
- its(:urn) { should eq("urn") }
29
- its(:location_uid) { should eq("location_uid") }
30
- its(:name) { should eq(name) }
31
- its(:vendor_action) { should eq("inventory") }
32
- end
33
-
34
- context "with an existing integration-setting record" do
35
- before do
36
- create(:integration_setting, uid: uid, urn: "old")
37
- updater.update
38
- end
39
-
40
- it "does not create a new IntegrationSetting" do
41
- expect(G5Updatable::IntegrationSetting.count).to eq(1)
42
- end
43
-
44
- its(:urn) { should eq("urn") }
45
- its(:name) { should eq(name) }
46
- end
47
- end
48
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe G5Updatable::IntegrationSetting do
4
- describe 'validations' do
5
- subject(:integration_setting) { G5Updatable::IntegrationSetting.new }
6
- it { expect(integration_setting).to validate_presence_of(:location_uid) }
7
- it { expect(integration_setting).to validate_presence_of(:uid) }
8
- end
9
-
10
- it_behaves_like 'a model with first-class properties' do
11
- let(:instance_factory_name) { :integration_setting }
12
- end
13
-
14
- it_behaves_like 'a model that uses its URN as its parameter' do
15
- let(:instance_factory_name) { :client }
16
- end
17
-
18
- describe "#location" do
19
- let(:integration_setting) { create(:integration_setting, location_uid: location.uid) }
20
- let(:location) { create(:location) }
21
- subject { integration_setting.location }
22
-
23
- it { should eq(location) }
24
- end
25
-
26
- describe :by_vendor_action do
27
- let!(:inventory) { create(:integration_setting, vendor_action: G5Updatable::IntegrationSetting::INVENTORY) }
28
- let!(:lead) { create(:integration_setting, vendor_action: G5Updatable::IntegrationSetting::LEAD) }
29
-
30
- it { expect(G5Updatable::IntegrationSetting.by_lead).to eq([lead]) }
31
- it { expect(G5Updatable::IntegrationSetting.by_inventory).to eq([inventory]) }
32
- end
33
- end