From 04cef22197c11a5bed937832a650442ca98639c7 Mon Sep 17 00:00:00 2001 From: "K.Kolotyuk" Date: Wed, 21 Sep 2016 17:00:26 +0600 Subject: [PATCH 1/6] Calendar sync skips empty calendars --- CHANGELOG.md | 3 +++ apps/workers/calendar_synchronisation.rb | 2 ++ spec/workers/calendar_synchronisation_spec.rb | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7826dfa..ecf333332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ how this file is formatted and how the process works. ### Added - `ZendeskNotify` client with ticket creation on cancellation of bookings from Poplidays and AtLeisure +### Changed +- `Workers::CalendarSynchronisation` doesn't run operation for empty calendar + ### Fixed - Ciirus:: ignore permissions error about MC disabled clone properties - SAW: return unavailable quotation instead of Result.error while quote price diff --git a/apps/workers/calendar_synchronisation.rb b/apps/workers/calendar_synchronisation.rb index b2e5cf36b..4d1c8c6fe 100644 --- a/apps/workers/calendar_synchronisation.rb +++ b/apps/workers/calendar_synchronisation.rb @@ -117,6 +117,8 @@ def process(calendar) # will not be recognised.) return unless synchronised?(calendar.identifier) + return if calendar.entries.empty? + calendar.validate! update_counters(calendar) operation = Roomorama::Client::Operations.update_calendar(calendar) diff --git a/spec/workers/calendar_synchronisation_spec.rb b/spec/workers/calendar_synchronisation_spec.rb index 674e2371b..0c8280ca3 100644 --- a/spec/workers/calendar_synchronisation_spec.rb +++ b/spec/workers/calendar_synchronisation_spec.rb @@ -25,6 +25,8 @@ end } + let(:empty_calendar) { Roomorama::Calendar.new("prop1") } + subject { described_class.new(host) } describe "#start" do @@ -39,6 +41,13 @@ expect(operation.calendar).to eq calendar end + it "does not run any operation for empty calendar" do + expect(subject).to_not receive(:run_operation) + + create_property(identifier: "prop1", host_id: host.id) + subject.start("prop1") { Result.new(empty_calendar) } + end + context "error handling" do it "announces an error if the calendar returned does not pass validations" do calendar.entries.first.date = nil From b5f3840e8d188df0518e7d0352b6265b8e90b170 Mon Sep 17 00:00:00 2001 From: "K.Kolotyuk" Date: Thu, 22 Sep 2016 10:16:58 +0600 Subject: [PATCH 2/6] calendar.entries.empty? -> calendar.empty? --- apps/workers/calendar_synchronisation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/workers/calendar_synchronisation.rb b/apps/workers/calendar_synchronisation.rb index 4d1c8c6fe..4b837570d 100644 --- a/apps/workers/calendar_synchronisation.rb +++ b/apps/workers/calendar_synchronisation.rb @@ -117,7 +117,7 @@ def process(calendar) # will not be recognised.) return unless synchronised?(calendar.identifier) - return if calendar.entries.empty? + return if calendar.empty? calendar.validate! update_counters(calendar) From 456cfe0094b5e5f91a8f236c1bd58c46a8f2a398 Mon Sep 17 00:00:00 2001 From: Keang Date: Thu, 22 Sep 2016 13:58:32 +0800 Subject: [PATCH 3/6] Add host creation rake task --- lib/tasks/hosts.rake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/tasks/hosts.rake b/lib/tasks/hosts.rake index 843dfc4fa..b8d85d334 100644 --- a/lib/tasks/hosts.rake +++ b/lib/tasks/hosts.rake @@ -11,6 +11,26 @@ class HostCreationError < RuntimeError end namespace :hosts do + + desc "Convenience task to create a new host" + task :create, [:supplier_name, + :identifier, + :username, + :access_token, + :fee_percentage] => :environment do |task, args| + config_path = Hanami.root.join("config", "suppliers.yml").to_s + Concierge::Flows::HostCreation.new( + supplier: SupplierRepository.named(args[:supplier_name]), + identifier: args[:identifier], + username: args[:username], + access_token: args[:access_token], + fee_percentage: args[:fee_percentage], + config_path: config_path + ).perform.tap do |result| + raise HostCreationError.new(result.error.code) unless result.success? + end + end + desc "Updates background worker definitions for all hosts" task update_worker_definitions: :environment do path = Hanami.root.join("config", "suppliers.yml").to_s From 7fbc16051d833016acd769ea477456c7f8ee0b53 Mon Sep 17 00:00:00 2001 From: Keang Date: Thu, 22 Sep 2016 14:00:07 +0800 Subject: [PATCH 4/6] Add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3816a53cb..a2e6b65e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file summarises the most important changes that went live on each release of Concierge. Please check the Wiki entry on the release process to understand how this file is formatted and how the process works. +## Unreleased +### Added +- Add `rake hosts:create` to, well, create hosts + ## [0.11.0] - 2016-09-21 ### Added - `ZendeskNotify` client with ticket creation on cancellation of bookings from Poplidays and AtLeisure From d61c6ed2955ef1324d13042cb368411af942b777 Mon Sep 17 00:00:00 2001 From: Keang Date: Thu, 22 Sep 2016 14:15:28 +0800 Subject: [PATCH 5/6] Fix changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e6b65e6..0c4d8f2b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,13 @@ how this file is formatted and how the process works. ### Added - Add `rake hosts:create` to, well, create hosts +### Changed +- `Workers::CalendarSynchronisation` doesn't run operation for empty calendar + ## [0.11.0] - 2016-09-21 ### Added - `ZendeskNotify` client with ticket creation on cancellation of bookings from Poplidays and AtLeisure -### Changed -- `Workers::CalendarSynchronisation` doesn't run operation for empty calendar - ### Fixed - Ciirus:: ignore permissions error about MC disabled clone properties - SAW: return unavailable quotation instead of Result.error while quote price From 78674357ee8aa1d48ecca8fb7dc1e7250ed6bfd7 Mon Sep 17 00:00:00 2001 From: Keang Date: Thu, 22 Sep 2016 14:20:07 +0800 Subject: [PATCH 6/6] Release 0.11.1 :calendar: --- CHANGELOG.md | 2 +- lib/concierge/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c4d8f2b3..bb52a3e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This file summarises the most important changes that went live on each release of Concierge. Please check the Wiki entry on the release process to understand how this file is formatted and how the process works. -## Unreleased +## [0.11.1] - 2016-09-22 ### Added - Add `rake hosts:create` to, well, create hosts diff --git a/lib/concierge/version.rb b/lib/concierge/version.rb index a58fd3d33..9cfbe5ee4 100644 --- a/lib/concierge/version.rb +++ b/lib/concierge/version.rb @@ -1,3 +1,3 @@ module Concierge - VERSION = "0.11.0" + VERSION = "0.11.1" end