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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix timestamps allowing all oneDayAgo timestamps (#12855)
Oliver Günther72c958bee67d
diff --git a/app/models/query.rb b/app/models/query.rbindex 5a5b29eebae..8c20401bc18 100644--- a/app/models/query.rb+++ b/app/models/query.rb@@ -438,8 +438,7 @@ class Query < ApplicationRecorddef allowed_timestampsreturn timestamps if EnterpriseToken.allows_to?(:baseline_comparison)-- timestamps.reject { |t| t.to_time < Date.yesterday }+ timestamps.select { |t| t.one_day_ago? || t.to_time >= Date.yesterday }enddef valid_filter_subset!diff --git a/app/models/timestamp.rb b/app/models/timestamp.rbindex 12d0e03c494..dd5f57ac388 100644--- a/app/models/timestamp.rb+++ b/app/models/timestamp.rb@@ -128,6 +128,10 @@ class Timestampto_s.match? TimestampParser::DATE_KEYWORD_REGEXend+ def one_day_ago?+ to_s.start_with? 'oneDayAgo'+ end+def to_s@timestamp_string.to_senddiff --git a/spec/models/query_spec.rb b/spec/models/query_spec.rbindex 9b908f293b1..6afc1b38d25 100644--- a/spec/models/query_spec.rb+++ b/spec/models/query_spec.rb@@ -146,6 +146,12 @@ RSpec.describe Query,it { is_expected.to be_valid }end+ context "when the 'oneDayAgo' with a timezone is provided" do+ let(:timestamps) { ["oneDayAgo@00:00+09:00"] }++ it { is_expected.to be_valid }+ end+context "when the shortcut value 'now' is provided" dolet(:timestamps) { ["now"] }