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

exclude virtual columns from journaling

Klaus Zanders3d827aedb595
diff --git a/app/models/journal/base_journal.rb b/app/models/journal/base_journal.rb
index ea9cd0fa094..826b7c62767 100644
--- a/app/models/journal/base_journal.rb
+++ b/app/models/journal/base_journal.rb
@@ -37,7 +37,7 @@ class Journal::BaseJournal < ApplicationRecord
end
def self.journaled_attributes
- @journaled_attributes ||= column_names.map(&:to_sym) - excluded_attributes
+ @journaled_attributes ||= columns.reject(&:virtual?).map { |col| col.name.to_sym } - excluded_attributes
end
def self.excluded_attributes
diff --git a/spec/lib/acts_as_journalized/journaled_spec.rb b/spec/lib/acts_as_journalized/journaled_spec.rb
index c10c92e4cb2..66244f00add 100644
--- a/spec/lib/acts_as_journalized/journaled_spec.rb
+++ b/spec/lib/acts_as_journalized/journaled_spec.rb
@@ -29,6 +29,14 @@
require "spec_helper"
RSpec.describe "Journalized Objects" do
+ describe ".journaled_attributes" do
+ it "does not include virtual columns" do
+ # we do have generated columns in the time entry journal
+ expect(Journal::TimeEntryJournal.journaled_attributes).not_to include(:start_timestamp)
+ expect(Journal::TimeEntryJournal.journaled_attributes).not_to include(:end_timestamp)
+ end
+ end
+
describe "journal_editable_by?" do
context "when the journable is a work package" do
let!(:user) { create(:user, member_with_permissions: { project => [] }) }