g5_updatable 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/app/controllers/g5_updatable/syncs_controller.rb +13 -0
- data/config/routes.rb +2 -0
- data/lib/g5_updatable/version.rb +1 -1
- data/spec/controllers/syncs_controller_spec.rb +20 -0
- data/spec/dummy/config/database.yml +1 -1
- data/spec/dummy/log/test.log +611 -19279
- metadata +6 -5
- data/spec/dummy/log/development.log +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3da77bb3b76b2b886e1bbbbca5150cdc8335d2d3
|
4
|
+
data.tar.gz: 650fa27e5eb4bb1c47198c4ffb8872d19a73d24e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/g5_updatable/version.rb
CHANGED
@@ -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
|