Skip to content

Commit

Permalink
Merge pull request #460 from roomorama/release/0.12.9
Browse files Browse the repository at this point in the history
Release/0.12.9
  • Loading branch information
keang authored Oct 18, 2016
2 parents a714acf + 89e7f4f commit 1bcea08
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.

## [0.12.9] - 2016-10-18
### Fixed
- Outdated method call when Kigo calendar checks if host is active
- Empty criteria for multiunit property's calendar

## [0.12.8] - 2016-10-17
### Added
- Rentals United: add number_of_bathrooms, number single, double, sofa beds fields
Expand Down
6 changes: 3 additions & 3 deletions apps/workers/suppliers/kigo/legacy/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def can_proceed?
# case there are no changes since the last run of the synchronisation process,
# for instance), then the +properties+ array will be empty. In such cases,
# the process can continue, but nothing will be updated.
return true unless properties.first
return true if properties.empty?

id = properties.first.identifier
result = Kigo::HostCheck.new(id, request_handler).active?
ids = properties.collect { |p| p.identifier }
result = Kigo::HostCheck.new(ids, request_handler).active?
result.success? && result.value
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/concierge/roomorama/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ def validate!
entries.all?(&:valid?) || (raise ValidationError.new("One of the entries miss required parameters."))
end

# checks if the calendar is empty (has no entries).
# Non multiunit property's calendar is empty if its entries list is empty
# Muiltiunit property's calendar is empty if calendar of each unit is empty
def empty?
entries.empty?
entries.empty? && (units.empty? || units.all?(&:empty?))
end

def to_h
Expand Down
2 changes: 1 addition & 1 deletion lib/concierge/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Concierge
VERSION = "0.12.7"
VERSION = "0.12.8"
end
39 changes: 34 additions & 5 deletions spec/lib/concierge/roomorama/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,42 @@
end

describe "#empty?" do
it "is empty if no calendar entries are added" do
expect(subject).to be_empty
context "non multiunit property's calendar" do
it "is empty if no calendar entries are added" do
expect(subject).to be_empty
end

it "is not empty if at least one calendar entry is added" do
subject.add(entry)
expect(subject).not_to be_empty
end
end

it "is not empty if at least one calendar entry is added" do
subject.add(entry)
expect(subject).not_to be_empty
context "multiunit property's calendar" do
it "is empty if all units' calendars are empty" do
unit_calendar = described_class.new('unit1')
subject.add_unit(unit_calendar)

expect(subject).to be_empty
end

it "is not empty if at least one unit's calendar is not empty" do
unit_calendar1 = described_class.new('unit1').tap do |calendar|
calendar.add(
Roomorama::Calendar::Entry.new(
date: Date.today,
available: true,
nightly_rate: 100
)
)
end
subject.add_unit(unit_calendar1)

unit_calendar2 = described_class.new('unit2')
subject.add_unit(unit_calendar2)

expect(subject).not_to be_empty
end
end
end

Expand Down
21 changes: 21 additions & 0 deletions spec/workers/suppliers/kigo/legacy/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@
allow_any_instance_of(Roomorama::Client).to receive(:perform) { Result.new('success') }
end

describe '#can_proceed' do
context "when host has no properties" do
it "should be true" do
host_with_no_properties = create_host(suplpier_id: supplier.id)
calendar = described_class.new(host_with_no_properties, [identifier])
expect(calendar.send(:can_proceed?)).to eq true
end
end

context "when host has properites" do
it "should call Kigo::HostCheck with all property ids" do
expect_any_instance_of(Kigo::HostCheck).to receive(:active?) do |host_check|
expect(host_check.property_ids).to be_a Array
expect(host_check.property_ids).to_not be_empty
Result.new(true)
end
expect(subject.send(:can_proceed?)).to eq true
end
end
end

describe '#perform' do
let(:today) { Date.today }
let(:days_count) { 5 }
Expand Down

0 comments on commit 1bcea08

Please sign in to comment.