From 92f8f6e331acf01b5cb355dac1726237f83f6f1e Mon Sep 17 00:00:00 2001 From: Renato Mascarenhas Date: Mon, 12 Sep 2016 11:12:48 +0800 Subject: [PATCH 1/2] Encode Kigo image URLs. Sometimes, Kigo property images contain non-Latin characters, causing the validation to fail, and the property not to be published. This uses `URI.encode` when creating the `Roomorama::Image` object, so that the URL can be properly recognised. --- lib/concierge/suppliers/kigo/mappers/resolver.rb | 4 ++-- .../suppliers/kigo/mappers/resolver_spec.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/concierge/suppliers/kigo/mappers/resolver.rb b/lib/concierge/suppliers/kigo/mappers/resolver.rb index 048a723a6..17393a200 100644 --- a/lib/concierge/suppliers/kigo/mappers/resolver.rb +++ b/lib/concierge/suppliers/kigo/mappers/resolver.rb @@ -14,11 +14,11 @@ def images(payload, _) identifier = url.split('/').last caption = image['PHOTO_COMMENTS'] Roomorama::Image.new(identifier).tap do |i| - i.url = ['https:', url].join + i.url = URI.encode(['https:', url].join) i.caption = caption unless caption.strip.empty? end end end end -end \ No newline at end of file +end diff --git a/spec/lib/concierge/suppliers/kigo/mappers/resolver_spec.rb b/spec/lib/concierge/suppliers/kigo/mappers/resolver_spec.rb index 91cc69e60..d9f4fe9e5 100644 --- a/spec/lib/concierge/suppliers/kigo/mappers/resolver_spec.rb +++ b/spec/lib/concierge/suppliers/kigo/mappers/resolver_spec.rb @@ -29,6 +29,18 @@ expect(images.first.caption).to be_nil end + + it 'creates a valid image if the URL contains non-Latin characters' do + image['PHOTO_ID'] = '//dx577khz83dc.cloudfront.net/3304/P307_13_baƱo2_s.jpg' + + images = subject.images([image], property_id) + expect(images.size).to eq 1 + + image = images.first + expect { + image.validate! + }.not_to raise_error + end end -end \ No newline at end of file +end From 078dc97c0d3456b0810f8ff8da978b6931009888 Mon Sep 17 00:00:00 2001 From: Renato Mascarenhas Date: Mon, 12 Sep 2016 11:14:03 +0800 Subject: [PATCH 2/2] Update change log. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32fe583a6..20ca541da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ how this file is formatted and how the process works. ### Added - fee percentage for hosts on Web app on suppliers#show. +### Fixed +- Kigo property images with non-Latin characters + ## [0.8.0] - 2016-09-08 ### Added - Kigo and KigoLegacy integration: metadata sync, calendar sync, quoting, booking, cancelling support.