g5_updatable 0.4.3 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42f246c8c5a29515d15c0ede1dc90a664766d034
4
- data.tar.gz: 95991cb00bf8cc17182be8ff1bbb73daf87a02a7
3
+ metadata.gz: 3da77bb3b76b2b886e1bbbbca5150cdc8335d2d3
4
+ data.tar.gz: 650fa27e5eb4bb1c47198c4ffb8872d19a73d24e
5
5
  SHA512:
6
- metadata.gz: cf8aed5e7a2ae79882be93e61d9b87f3fc2d27dfabf218edc9ddfe8d4a373db293f74783909d0ededb08e4421512c50eec19d2ecaf8f6ac4a399c7269d1d40ce
7
- data.tar.gz: 8650d29014196bf832ca32d2d209c2156edd003b9b3026f5136c15fe7cb6753488f4882af6959c206244812991493f32a5e98dd9d8bf8252dfdcb6e0c62d6ed2
6
+ metadata.gz: 4e6833532814f8e51d4cf898659e8f55051fa6939b1b39f57eca409d422654e91858db1f7a2c5d6ae2bbdbf12b5a3684f5b8924bea150b13bde7bfa912ff3734
7
+ data.tar.gz: a68b14ed307b852fbdeccd95016055c6daa112927ddc4beef94cf4d17e43ec383a93e069b8ea21148a1100d52ef7366663d0cf28e7a01d4d6d6f6ae4fe772b7e
data/README.md CHANGED
@@ -51,6 +51,11 @@ Hub). When the route is hit, it will update/create Location and Client.
51
51
 
52
52
  See the [G5-Hub](https://github.com/G5/g5-hub/blob/master/lib/webhook_poster.rb) webhook logic for further info.
53
53
 
54
+ G5 Updatable also exposes two GET endpoints which return JSON:
55
+
56
+ * '/g5_updatable/locations/:urn' returns information about a location
57
+ * '/g5_updatable/syncs' returns updated_at timetamp of the most recent location sync
58
+
54
59
  ### Associations
55
60
 
56
61
  You will likely have models in your own application that are associated with a Client or Location. A module is available to include in your related models to support this association. Assuming your model has a `client_uid` or `location_uid` string field respectively, you can do the following:
@@ -79,6 +84,8 @@ For easier testing, if your app uses `FactoryGirl`, you can get access to factor
79
84
  ## Authors
80
85
 
81
86
  * Brian Bauer / [@bbauer](https://github.com/bbauer)
87
+ * Perry Hertler / [@perryqh](https://github.com/perryqh)
88
+ * Chris Stringer / [@jcstringer](https://github.com/jcstringer)
82
89
 
83
90
  ## Contributing
84
91
 
@@ -0,0 +1,13 @@
1
+ class G5Updatable::SyncsController < G5Updatable::BaseUpdatableController
2
+
3
+ def index
4
+ timestamp = G5Updatable::Location.maximum(:updated_at)
5
+ render json: {updated_at: formatted_timestamp(timestamp)}
6
+ end
7
+
8
+ private
9
+
10
+ def formatted_timestamp(timestamp)
11
+ timestamp.in_time_zone.strftime("%I:%M%P on %B %e, %Y") if timestamp
12
+ end
13
+ end
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  G5Updatable::Engine.routes.draw do
2
2
  post "/update" => "feed#update"
3
3
  get "/locations/:urn" => "locations#show"
4
+
5
+ resources :syncs, only: [:index]
4
6
  end
@@ -1,3 +1,3 @@
1
1
  module G5Updatable
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe G5Updatable::SyncsController, type: :controller do
4
+ routes { G5Updatable::Engine.routes }
5
+
6
+ describe 'GET index' do
7
+ let!(:location) { create(:location) }
8
+ let!(:location2) { create(:location) }
9
+ let(:expected_result) { location2.updated_at.in_time_zone.strftime("%I:%M%P on %B %e, %Y") }
10
+
11
+ before do
12
+ get :index
13
+ @result = JSON.parse response.body
14
+ end
15
+
16
+ it 'serializes' do
17
+ expect(@result['updated_at']).to eq(expected_result)
18
+ end
19
+ end
20
+ end
@@ -8,4 +8,4 @@ test:
8
8
  adapter: postgresql
9
9
  database: g5_updatable_dummy_test
10
10
  username: g5
11
- password: rocks!
11
+ password: rocks!