diff --git a/CHANGELOG.md b/CHANGELOG.md index 93e7cec..4854f35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Please mark backwards incompatible changes with an exclamation mark at the start ## [Unreleased] +### Fixed +- `PropertiesFetcher#last` now correctly returns the last set of properties + (ordered chronologically). + ## [29.3.0] - 2025-12-11 ### Added diff --git a/lib/jay_api/properties_fetcher.rb b/lib/jay_api/properties_fetcher.rb index 8266a19..133d5b0 100644 --- a/lib/jay_api/properties_fetcher.rb +++ b/lib/jay_api/properties_fetcher.rb @@ -129,7 +129,7 @@ def and # @return [Hash, nil] The last set of properties (ordered chronologically) # or +nil+ if no properties are found. def last - sort_records('asc').size(1) + sort_records('desc').size(1) fetch_properties.last end diff --git a/spec/jay_api/properties_fetcher_spec.rb b/spec/jay_api/properties_fetcher_spec.rb index 257a51e..b3e49cb 100644 --- a/spec/jay_api/properties_fetcher_spec.rb +++ b/spec/jay_api/properties_fetcher_spec.rb @@ -347,7 +347,7 @@ shared_examples_for '#last' do it 'adds a sorting clause to the query' do - expect(query_builder).to receive(:sort).with('timestamp' => 'asc') + expect(query_builder).to receive(:sort).with('timestamp' => 'desc') method_call end