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
at_timestamp: handle asking for work packages with specific ids
Sebastian Fiedlschusterebad1063fe2c
diff --git a/app/models/journable/historic_active_record_relation.rb b/app/models/journable/historic_active_record_relation.rbindex c26afcb1563..1bcec40baa7 100644--- a/app/models/journable/historic_active_record_relation.rb+++ b/app/models/journable/historic_active_record_relation.rb@@ -78,7 +78,12 @@ class Journable::HistoricActiveRecordRelation < ActiveRecord::Relationif predicate.kind_of? Stringpredicate.gsub! "#{model.table_name}.", "#{model.journal_class.table_name}."elsif predicate.left.relation == self.arel_table+ if predicate.right.respond_to? :name and predicate.right.name == "id"+ predicate.right.instance_variable_set(:@name, "journable_id")+ predicate.left.relation = Journal.arel_table+ elsepredicate.left.relation = self.journal_class.arel_table+ endendenddiff --git a/spec/models/journable/timestamps_spec.rb b/spec/models/journable/timestamps_spec.rbindex 9c68c63984a..5af8db315fd 100644--- a/spec/models/journable/timestamps_spec.rb+++ b/spec/models/journable/timestamps_spec.rb@@ -405,6 +405,21 @@ describe Journable::Timestamps, type: :model doendend+ describe "when chaining where(id:) in order to request specific work packages at a specific point in time" do+ subject { WorkPackage.where(id: [work_package.id]).at_timestamp(@wednesday) }++ it "returns the work packages in their state at the requested point in time" do+ expect(subject.first.description).to eq "The work package as it has been on Wednesday"+ end++ describe "when the work package does not exist at the requested time" do+ subject { WorkPackage.where(id: [work_package.id]).at_timestamp(@before_monday) }++ it "returns an empty result" do+ expect(subject.count).to eq 0+ end+ end+ enddescribe "when chaining a sql where clause (as used by Query#statement)" dosubject { WorkPackage.where("(work_packages.description ILIKE '%been on Wednesday%')").at_timestamp(@wednesday) }