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

Allow instantiation of Project::LifeCycleStepDefinition in order to let acts_as_list function correctly.

Dombi Attilaa115cc50fca7
diff --git a/app/models/project/life_cycle_step_definition.rb b/app/models/project/life_cycle_step_definition.rb
index 5f1181f326d..7386a0ff4a5 100644
--- a/app/models/project/life_cycle_step_definition.rb
+++ b/app/models/project/life_cycle_step_definition.rb
@@ -42,15 +42,20 @@ class Project::LifeCycleStepDefinition < ApplicationRecord
acts_as_list
- def initialize(*args)
- if instance_of? Project::LifeCycleStepDefinition
- # Do not allow directly instantiating this class
- raise NotImplementedError, "Cannot instantiate the base Project::LifeCycleStepDefinition class directly. " \
- "Use Project::StageDefinition or Project::GateDefinition instead."
- end
-
- super
- end
+ # TODO: Enabling this causes an error in the acts_as_customizable gem
+ # /gems/acts_as_list-1.2.4/lib/acts_as_list/active_record/acts/position_column_method_definer.rb
+ # define_singleton_method :touch_record_sql do
+ # new.touch_record_sql
+ # end
+ # Calling new will fail with the error below:
+ # def initialize(*args)
+ # if instance_of? Project::LifeCycleStepDefinition
+ # # Do not allow directly instantiating this class
+ # raise NotImplementedError, "Cannot instantiate the base Project::LifeCycleStepDefinition class directly. " \
+ # "Use Project::StageDefinition or Project::GateDefinition instead."
+ # end
+ # super
+ # end
def step_class
raise NotImplementedError
diff --git a/spec/models/project/life_cycle_step_definition_spec.rb b/spec/models/project/life_cycle_step_definition_spec.rb
index 6251817bb2e..ff58d203c5c 100644
--- a/spec/models/project/life_cycle_step_definition_spec.rb
+++ b/spec/models/project/life_cycle_step_definition_spec.rb
@@ -29,8 +29,8 @@
require "rails_helper"
RSpec.describe Project::LifeCycleStepDefinition do
- it "cannot be instantiated" do
- expect { described_class.new }.to raise_error(NotImplementedError)
+ it "can be instantiated" do
+ expect { described_class.new }.not_to raise_error
end
context "with a Project::StageDefinition" do