Skip to content

Commit

Permalink
improve a bit results version integration spec
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Sep 23, 2024
1 parent d9f3db4 commit ff62ae7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions spec/models/query/results_version_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@

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")
end

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")
end

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)
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit ff62ae7

Please sign in to comment.