Skip to content

Commit

Permalink
Merge pull request #383 from roomorama/release/0.11.3
Browse files Browse the repository at this point in the history
Release/0.11.3
  • Loading branch information
keang authored Sep 23, 2016
2 parents a5e9010 + 13ce7da commit b5653ce
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## [0.11.3] - 2016-09-23
### Fixed
- Kigo: set `minimum_stay` to `nil` instead of 1 for calendar entry when coming NUMBER is zero

## [0.11.2] - 2016-09-22
### Fixed
- Atleisure config being paresed as boolean by YAML
Expand Down
9 changes: 7 additions & 2 deletions lib/concierge/suppliers/kigo/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ module Kigo
#
# represents days count according to +UNIT+ type
# possible unit types NIGHT, MONTH, YEAR
#
# example:
#
# TimeInterval.new({"UNIT"=>"NIGHT", "NUMBER"=>3})
TimeInterval = Struct.new(:interval) do
def days
return 1 if interval['NUMBER'].zero?
return nil if interval['NUMBER'].zero?

multiplier = { 'MONTH' => 30, 'YEAR' => 365 }.fetch(interval['UNIT'], 1)
interval['NUMBER'].to_i * multiplier
end
Expand Down Expand Up @@ -104,4 +109,4 @@ def safe_access(hash)
Concierge::SafeAccessHash.new(hash)
end
end
end
end
4 changes: 3 additions & 1 deletion lib/concierge/suppliers/kigo/mappers/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def set_base_info
end
end

# Parse the minimum stay from the given interval,
# or use 1 to statisfy Roomorama's property validation
def stay_length(interval)
Kigo::TimeInterval.new(interval).days
Kigo::TimeInterval.new(interval).days || 1
end

def set_description
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.11.2"
VERSION = "0.11.3"
end
29 changes: 27 additions & 2 deletions spec/lib/concierge/suppliers/kigo/calendar/period_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,31 @@
expect(entry.checkin_allowed).to eq true
expect(entry.checkout_allowed).to eq true
end
end

end
context 'unavailable minimum stay' do
let(:period) do
{
'CHECK_IN' => start_date.to_s,
'CHECK_OUT' => end_date.to_s,
'NAME' => '',
'STAY_MIN' => { 'UNIT' => 'NIGHT', 'NUMBER' => 0 },
'WEEKLY' => false,
'NIGHTLY_AMOUNTS' => [
{
'GUESTS_FROM' => 1,
'WEEK_NIGHTS' => [1, 2, 3, 4, 5, 6, 7],
'STAY_FROM' => { 'UNIT' => 'NIGHT', 'NUMBER' => 7 },
'AMOUNT' => '36.26'
}
]
}
end

it 'returns entry with min stay set to nil if NUMBER value is zero' do
entry = subject.entries.first

expect(entry.minimum_stay).to be_nil
end
end
end
end
14 changes: 14 additions & 0 deletions spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
expect(property.minimum_stay).to eq 30
end
end
context 'number is zero' do
let(:minimum_stay) {
{
'UNIT' => 'MONTH',
'NUMBER' => 0
}
}
it 'sets default stay_length' do
property_data['PROP_INFO']['PROP_STAYTIME_MIN'] = minimum_stay
property = subject.prepare(property_data, pricing).value

expect(property.minimum_stay).to eq 1
end
end
end

context 'description' do
Expand Down

0 comments on commit b5653ce

Please sign in to comment.