g5_updatable 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/g5_updatable/syncs_controller.rb +7 -1
- data/app/models/g5_updatable/client.rb +0 -1
- data/app/models/g5_updatable/location.rb +3 -0
- data/lib/g5_updatable/locations_updater.rb +2 -2
- data/lib/g5_updatable/version.rb +1 -1
- data/spec/controllers/syncs_controller_spec.rb +18 -8
- data/spec/dummy/log/test.log +8740 -0
- data/spec/lib/g5_updatable/locations_updater_spec.rb +12 -0
- data/spec/models/g5_updatable/location_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e5c5697b79384b5cc532c8a9d692f15784475fb
|
4
|
+
data.tar.gz: 7b862cf10c89e412bbb68d42004934539b5aaecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 968edabc4d300e1fa34c6d56448ab37e28e64f1fccc08304899db06f1c30b19ef34910f63a9a9fd4ba3fb781a6da2eaaad530ce1fc058d4714279748ae13f54c
|
7
|
+
data.tar.gz: a29f3772392f43e9492cda4f923a2e6ca097c99216f7084c186bf546b4b9fddf919e5a95a124f8708a415e5e6a39b0926aca1d23cf5595377562f450cadaa5aa
|
@@ -1,12 +1,18 @@
|
|
1
1
|
class G5Updatable::SyncsController < G5Updatable::BaseUpdatableController
|
2
2
|
|
3
|
+
before_filter :set_client
|
4
|
+
|
3
5
|
def index
|
4
|
-
timestamp =
|
6
|
+
timestamp = @client.locations.max_updated_at
|
5
7
|
render json: {updated_at: formatted_timestamp(timestamp)}
|
6
8
|
end
|
7
9
|
|
8
10
|
private
|
9
11
|
|
12
|
+
def set_client
|
13
|
+
@client = G5Updatable::Client.find_by_urn!(params[:urn])
|
14
|
+
end
|
15
|
+
|
10
16
|
def formatted_timestamp(timestamp)
|
11
17
|
timestamp.in_time_zone.strftime("%I:%M%P on %B %e, %Y") if timestamp
|
12
18
|
end
|
@@ -6,14 +6,14 @@ class G5Updatable::LocationsUpdater
|
|
6
6
|
def update
|
7
7
|
@g5_locations.each do |g5_location|
|
8
8
|
attributes = g5_location.location_hash.dup
|
9
|
-
|
10
9
|
G5Updatable::Location.
|
11
10
|
find_or_initialize_by(uid: attributes[:uid]).
|
12
11
|
update_attributes!(
|
13
12
|
urn: attributes[:urn],
|
14
13
|
name: attributes[:name],
|
15
14
|
client_uid: attributes[:client_uid],
|
16
|
-
properties: attributes
|
15
|
+
properties: attributes,
|
16
|
+
updated_at: DateTime.now
|
17
17
|
)
|
18
18
|
end
|
19
19
|
end
|
data/lib/g5_updatable/version.rb
CHANGED
@@ -4,17 +4,27 @@ describe G5Updatable::SyncsController, type: :controller do
|
|
4
4
|
routes { G5Updatable::Engine.routes }
|
5
5
|
|
6
6
|
describe 'GET index' do
|
7
|
-
let
|
8
|
-
let!(:
|
7
|
+
let(:client){ create(:client) }
|
8
|
+
let!(:location) { create(:location, client: client) }
|
9
|
+
let!(:location2) { create(:location, client: client) }
|
10
|
+
let!(:location3) { create(:location, client: create(:client)) }
|
9
11
|
let(:expected_result) { location2.updated_at.in_time_zone.strftime("%I:%M%P on %B %e, %Y") }
|
12
|
+
let(:params) { {urn: client.urn } }
|
10
13
|
|
11
|
-
|
12
|
-
get :index
|
13
|
-
|
14
|
+
subject do
|
15
|
+
get :index, params
|
16
|
+
JSON.parse response.body
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
its(['updated_at']){ should eq(expected_result) }
|
20
|
+
|
21
|
+
describe "no client" do
|
22
|
+
let(:params) { {urn: "xxx" } }
|
23
|
+
|
24
|
+
it "raises" do
|
25
|
+
# This error will cause rails to return a 404 in production
|
26
|
+
expect{ subject }.to raise_error(ActiveRecord::RecordNotFound)
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|