mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 11:40:02 +00:00
use touch_and_save_journals
This commit is contained in:
@@ -78,6 +78,6 @@ class Projects::Settings::LifeCycleStepsController < Projects::SettingsControlle
|
||||
unique_by: %i[project_id definition_id]
|
||||
)
|
||||
|
||||
@project.save_journals
|
||||
@project.touch_and_save_journals
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,6 +73,11 @@ module Acts::Journalized
|
||||
end
|
||||
end
|
||||
|
||||
def touch_and_save_journals
|
||||
update_column(:updated_at, Time.current)
|
||||
save_journals
|
||||
end
|
||||
|
||||
def add_journal(user: User.current, notes: "", cause: CauseOfChange::NoCause.new)
|
||||
self.journal_user ||= user
|
||||
self.journal_notes ||= notes
|
||||
|
||||
@@ -54,10 +54,5 @@ module Meeting::Journalized
|
||||
register_journal_formatted_fields /agenda_items_\d+_duration_in_minutes/, formatter_key: :agenda_item_duration
|
||||
register_journal_formatted_fields "position", formatter_key: :agenda_item_position
|
||||
register_journal_formatted_fields /agenda_items_\d+_work_package_id/, formatter_key: :meeting_work_package_id
|
||||
|
||||
def touch_and_save_journals
|
||||
update_column(:updated_at, Time.current)
|
||||
save_journals
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -364,6 +364,30 @@ RSpec.describe Project, "acts_as_journalized" do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when creating without touching project" do
|
||||
let!(:project) do
|
||||
Timecop.freeze(1.year.ago) do
|
||||
create(:project)
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
create(:project_gate, project_id: project.id)
|
||||
end
|
||||
|
||||
it "fails when using save_journals" do
|
||||
expect do
|
||||
project.save_journals
|
||||
end.to raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
it "succeeds when using touch_and_save_journals" do
|
||||
expect do
|
||||
project.touch_and_save_journals
|
||||
end.to change { project.journals.count }.from(1).to(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "on project deletion" do
|
||||
|
||||
Reference in New Issue
Block a user