Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

clarify boundary of week filter

ulfertsb15f28f1244a
diff --git a/app/models/queries/projects/filters/filter_on_project_phase.rb b/app/models/queries/projects/filters/filter_on_project_phase.rb
index 96160a5df55..21598dab626 100644
--- a/app/models/queries/projects/filters/filter_on_project_phase.rb
+++ b/app/models/queries/projects/filters/filter_on_project_phase.rb
@@ -148,7 +148,7 @@ module Queries::Projects::Filters::FilterOnProjectPhase
end
def end_of_week
- beginning_of_week + 7.days
+ (beginning_of_week + 6.days).end_of_day
end
def project_phase_scope
diff --git a/spec/models/queries/projects/project_query_results_project_phase_any_spec.rb b/spec/models/queries/projects/project_query_results_project_phase_any_spec.rb
index 186c34c4ba0..64a54138d88 100644
--- a/spec/models/queries/projects/project_query_results_project_phase_any_spec.rb
+++ b/spec/models/queries/projects/project_query_results_project_phase_any_spec.rb
@@ -363,6 +363,32 @@ RSpec.describe ProjectQuery, "results of 'Project phase: Any' filter" do
end
end
end
+
+ context "when being on Wednesday before the phase, the phase starts on Monday and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ phase.update_column(:start_date, Date.parse("2025-02-03"))
+ end
+
+ it "returns no project as the phase starts in the next week" do
+ Timecop.travel(Date.parse("2025-01-29").noon) do
+ expect(instance.results).to be_empty
+ end
+ end
+ end
+
+ context "when being on Sunday, same as the phase's start date and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ phase.update_column(:start_date, Date.parse("2025-02-09"))
+ end
+
+ it "returns the project whose gate is in the current week" do
+ Timecop.travel(Date.parse("2025-02-09").noon) do
+ expect(instance.results).to contain_exactly(project_with_phase)
+ end
+ end
+ end
end
context "with a <>d (between) operator" do
diff --git a/spec/models/queries/projects/project_query_results_project_phase_gate_spec.rb b/spec/models/queries/projects/project_query_results_project_phase_gate_spec.rb
index 3225bb1631d..9a578437036 100644
--- a/spec/models/queries/projects/project_query_results_project_phase_gate_spec.rb
+++ b/spec/models/queries/projects/project_query_results_project_phase_gate_spec.rb
@@ -345,6 +345,36 @@ RSpec.describe ProjectQuery, "results of a project phase gate filter" do
end
end
end
+
+ context "when being on Wednesday before the gate, the gate is Monday and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ # This might produce invalid phases where the start date is after the end date.
+ # For the sake of the test, this is irrelevant.
+ gate.update_column(:"#{boundary}_date", Date.parse("2025-03-03"))
+ end
+
+ it "returns no project as the gate is in the week after" do
+ Timecop.travel(Date.parse("2025-02-26").noon) do
+ expect(instance.results).to be_empty
+ end
+ end
+ end
+
+ context "when being on Sunday, same as the gate and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ # This might produce invalid phases where the start date is after the end date.
+ # For the sake of the test, this is irrelevant.
+ gate.update_column(:"#{boundary}_date", Date.parse("2025-03-02"))
+ end
+
+ it "returns the project whose gate is in the current week" do
+ Timecop.travel(Date.parse("2025-03-02").noon) do
+ expect(instance.results).to contain_exactly(project_with_gate)
+ end
+ end
+ end
end
context "with a <>d (between) operator" do
diff --git a/spec/models/queries/projects/project_query_results_project_phase_spec.rb b/spec/models/queries/projects/project_query_results_project_phase_spec.rb
index dad5aec96c1..de1b7fd3c2d 100644
--- a/spec/models/queries/projects/project_query_results_project_phase_spec.rb
+++ b/spec/models/queries/projects/project_query_results_project_phase_spec.rb
@@ -363,6 +363,32 @@ RSpec.describe ProjectQuery, "results of a project phase filter" do
end
end
end
+
+ context "when being on Wednesday before the phase, the phase starts on Monday and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ stage.update_column(:start_date, Date.parse("2025-02-03"))
+ end
+
+ it "returns no project as the phase starts in the next week" do
+ Timecop.travel(Date.parse("2025-01-29").noon) do
+ expect(instance.results).to be_empty
+ end
+ end
+ end
+
+ context "when being on Sunday, same as the phase's start date and the week is configured to start on Monday",
+ with_settings: { start_of_week: 1 } do
+ before do
+ phase.update_column(:start_date, Date.parse("2025-02-09"))
+ end
+
+ it "returns the project whose gate is in the current week" do
+ Timecop.travel(Date.parse("2025-02-09").noon) do
+ expect(instance.results).to contain_exactly(project_with_phase)
+ end
+ end
+ end
end
context "with a <>d (between) operator" do