From 3bd5e06f618659d56a35f31066395a365b4e30de Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Mon, 23 Sep 2024 14:18:52 +0200 Subject: [PATCH] improve a bit results version integration spec --- .../query/results_version_integration_spec.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spec/models/query/results_version_integration_spec.rb b/spec/models/query/results_version_integration_spec.rb index efb8c8e90b48..e06e3f5f4b3a 100644 --- a/spec/models/query/results_version_integration_spec.rb +++ b/spec/models/query/results_version_integration_spec.rb @@ -42,7 +42,7 @@ let(:old_version) do create(:version, - name: "1. Old version", + name: "4. Old version", project:, start_date: "2019-02-02", effective_date: "2019-02-03") @@ -50,7 +50,7 @@ let(:new_version) do create(:version, - name: "1.2 New version", + name: "10.2 New version", project:, start_date: "2020-02-02", effective_date: "2020-02-03") @@ -58,7 +58,7 @@ let(:no_date_version) do create(:version, - name: "1.1 No date version", + name: "10.1 No date version", project:, start_date: nil, effective_date: nil) @@ -69,13 +69,13 @@ subject: "No version wp", project:) end - let!(:newest_version_wp) do + let!(:new_version_wp) do create(:work_package, subject: "Newest version wp", version: new_version, project:) end - let!(:oldest_version_wp) do + let!(:old_version_wp) do create(:work_package, subject: "Oldest version wp", version: old_version, @@ -101,7 +101,8 @@ q.sort_criteria = sort_criteria end end - let(:work_packages_asc) { [oldest_version_wp, no_date_version_wp, newest_version_wp, no_version_wp] } + let(:work_packages_asc) { [old_version_wp, no_date_version_wp, new_version_wp, no_version_wp] } + let(:work_packages_desc) { [new_version_wp, no_date_version_wp, old_version_wp, no_version_wp] } before do login_as(user) @@ -136,11 +137,8 @@ let(:sort_criteria) { [["version", "desc"]] } it "returns the correctly sorted result" do - # null values are still sorted last - work_packages_order = [newest_version_wp, no_date_version_wp, oldest_version_wp, no_version_wp] - expect(query_results.work_packages.pluck(:id)) - .to match work_packages_order.map(&:id) + .to match work_packages_desc.map(&:id) end end end