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 time entry query
Klaus Zanders8c413577ddc7
diff --git a/modules/costs/spec/models/queries/time_entries/time_entry_query_spec.rb b/modules/costs/spec/models/queries/time_entries/time_entry_query_spec.rbindex 3d7c08090ea..459cfa6b29b 100644--- a/modules/costs/spec/models/queries/time_entries/time_entry_query_spec.rb+++ b/modules/costs/spec/models/queries/time_entries/time_entry_query_spec.rb@@ -133,19 +133,22 @@ RSpec.describe Queries::TimeEntries::TimeEntryQuery doendend- context "with a work_package filter" do+ context "with an entity filter" dobefore doallow(WorkPackage).to receive_message_chain(:visible, :pluck).with(:id).and_return([1])- instance.where("work_package_id", "=", ["1"])+ instance.where("entity_type", "=", "WorkPackage")+ instance.where("entity_id", "=", ["1"])enddescribe "#results" doit "is the same as handwriting the query" do+ # we need to build the exact same query as the filter, so we cannot optimize for the copexpected = base_scope- .where(["time_entries.work_package_id IN (?)", ["1"]])+ .where("time_entries.entity_type IN (?)", "WorkPackage") # rubocop:disable Rails/WhereEquals+ .where("time_entries.entity_id IN (?)", ["1"]) # rubocop:disable Rails/WhereEqualsexpect(instance.results.to_sql).to eql expected.to_sqlend@@ -157,8 +160,8 @@ RSpec.describe Queries::TimeEntries::TimeEntryQuery doendit "is invalid if the filter is invalid" do- instance.where("work_package_id", "=", [""])- expect(instance).to be_invalid+ instance.where("entity_id", "=", [""])+ expect(instance).not_to be_validendendend