diff options
| author | Xinhui | 2016-08-05 11:23:03 +0200 |
|---|---|---|
| committer | Xinhui | 2016-08-05 11:23:03 +0200 |
| commit | 7cfd4faefab17e556ac66dd0e52c5942b289ec62 (patch) | |
| tree | c5630a1a3112f24a089b80ff13556892fef527f5 /lib/tasks | |
| parent | 9a818eeb8991bf0e07f2c9a9837930d153a0492f (diff) | |
| download | chouette-core-7cfd4faefab17e556ac66dd0e52c5942b289ec62.tar.bz2 | |
Rspec task organisations:sync
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/organisations.rake | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/tasks/organisations.rake b/lib/tasks/organisations.rake index a887cd277..06e1d3da7 100644 --- a/lib/tasks/organisations.rake +++ b/lib/tasks/organisations.rake @@ -1,7 +1,7 @@ namespace :organisations do def api_retrieve_organisation - last_sync = User.minimum(:synced_at) - conf = Rails.application.config.stif_portail_api + conf = Rails.application.config.try(:stif_portail_api) + raise 'Rails.application.config.stif_portail_api settings is not defined' unless conf conn = Faraday.new(:url => conf[:url]) do |c| c.headers['Authorization'] = "Token token=\"#{conf[:key]}\"" @@ -9,8 +9,8 @@ namespace :organisations do c.adapter Faraday.default_adapter end - response = conn.get '/api/v1/organizations' - JSON.parse response.body if response.status == 200 + resp = conn.get '/api/v1/organizations' + JSON.parse resp.body if resp.status == 200 end def sync_organisations data @@ -19,7 +19,7 @@ namespace :organisations do organisation.name = org['name'] organisation.synced_at = Time.now organisation.save if organisation.changed? - puts "Organisation #{organisation.name} has been updated" + puts "✓ Organisation #{organisation.name} has been updated" unless Rails.env.test? end end end |
