From 7af128539825aa4b0abea6a9b6400feac245f9ee Mon Sep 17 00:00:00 2001 From: Jack McNicol Date: Mon, 8 Aug 2016 18:21:48 +0930 Subject: [PATCH 1/8] update cache_key to be correct date if passed --- lib/quick_travel/resource.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/quick_travel/resource.rb b/lib/quick_travel/resource.rb index 15a6368..e4bcebe 100644 --- a/lib/quick_travel/resource.rb +++ b/lib/quick_travel/resource.rb @@ -12,8 +12,8 @@ def sub_resources end def self.all_with_price(opts) - find_all!("/api/resources/index_with_price.json", - opts.merge(cache: "#{name}.all_with_price-attrs?#{opts.to_param}&date=#{Date.current}")) + cache_key = GenerateCacheKey.new(name, opts).call + find_all!("/api/resources/index_with_price.json", opts.merge(cache: cache_key)) end def product_type @@ -25,5 +25,24 @@ def bed_requirements BedRequirement.new(bed_requirement) end end + + private + + class GenerateCacheKey + def initialize(resource_name, opts) + @resource_name = resource_name + @opts = opts + end + + def call + "#{@resource_name}.all_with_price-attrs?#{cache_params.to_param}" + end + + private + + def cache_params + { date: Date.current }.merge(@opts.symbolize_keys) + end + end end end From 5b1051fc45e002a3a54ccdea1bd4c4ed878d2102 Mon Sep 17 00:00:00 2001 From: Jack McNicol Date: Mon, 8 Aug 2016 18:22:26 +0930 Subject: [PATCH 2/8] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31af3a1..17c6b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/). +## [2.3.1] + +- Update cache_key to allow date + ## [2.3.0] ### Changed From d4cfff5873e67f90e9d4923cf9c55b4b2a4b66e2 Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 11:31:22 +0930 Subject: [PATCH 3/8] Updates Changelog entry and version --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17c6b32..08812ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/). -## [2.3.1] +## [2.4.0] -- Update cache_key to allow date +- Adds support for passing dates to Resource#all_with_price ## [2.3.0] From f5184ff59fc5cdbc4f857d29869ac355269a8f25 Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 11:31:45 +0930 Subject: [PATCH 4/8] Fixes issue with HTTParty 0.14 See https://github.com/jnunemaker/httparty/commit/c4a031d70d09a5d1dff7661ad71030bddbcf6e71 --- CHANGELOG.md | 1 + lib/quick_travel/adapter.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08812ce..f4adf84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/). ## [2.4.0] - Adds support for passing dates to Resource#all_with_price +- Fixes issue with HTTParty ~> 0.14 ## [2.3.0] diff --git a/lib/quick_travel/adapter.rb b/lib/quick_travel/adapter.rb index 5c0e399..3d5c431 100644 --- a/lib/quick_travel/adapter.rb +++ b/lib/quick_travel/adapter.rb @@ -272,7 +272,7 @@ def self.call_and_validate(http_method, path, query = {}, opts = {}) raise ConnectionError.new('Timeout error') end - if expect && expect == :json && !response.is_a?(Hash) + if expect && expect == :json && !response.parsed_response.is_a?(Hash) fail AdapterError, <<-FAIL Request expected to be json but failed. Debug information below: http_method: #{http_method.inspect} From 6b02987015c95aa1359e767803d253aec4ad0235 Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 11:31:57 +0930 Subject: [PATCH 5/8] Updates HTTParty dependency to ~> 0.14 --- CHANGELOG.md | 1 + quicktravel_client.gemspec | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4adf84..4793ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/). - Adds support for passing dates to Resource#all_with_price - Fixes issue with HTTParty ~> 0.14 +- Updates HTTParty dependency to ~> 0.14 ## [2.3.0] diff --git a/quicktravel_client.gemspec b/quicktravel_client.gemspec index 46c9fce..2ecdf14 100644 --- a/quicktravel_client.gemspec +++ b/quicktravel_client.gemspec @@ -16,7 +16,8 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.add_dependency 'httparty' + spec.add_dependency 'httparty', '~> 0.14' + spec.add_dependency 'json' # Geokit dependency should be removed (see address.rb for details) spec.add_dependency 'geokit', '~> 1.8.3' # used in address model spec.add_dependency 'activesupport', '>= 2.0.0' From 5af8b7e760662a5d7f9f67eddb1426ed24d48e3d Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 11:32:07 +0930 Subject: [PATCH 6/8] Bumps version to 2.4.0 --- lib/quick_travel/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/quick_travel/version.rb b/lib/quick_travel/version.rb index 187a0e6..7c1000c 100644 --- a/lib/quick_travel/version.rb +++ b/lib/quick_travel/version.rb @@ -1,3 +1,3 @@ module QuickTravel - VERSION = '2.2.2' + VERSION = '2.4.0' end From 376771fcf8658bf69ec15a3e6b25d9742dd2fac0 Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 11:54:14 +0930 Subject: [PATCH 7/8] Locks Ruby 1.9 compatible gem versions for travis --- gemfiles/rails2.gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gemfiles/rails2.gemfile b/gemfiles/rails2.gemfile index 7221abf..7ee6747 100644 --- a/gemfiles/rails2.gemfile +++ b/gemfiles/rails2.gemfile @@ -2,7 +2,10 @@ source 'https://rubygems.org' gemspec :path => '../' group :development, :test do + gem 'json', '~> 1.8' + gem 'tins', '~> 1.6.0' gem 'activesupport', '~> 2.3' gem 'activerecord', '~> 2.3' gem 'actionpack', '~> 2.3' + gem 'rubocop', '~> 0.41.2' end From a7aaaf7e6df9fa6a1eb7df04f0fadf1b5138b078 Mon Sep 17 00:00:00 2001 From: Alessandro Berardi Date: Tue, 9 Aug 2016 12:07:05 +0930 Subject: [PATCH 8/8] Sets version to 2.3.0 for actual next release --- CHANGELOG.md | 12 +++++------- lib/quick_travel/version.rb | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4793ea7..b5d4816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,16 +3,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/). -## [2.4.0] - -- Adds support for passing dates to Resource#all_with_price -- Fixes issue with HTTParty ~> 0.14 -- Updates HTTParty dependency to ~> 0.14 - ## [2.3.0] - ### Changed - Change cache expiries +- Adds support for passing dates to Resource#all_with_price + +### Fixed +- Fixes issue with HTTParty ~> 0.14 +- Updates HTTParty dependency to ~> 0.14 ## [2.2.2] ### Changed diff --git a/lib/quick_travel/version.rb b/lib/quick_travel/version.rb index 7c1000c..599da25 100644 --- a/lib/quick_travel/version.rb +++ b/lib/quick_travel/version.rb @@ -1,3 +1,3 @@ module QuickTravel - VERSION = '2.4.0' + VERSION = '2.3.0' end