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
Move status names into the seeder files
Christophe Bliarda543e6a3bd46
diff --git a/app/seeders/basic_data/setting_seeder.rb b/app/seeders/basic_data/setting_seeder.rbindex 01249e9ea6c..f8d97304779 100644--- a/app/seeders/basic_data/setting_seeder.rb+++ b/app/seeders/basic_data/setting_seeder.rb@@ -57,7 +57,8 @@ module BasicDatasettings['new_project_user_role_id'] = Role.find_by(name: I18n.t(:default_role_project_admin)).try(:id)# Set the closed status for repository commit references- settings['commit_fix_status_id'] = Status.find_by(name: I18n.t(:default_status_closed)).try(:id)+ status_closed = seed_data.find_reference(:default_status_closed, default: nil)+ settings['commit_fix_status_id'] = status_closed.try(:id)settings.compactenddiff --git a/app/seeders/basic_data/status_seeder.rb b/app/seeders/basic_data/status_seeder.rbindex 7d1a1cbbd65..117b19fa639 100644--- a/app/seeders/basic_data/status_seeder.rb+++ b/app/seeders/basic_data/status_seeder.rb@@ -30,7 +30,9 @@ module BasicDatadef seed_data!Status.transaction dodata.each do |attributes|- Status.create!(attributes)+ reference = attributes.delete(:reference)+ status = Status.create!(attributes)+ seed_data.store_reference(reference, status)endendend@@ -44,7 +46,23 @@ module BasicDataenddef data- raise NotImplementedError+ Array(seed_data.lookup('statuses')).map do |status_data|+ {+ reference: status_data['reference'],+ name: status_data['name'],+ color_id: color_id(status_data['color_name']),+ is_closed: true?(status_data['is_closed']),+ is_default: true?(status_data['is_default']),+ position: status_data['position']+ }+ end+ end++ protected++ def color_id(name)+ @color_ids_by_name ||= Color.pluck(:name, :id).to_h+ @color_ids_by_name[name] or raise "Cannot find color #{name}"endendenddiff --git a/app/seeders/basic_data/workflow_seeder.rb b/app/seeders/basic_data/workflow_seeder.rbindex af42dc88b33..c8ff3624454 100644--- a/app/seeders/basic_data/workflow_seeder.rb+++ b/app/seeders/basic_data/workflow_seeder.rb@@ -49,10 +49,6 @@ module BasicDataraise NotImplementedErrorend- def status_seeder_class- raise NotImplementedError- end-privatedef fix_work_packages_without_types@@ -95,7 +91,7 @@ module BasicDatadef seed_statusesprint_status ' ↳ Statuses'- status_seeder_class.new(seed_data).seed!+ BasicData::StatusSeeder.new(seed_data).seed!enddef seed_typesdiff --git a/app/seeders/demo_data/work_package_board_seeder.rb b/app/seeders/demo_data/work_package_board_seeder.rbindex 5650f77af71..fb0dc5026bb 100644--- a/app/seeders/demo_data/work_package_board_seeder.rb+++ b/app/seeders/demo_data/work_package_board_seeder.rb@@ -102,10 +102,10 @@ module DemoDatadef seed_kanban_board_queriesstatuses(- 'default_status_new',- 'default_status_in_progress',- 'default_status_closed',- 'default_status_rejected'+ :default_status_new,+ :default_status_in_progress,+ :default_status_closed,+ :default_status_rejected).map do |status|Query.new_default(project:, user:).tap do |query|# Make it public so that new members can see it too@@ -123,15 +123,14 @@ module DemoDataendend- def statuses(*status_i18n_keys)- status_names = status_i18n_keys.map { I18n.t(_1) }- statuses = Status.where(name: status_names).to_a+ def statuses(*status_references)+ statuses = status_references.map { seed_data.find_reference(_1) }- if statuses.size < status_names.size+ if statuses.size < status_references.sizeraise StandardError, "Not all statuses needed for seeding a board are present. Check that they got seeded."end- statuses.to_a+ statusesenddef seed_basic_board(board_data)diff --git a/app/seeders/demo_data/work_package_seeder.rb b/app/seeders/demo_data/work_package_seeder.rbindex 1596c49f072..b7332759696 100644--- a/app/seeders/demo_data/work_package_seeder.rb+++ b/app/seeders/demo_data/work_package_seeder.rb@@ -141,7 +141,7 @@ module DemoDataenddef find_status(attributes)- Status.find_by!(name: I18n.t(attributes['status']))+ seed_data.find_reference(attributes['status'].to_sym)enddef find_type(attributes)diff --git a/app/seeders/seeder.rb b/app/seeders/seeder.rbindex 6c908b908b8..2cc469b8680 100644--- a/app/seeders/seeder.rb+++ b/app/seeders/seeder.rb@@ -81,6 +81,10 @@ class Seeder@user ||= User.not_builtin.admin.firstend+ def true?(value)+ ActiveRecord::Type::Boolean.new.cast(value) || false+ end+protecteddef print_status(message)diff --git a/app/seeders/source/seed_data.rb b/app/seeders/source/seed_data.rbindex ba7c5547809..4f47c592bd2 100644--- a/app/seeders/source/seed_data.rb+++ b/app/seeders/source/seed_data.rb@@ -43,10 +43,32 @@ class Source::SeedDataregistry[reference] = recordend- def find_reference(reference)+ def find_reference(reference, default: :__unset__)return if reference.nil?- registry.fetch(reference) { raise ArgumentError, "Nothing registered with reference #{reference.inspect}" }+ registry.fetch(reference) do+ if default == :__unset__+ raise ArgumentError, "Nothing registered with reference #{reference.inspect}"+ end++ default+ end+ end++ # Get a `SeedData` instance with only the given top level keys.+ #+ # Used in tests to get the real statuses, types and other data.+ def only(*keys)+ self.class.new(data.slice(*keys), registry.dup)+ end++ # Returns a new `SeedData` instance with its data and its registry merged with+ # the ones from the given instance.+ #+ # The data from the given instance takes precedence for keys present in both+ # instances.+ def merge(other)+ self.class.new(data.merge(other.data), registry.merge(other.registry))enddef lookup(path)@@ -78,12 +100,12 @@ class Source::SeedDataendend- private+ protected- attr_reader :registry+ attr_reader :data, :registrydef fetch(path)keys = path.to_s.split('.')- @data.dig(*keys)+ data.dig(*keys)endenddiff --git a/app/seeders/standard.yml b/app/seeders/standard.ymlindex 9050dec29d0..3d6ce4e4853 100644--- a/app/seeders/standard.yml+++ b/app/seeders/standard.yml@@ -26,6 +26,92 @@# See COPYRIGHT and LICENSE files for more details.#+++statuses:+- reference: :default_status_new+ t_name: New+ color_name: cyan-7+ is_closed: false+ is_default: true+ position: 1+- reference: :default_status_in_specification+ t_name: In specification+ color_name: blue-2+ is_closed: false+ is_default: false+ position: 2+- reference: :default_status_specified+ t_name: Specified+ color_name: blue-2+ is_closed: false+ is_default: false+ position: 3+- reference: :default_status_confirmed+ t_name: Confirmed+ color_name: violet-2+ is_closed: false+ is_default: false+ position: 4+- reference: :default_status_to_be_scheduled+ t_name: To be scheduled+ color_name: yellow-2+ is_closed: false+ is_default: false+ position: 5+- reference: :default_status_scheduled+ t_name: Scheduled+ color_name: lime-2+ is_closed: false+ is_default: false+ position: 6+- reference: :default_status_in_progress+ t_name: In progress+ color_name: grape-5+ is_closed: false+ is_default: false+ position: 7+- reference: :default_status_developed+ t_name: Developed+ color_name: green-3+ is_closed: false+ is_default: false+ position: 8+- reference: :default_status_in_testing+ t_name: In testing+ color_name: cyan-5+ is_closed: false+ is_default: false+ position: 9+- reference: :default_status_tested+ t_name: Tested+ color_name: teal-6+ is_closed: false+ is_default: false+ position: 10+- reference: :default_status_test_failed+ t_name: Test failed+ color_name: red-5+ is_closed: false+ is_default: false+ position: 11+- reference: :default_status_closed+ t_name: Closed+ color_name: gray-3+ is_closed: true+ is_default: false+ position: 12+- reference: :default_status_on_hold+ t_name: On hold+ color_name: orange-3+ is_closed: false+ is_default: false+ position: 13+- reference: :default_status_rejected+ t_name: Rejected+ color_name: red-3+ is_closed: true+ is_default: false+ position: 14+welcome:t_title: "Welcome to OpenProject!"t_text: |@@ -208,7 +294,7 @@ projects:- start: -1t_subject: Start of projectdescription:- status: default_status_closed+ status: :default_status_closedtype: default_type_milestoneduration: 1schedule_manually: false@@ -216,32 +302,32 @@ projects:t_subject: Organize open source conferencereference: :organize_open_source_conferencedescription: ''- status: default_status_in_progress+ status: :default_status_in_progresstype: default_type_phasechildren:- start: 0t_subject: Set date and location of conferencereference: :set_date_and_location_of_conferencedescription: ''- status: default_status_in_progress+ status: :default_status_in_progresstype: default_type_taskchildren:- start: 0t_subject: Send invitation to speakersdescription: ''- status: default_status_in_progress+ status: :default_status_in_progresstype: default_type_taskduration: 1- start: 0t_subject: Contact sponsoring partnersdescription: ''- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 2- start: 0t_subject: Create sponsorship brochure and hand-outsdescription: ''- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 4duration: 4@@ -250,7 +336,7 @@ projects:t_subject: Invite attendees to conferencereference: :invite_attendees_to_conferencedescription: ''- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 1relations:@@ -261,7 +347,7 @@ projects:t_subject: Setup conference websitereference: :setup_conference_websitedescription: ''- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 11relations:@@ -273,7 +359,7 @@ projects:- start: 15t_subject: Conferencedescription: ''- status: default_status_scheduled+ status: :default_status_scheduledtype: default_type_milestoneduration: 1relations:@@ -284,14 +370,14 @@ projects:t_subject: Follow-up tasksreference: :follow_up_tasksdescription: ''- status: default_status_to_be_scheduled+ status: :default_status_to_be_scheduledtype: default_type_phasechildren:- start: 21t_subject: Upload presentations to websitereference: :upload_presentations_to_websitedescription: ''- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 10schedule_manually: false@@ -302,7 +388,7 @@ projects:* [ ] Snacks* [ ] Music* [ ] Even more beer- status: default_status_new+ status: :default_status_newtype: default_type_taskduration: 1schedule_manually: false@@ -311,7 +397,7 @@ projects:- start: 32t_subject: End of projectdescription:- status: default_status_new+ status: :default_status_newtype: default_type_milestoneduration: 1relations:diff --git a/app/seeders/standard/basic_data/status_seeder.rb b/app/seeders/standard/basic_data/status_seeder.rbdeleted file mode 100644index 6f478b89e6a..00000000000--- a/app/seeders/standard/basic_data/status_seeder.rb+++ /dev/null@@ -1,88 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2023 the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-module Standard- module BasicData- class StatusSeeder < ::BasicData::StatusSeeder- def data- color_names = [- 'cyan-7', # new- 'blue-2', # in specification- 'blue-2', # specified- 'violet-2', # confirmed- 'yellow-2', # tbs- 'lime-2', # scheduled- 'grape-5', # in progress- 'cyan-3', # in development- 'green-3', # developed- 'cyan-5', # in testing- 'teal-6', # tested- 'red-5', # test_failed- 'gray-3', # closed- 'orange-3', # on hold- 'red-3' # rejected- ]-- # When selecting for an array of values, implicit order is applied- # so we need to restore values by their name.- colors_by_name = Color.where(name: color_names).index_by(&:name)- colors = color_names.collect { |name| colors_by_name[name].id }-- [- { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true,- position: 1 },- { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false,- position: 2 },- { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false,- position: 3 },- { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false,- position: 4 },- { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false,- position: 5 },- { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false,- position: 6 },- { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false,- position: 7 },- { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false,- position: 9 },- { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false,- position: 10 },- { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false,- position: 11 },- { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false,- position: 12 },- { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false,- position: 13 },- { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false,- position: 14 },- { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false,- position: 15 }- ]- end- end- end-enddiff --git a/app/seeders/standard/basic_data/workflow_seeder.rb b/app/seeders/standard/basic_data/workflow_seeder.rbindex 22b51f0cae0..20c95d431b8 100644--- a/app/seeders/standard/basic_data/workflow_seeder.rb+++ b/app/seeders/standard/basic_data/workflow_seeder.rb@@ -32,20 +32,20 @@ module Standardtypes = Type.alltypes = types.map { |t| { t.name => t.id } }.reduce({}, :merge)- new = Status.find_by(name: I18n.t(:default_status_new))- in_specification = Status.find_by(name: I18n.t(:default_status_in_specification))- specified = Status.find_by(name: I18n.t(:default_status_specified))- confirmed = Status.find_by(name: I18n.t(:default_status_confirmed))- to_be_scheduled = Status.find_by(name: I18n.t(:default_status_to_be_scheduled))- scheduled = Status.find_by(name: I18n.t(:default_status_scheduled))- in_progress = Status.find_by(name: I18n.t(:default_status_in_progress))- developed = Status.find_by(name: I18n.t(:default_status_developed))- in_testing = Status.find_by(name: I18n.t(:default_status_in_testing))- tested = Status.find_by(name: I18n.t(:default_status_tested))- test_failed = Status.find_by(name: I18n.t(:default_status_test_failed))- closed = Status.find_by(name: I18n.t(:default_status_closed))- on_hold = Status.find_by(name: I18n.t(:default_status_on_hold))- rejected = Status.find_by(name: I18n.t(:default_status_rejected))+ new = seed_data.find_reference(:default_status_new)+ in_specification = seed_data.find_reference(:default_status_in_specification)+ specified = seed_data.find_reference(:default_status_specified)+ confirmed = seed_data.find_reference(:default_status_confirmed)+ to_be_scheduled = seed_data.find_reference(:default_status_to_be_scheduled)+ scheduled = seed_data.find_reference(:default_status_scheduled)+ in_progress = seed_data.find_reference(:default_status_in_progress)+ developed = seed_data.find_reference(:default_status_developed)+ in_testing = seed_data.find_reference(:default_status_in_testing)+ tested = seed_data.find_reference(:default_status_tested)+ test_failed = seed_data.find_reference(:default_status_test_failed)+ closed = seed_data.find_reference(:default_status_closed)+ on_hold = seed_data.find_reference(:default_status_on_hold)+ rejected = seed_data.find_reference(:default_status_rejected){types[I18n.t(:default_type_task)] => [new, in_progress, on_hold, rejected, closed],@@ -65,10 +65,6 @@ module Standarddef type_seeder_class::Standard::BasicData::TypeSeederend-- def status_seeder_class- ::Standard::BasicData::StatusSeeder- endendendenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex f6486ae9d83..6cbe82db50f 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1290,21 +1290,6 @@ en:default_color_red: "Red"default_color_white: "White"default_color_yellow: "Yellow"- default_status_closed: "Closed"- default_status_confirmed: "Confirmed"- default_status_developed: "Developed"- default_status_in_development: "In development"- default_status_in_progress: "In progress"- default_status_in_specification: "In specification"- default_status_in_testing: "In testing"- default_status_new: "New"- default_status_on_hold: "On hold"- default_status_rejected: "Rejected"- default_status_scheduled: "Scheduled"- default_status_specified: "Specified"- default_status_tested: "Tested"- default_status_test_failed: "Test failed"- default_status_to_be_scheduled: "To be scheduled"default_priority_low: "Low"default_priority_normal: "Normal"default_priority_high: "High"diff --git a/modules/bim/app/seeders/bim.yml b/modules/bim/app/seeders/bim.ymlindex 7557ab4b0dd..05499ac200f 100644--- a/modules/bim/app/seeders/bim.yml+++ b/modules/bim/app/seeders/bim.yml@@ -26,6 +26,26 @@# See COPYRIGHT and LICENSE files for more details.#+++statuses:+ - reference: :default_status_new+ t_name: New+ color_name: blue-6+ is_default: true+ position: 1+ - reference: :default_status_in_progress+ t_name: In progress+ color_name: orange-6+ position: 2+ - reference: :default_status_resolved+ t_name: Resolved+ color_name: green-3+ position: 3+ - reference: :default_status_closed+ t_name: Closed+ color_name: gray-3+ is_closed: true+ position: 4+global_queries:- t_name: "Embedded table: Children"reference: :global_query__children@@ -368,7 +388,7 @@ projects:The project kick off initializes the start of the project in your company. Everybody being part of this project should be invited to the kick off for a first briefing.The next step could be checking out the timetable and adjusting the appointments, by looking at the [Gantt chart]({{opSetting:base_url}}/projects/demo-construction-project/work_packages?query_props=%7B%22c%22%3A%5B%22id%22%2C%22subject%22%2C%22startDate%22%2C%22dueDate%22%5D%2C%22tv%22%3Atrue%2C%22tzl%22%3A%22weeks%22%2C%22hi%22%3Atrue%2C%22g%22%3A%22%22%2C%22t%22%3A%22startDate%3Aasc%22%2C%22f%22%3A%5B%7B%22n%22%3A%22status%22%2C%22o%22%3A%22o%22%2C%22v%22%3A%5B%5D%7D%5D%2C%22pa%22%3A1%2C%22pp%22%3A100%7D).- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__planners:duration: 1@@ -376,7 +396,7 @@ projects::t_subject: Basic evaluation:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 7@@ -393,7 +413,7 @@ projects:* Identify the customer needs by having a workshop with him/ her* Each need shall represent a task with its corresponding work packages* Derive the cost estimation and time frame- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 4@@ -413,7 +433,7 @@ projects:* Each topic gets its own overview which will be used as a catalogue of results* This overview informs all participants about the decisions made* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 4@@ -425,7 +445,7 @@ projects::reference: :end_of_basic_evaluation:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__planners:duration: 1@@ -441,7 +461,7 @@ projects::t_subject: Preliminary planning:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 22@@ -460,7 +480,7 @@ projects:* Each topic gets its own overview which will be used as a catalogue of results* This overview informs all participants about the decisions made* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 10@@ -483,7 +503,7 @@ projects:* Each topic gets its own overview which will be used as a catalogue of results* This overview informs all participants about the decisions made* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 4@@ -497,7 +517,7 @@ projects::reference: :passing_of_preliminary_planning:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__planners:duration: 1@@ -508,7 +528,7 @@ projects::t_subject: Design planning:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 44@@ -526,7 +546,7 @@ projects:* All parties agree on the design* The owner is happy with the results* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 45@@ -538,7 +558,7 @@ projects::reference: :design_freeze:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__planners:duration: 1@@ -550,7 +570,7 @@ projects:- :start: 98:t_subject: Construction phase:description: ''- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 98@@ -568,7 +588,7 @@ projects:* Preparing the site for the project* Get the team together* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 31@@ -585,7 +605,7 @@ projects:* Setting up the concrete mixer* Setting up the supply chain for the concrete* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 25@@ -607,7 +627,7 @@ projects:* Installing doors and windows* Finishing the roof structure* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 46@@ -625,7 +645,7 @@ projects:* Install all elements for the facade* Finish the roof* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 32@@ -642,7 +662,7 @@ projects:* Installing the climate system* Electrical installation* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 25@@ -662,7 +682,7 @@ projects:* Finishing the interior construction* Finishing the facade* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 18@@ -678,7 +698,7 @@ projects:* Invite the construction team* Invite your friends* Bring some drinks, snacks and your smile- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:duration: 1:relations:@@ -837,7 +857,7 @@ projects:The project Kickoff initializes the start of the project in your company. The whole project team should be invited to the Kickoff for a first briefing.The next step could be to check out the timetable and adjusting the appointments, by looking at the [Gantt chart]({{opSetting:base_url}}/projects/demo-bim-project/work_packages?query_props=%7B%22c%22%3A%5B%22id%22%2C%22subject%22%2C%22startDate%22%2C%22dueDate%22%5D%2C%22tv%22%3Atrue%2C%22tzl%22%3A%22weeks%22%2C%22hi%22%3Atrue%2C%22g%22%3A%22%22%2C%22t%22%3A%22startDate%3Aasc%22%2C%22f%22%3A%5B%7B%22n%22%3A%22status%22%2C%22o%22%3A%22o%22%2C%22v%22%3A%5B%5D%7D%5D%2C%22pa%22%3A1%2C%22pp%22%3A100%7D).- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_managers:duration: 1@@ -846,7 +866,7 @@ projects::reference: :project_preparation:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 15@@ -866,7 +886,7 @@ projects:* The requirements for the project* A strategy for the delivery phase* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__planners:duration: 14@@ -887,7 +907,7 @@ projects:* Depending on the identifies use cases, the individual Information Delivery Manuals will be defined* To handle the technological interfaces, a software topology will be defined and analyzed and verified* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__lead_bim_coordinators:duration: 18@@ -899,7 +919,7 @@ projects::reference: :completion_of_bim_execution_plan:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: bim.default_status_resolved+ :status: :default_status_resolved:type: default_type_milestone:assigned_to: :group__bim_coordinators:duration: 1@@ -913,7 +933,7 @@ projects::reference: :end_of_preparation_phase:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_managers:duration: 1@@ -924,7 +944,7 @@ projects::t_subject: Creating initial BIM model:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 54@@ -941,7 +961,7 @@ projects:* According to the gathered data from the customer, the initial model will be modelled* The model shall be modelled according to the LOD Matrices and contain the information needed* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_modellers:duration: 7@@ -960,7 +980,7 @@ projects:* The model shall be checked, according to the defined standards (conventions, LOD, ...) and revised* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__lead_bim_coordinators:duration: 2@@ -972,7 +992,7 @@ projects::reference: :submitting_initial_bim_model:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_modellers:duration: 1@@ -988,7 +1008,7 @@ projects::t_subject: Modelling, first cycle:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 66@@ -1004,7 +1024,7 @@ projects:* The external model will be referenced in the BIM platform, thus used for modelling the internal model* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_modellers:duration: 1@@ -1024,7 +1044,7 @@ projects:* The model will be created according to the BIM execution plan* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_modellers:duration: 6@@ -1043,7 +1063,7 @@ projects:* The model shall be checked, according to the defined standards (conventions, LOD, ...) and revised.* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_coordinators:duration: 1@@ -1055,7 +1075,7 @@ projects::reference: :submitting_bim_model:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_modellers:duration: 1@@ -1071,7 +1091,7 @@ projects::t_subject: Coordination, first cycle:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 77@@ -1087,7 +1107,7 @@ projects:* The different BIM models will be assembled and checked* The identified model specific issues will be communicated via BCF files* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_coordinators:duration: 3@@ -1095,7 +1115,7 @@ projects::t_subject: Issue management, first cycle:reference: :issue_management_first_cycle:description: ''- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__bim_coordinators:duration: 4@@ -1104,7 +1124,7 @@ projects::reference: :finishing_coordination_first_cycle:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__lead_bim_coordinators:duration: 1@@ -1120,7 +1140,7 @@ projects::t_subject: Modelling & coordinating, second cycle:reference: :modelling_and_coordinating_second_cycle:t_description: "## Goal\r\n\r\n* ...\r\n\r\n## Description\r\n\r\n* ..."- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__lead_bim_coordinators:duration: 1@@ -1132,7 +1152,7 @@ projects::reference: :modelling_and_coordinating_another_cycle:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__lead_bim_coordinators:duration: 1@@ -1143,7 +1163,7 @@ projects::t_subject: Modelling & coordinating, (n-th minus 1) cycle:reference: :modelling_and_coordinating_penultimate_cycle:t_description: "## Goal\r\n\r\n* ...\r\n\r\n## Description\r\n\r\n* ..."- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__lead_bim_coordinators:duration: 1@@ -1155,7 +1175,7 @@ projects::reference: :modelling_and_coordinating_last_cycle:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__bim_coordinators:duration: 1@@ -1167,7 +1187,7 @@ projects::reference: :finishing_modelling_and_coordinating:t_description: This type is hierarchically a parent of the types "Clash"and "Request", thus represents a general note.- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_coordinators:duration: 1@@ -1177,7 +1197,7 @@ projects:- :start: 88:t_subject: Use model for construction phase:description: ''- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:children:- :start: 88@@ -1194,7 +1214,7 @@ projects:* The Kickoff on the construction site includes an introduction to the model* All the objects should have the information needed for the assigned tasks. If not, data enrichment of the model needs to be done* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_coordinators:duration: 5@@ -1212,7 +1232,7 @@ projects:* New issues will be documented using BCF files as sticky notes for the model* The BCF files will be used to assign, track and correct issues* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_task:assigned_to: :group__bim_coordinators:duration: 101@@ -1220,7 +1240,7 @@ projects::t_subject: Finish construction:reference: :finish_construction:description: ''- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__bim_coordinators:duration: 1@@ -1236,7 +1256,7 @@ projects::t_subject: Issue management, construction phase:reference: :issue_management_construction_phase:description: ''- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:assigned_to: :group__planners:duration: 88@@ -1255,7 +1275,7 @@ projects:* The model contains the relevant information for the facility manager* The model can be used for the operating system of the building* ...- :status: default_status_new+ :status: :default_status_new:type: default_type_milestone:assigned_to: :group__lead_bim_coordinators:duration: 1@@ -1265,7 +1285,7 @@ projects:- :start: 211:t_subject: Asset Management:t_description: Enjoy your building :)- :status: default_status_new+ :status: :default_status_new:type: default_type_phase:duration: 1:relations:diff --git a/modules/bim/app/seeders/bim/basic_data/status_seeder.rb b/modules/bim/app/seeders/bim/basic_data/status_seeder.rbdeleted file mode 100644index df7144665c8..00000000000--- a/modules/bim/app/seeders/bim/basic_data/status_seeder.rb+++ /dev/null@@ -1,57 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2023 the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-module Bim- module BasicData- class StatusSeeder < ::BasicData::StatusSeeder- def data- color_names = [- 'blue-6', # new- 'orange-6', # in progress- 'green-3', # resolved- 'gray-3' # closed- ]-- # When selecting for an array of values, implicit order is applied- # so we need to restore values by their name.- colors_by_name = Color.where(name: color_names).index_by(&:name)- colors = color_names.collect { |name| colors_by_name[name].id }-- [- { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true,- position: 1 },- { name: I18n.t(:default_status_in_progress), color_id: colors[1], is_closed: false, is_default: false,- position: 2 },- { name: I18n.t('bim.default_status_resolved'), color_id: colors[2], is_closed: false,- is_default: false, position: 3 },- { name: I18n.t(:default_status_closed), color_id: colors[3], is_closed: true, is_default: false,- position: 4 }- ]- end- end- end-enddiff --git a/modules/bim/app/seeders/bim/basic_data/workflow_seeder.rb b/modules/bim/app/seeders/bim/basic_data/workflow_seeder.rbindex a4c80a41af5..c0a750ef8d6 100644--- a/modules/bim/app/seeders/bim/basic_data/workflow_seeder.rb+++ b/modules/bim/app/seeders/bim/basic_data/workflow_seeder.rb@@ -32,10 +32,10 @@ module Bimtypes = Type.alltypes = types.map { |t| { t.name => t.id } }.reduce({}, :merge)- new = Status.find_by(name: I18n.t(:default_status_new))- in_progress = Status.find_by(name: I18n.t(:default_status_in_progress))- closed = Status.find_by(name: I18n.t(:default_status_closed))- resolved = Status.find_by(name: I18n.t('bim.default_status_resolved'))+ new = seed_data.find_reference(:default_status_new)+ in_progress = seed_data.find_reference(:default_status_in_progress)+ closed = seed_data.find_reference(:default_status_closed)+ resolved = seed_data.find_reference(:default_status_resolved){types[I18n.t(:default_type_task)] => [new, in_progress, closed],@@ -51,10 +51,6 @@ module Bimdef type_seeder_class::Bim::BasicData::TypeSeederend-- def status_seeder_class- ::Bim::BasicData::StatusSeeder- endendendenddiff --git a/modules/bim/config/locales/en.yml b/modules/bim/config/locales/en.ymlindex 9247a5a7fd9..d4393d062f0 100644--- a/modules/bim/config/locales/en.yml+++ b/modules/bim/config/locales/en.yml@@ -7,7 +7,6 @@ en:default_type_issue: Issuedefault_type_remark: Remarkdefault_type_request: Request- default_status_resolved: Resolveddefault_priority_critical: Criticalbcf:diff --git a/modules/bim/lib/open_project/bim/patches/work_package_board_seeder_patch.rb b/modules/bim/lib/open_project/bim/patches/work_package_board_seeder_patch.rbindex 146bec0e455..92de42ad305 100644--- a/modules/bim/lib/open_project/bim/patches/work_package_board_seeder_patch.rb+++ b/modules/bim/lib/open_project/bim/patches/work_package_board_seeder_patch.rb@@ -43,10 +43,10 @@ module OpenProject::Bim::Patches::WorkPackageBoardSeederPatchdef seed_bcf_board_queriesstatuses(- 'default_status_new',- 'default_status_in_progress',- 'bim.default_status_resolved',- 'default_status_closed'+ :default_status_new,+ :default_status_in_progress,+ :default_status_resolved,+ :default_status_closed).map do |status|Query.new_default(project:, user:).tap do |query|# Make it public so that new members can see it toodiff --git a/modules/bim/lib/tasks/openproject-bim.rake b/modules/bim/lib/tasks/openproject-bim.rakeindex 435c79adfaa..9c4bd412261 100644--- a/modules/bim/lib/tasks/openproject-bim.rake+++ b/modules/bim/lib/tasks/openproject-bim.rake@@ -49,6 +49,10 @@ class Seedifier@written_work_packages_ids = []@projects = Project.where(identifier: @project_identifiers)+ raise "Warning: this class and the bim:seedify task have not been maintained when " \+ "work package 36933 was implemented as it was out-of-scope. It will probably " \+ "fail to produce the expected output."+all_work_packages = @projects.map { |project| project.work_packages.to_a }.flatten.sort_by(&:start_date)@base_date = all_work_packages.first.start_date.mondayenddiff --git a/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb b/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rbindex 1b9dac6cc6f..29e71394a0b 100644--- a/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb+++ b/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb@@ -77,6 +77,10 @@ describe RootSeeder,"User: OpenProject Admin" => 12)end++ it 'creates workflows' do+ expect(Workflow.count).to eq(182)+ endenddescribe 'demo data' dodiff --git a/spec/seeders/basic_data/status_seeder_spec.rb b/spec/seeders/basic_data/status_seeder_spec.rbnew file mode 100644index 00000000000..d91752964ef--- /dev/null+++ b/spec/seeders/basic_data/status_seeder_spec.rb@@ -0,0 +1,116 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'++RSpec.describe BasicData::StatusSeeder do+ shared_let(:seeding) do+ [+ # Color records needed by StatusSeeder+ BasicData::ColorSeeder,+ BasicData::ColorSchemeSeeder+ ].each { |seeder| seeder.new.seed! }+ end++ subject(:seeder) { described_class.new(seed_data) }++ let(:seed_data) { Source::SeedData.new(data_hash) }++ before do+ seeder.seed!+ end++ context 'with some statuses defined' do+ let(:data_hash) do+ YAML.load <<~SEEDING_DATA_YAML+ statuses:+ - reference: :status_new+ name: New+ color_name: cyan-7+ is_closed: false+ is_default: true+ position: 1+ - reference: :status_in_progress+ name: In progress+ color_name: grape-5+ position: 2+ - reference: :status_closed+ name: Closed+ color_name: gray-3+ is_closed: true+ position: 3+ SEEDING_DATA_YAML+ end++ it 'creates the corresponding statuses with the given attributes' do+ expect(Status.count).to eq(3)+ expect(Status.find_by(name: 'New')).to have_attributes(+ is_closed: false,+ is_default: true,+ position: 1+ )+ expect(Status.find_by(name: 'Closed')).to have_attributes(+ is_closed: true,+ is_default: false,+ position: 3+ )+ end++ it 'sets is_closed and is_default to false if not specified' do+ expect(Status.find_by(name: 'In progress')).to have_attributes(+ is_closed: false,+ is_default: false+ )+ end++ it 'looks color_id up from its name' do+ expect(Status.find_by(name: 'New')).to have_attributes(+ color_id: Color.find_by(name: 'cyan-7').id+ )+ end++ it 'references the status in the seed data' do+ created_status = Status.last+ expect(seed_data.find_reference(:status_closed)).to eq(created_status)+ end+ end++ context 'without statuses defined' do+ let(:data_hash) do+ YAML.load <<~SEEDING_DATA_YAML+ nothing here: ''+ SEEDING_DATA_YAML+ end++ it 'creates no statuses' do+ expect(Status.count).to eq(0)+ end+ end+enddiff --git a/spec/seeders/demo_data/project_seeder_spec.rb b/spec/seeders/demo_data/project_seeder_spec.rbindex 4fee678eb07..0ad174cdf81 100644--- a/spec/seeders/demo_data/project_seeder_spec.rb+++ b/spec/seeders/demo_data/project_seeder_spec.rb@@ -33,6 +33,9 @@ require 'spec_helper'RSpec.describe DemoData::ProjectSeeder dosubject(:project_seeder) { described_class.new(seed_data) }+ shared_let(:standard_seed_data) do+ Source::SeedDataLoader.get_data(edition: 'standard').only('statuses')+ endshared_let(:initial_seeding) do[# Color records needed by StatusSeeder and TypeSeeder@@ -40,7 +43,7 @@ RSpec.describe DemoData::ProjectSeeder doBasicData::ColorSchemeSeeder,# Status records needed by WorkPackageSeeder- Standard::BasicData::StatusSeeder,+ BasicData::StatusSeeder,# Type records needed by WorkPackageSeederStandard::BasicData::TypeSeeder,@@ -50,11 +53,14 @@ RSpec.describe DemoData::ProjectSeeder do# project admin role needed by ProjectSeederBasicData::BuiltinRolesSeeder,- BasicData::RoleSeeder- ].each { |seeder| seeder.new.seed! }+ BasicData::RoleSeeder,++ # Admin user needed by ProjectSeeder+ AdminUserSeeder+ ].each { |seeder| seeder.new(standard_seed_data).seed! }end- let(:seed_data) { Source::SeedData.new(project_data) }+ let(:seed_data) { standard_seed_data.merge(Source::SeedData.new(project_data)) }let(:project_data) { project_data_with_a_version }let(:project_data_with_a_version) do{@@ -70,14 +76,6 @@ RSpec.describe DemoData::ProjectSeeder do}end- before do- # Admin user needed by ProjectSeeder- # The AdminUserSeeder cannot be put in the initial_seeding block as it needs- # to add a reference to the created admin user in the seed_data for each- # example.- AdminUserSeeder.new(seed_data).seed!- end-it 'stores references to created versions in the seed data' doproject_seeder.seed!created_version = Version.find_by(name: 'The product backlog')@@ -118,7 +116,7 @@ RSpec.describe DemoData::ProjectSeeder do'work_packages' => [{'subject' => 'Some work package',- 'status' => 'default_status_new',+ 'status' => :default_status_new,'type' => 'default_type_task','version' => :product_backlog}diff --git a/spec/seeders/demo_data/work_package_seeder_spec.rb b/spec/seeders/demo_data/work_package_seeder_spec.rbindex eb5ac6c9645..3d14c7c72ce 100644--- a/spec/seeders/demo_data/work_package_seeder_spec.rb+++ b/spec/seeders/demo_data/work_package_seeder_spec.rb@@ -30,6 +30,9 @@ require 'spec_helper'describe DemoData::WorkPackageSeeder doshared_let(:work_week) { week_with_saturday_and_sunday_as_weekend }+ shared_let(:standard_seed_data) do+ Source::SeedDataLoader.get_data(edition: 'standard').only('statuses')+ endshared_let(:seeding) do[# Color records needed by StatusSeeder and TypeSeeder@@ -37,37 +40,34 @@ describe DemoData::WorkPackageSeeder doBasicData::ColorSchemeSeeder,# Status records needed by WorkPackageSeeder- Standard::BasicData::StatusSeeder,+ BasicData::StatusSeeder,# Type records needed by WorkPackageSeederStandard::BasicData::TypeSeeder,# IssuePriority records needed by WorkPackageSeederStandard::BasicData::PrioritySeeder,- ].each { |seeder| seeder.new.seed! }++ # Admin user needed by ProjectSeeder+ AdminUserSeeder+ ].each { |seeder| seeder.new(standard_seed_data).seed! }endlet(:project) { create(:project) }let(:new_project_role) { Role.find_by(name: I18n.t(:default_role_project_admin)) }- let(:closed_status) { Status.find_by(name: I18n.t(:default_status_closed)) }+ let(:closed_status) { seed_data.find_reference(:default_status_closed) }let(:work_packages_data) { [] }- let(:seed_data) { Source::SeedData.new('work_packages' => work_packages_data) }+ let(:seed_data) { standard_seed_data.merge(Source::SeedData.new('work_packages' => work_packages_data)) }def work_package_data(**attributes){start: 0,subject: "Some subject",- status: "default_status_new",+ status: :default_status_new,type: "default_type_task"}.merge(attributes).deep_stringify_keysendbefore do- # Admin user needed by ProjectSeeder- # The AdminUserSeeder cannot be put in the initial_seeding block as it needs- # to add a reference to the created admin user in the seed_data for each- # example.- AdminUserSeeder.new(seed_data).seed!-work_package_seeder = described_class.new(project, seed_data)work_package_seeder.seed!end@@ -263,65 +263,6 @@ describe DemoData::WorkPackageSeeder doendend- context 'with relations defined between multiple work packages' do- let(:work_packages_data) do- [- work_package_data(- subject: 'Predecessor',- reference: :wp_predecessor,- relations: [{- type: :relates,- to: :wp_child- }]- ),- work_package_data(- subject: 'Successor',- reference: :wp_successor,- relations: [{- type: :follows,- to: :wp_predecessor- }, {- type: :includes,- to: :wp_child- }],- children: [- work_package_data(- subject: 'Child',- reference: :wp_child,- relations: [{- type: :blocks,- to: :wp_successor- }]- )- ]- )- ]- end-- it 'creates the given relationships between the work packages' do- predecessor = WorkPackage.find_by!(subject: 'Predecessor')- successor = WorkPackage.find_by!(subject: 'Successor')- child = WorkPackage.find_by!(subject: 'Child')-- expect(Relation.find_by!(relation_type: Relation::TYPE_RELATES)).to have_attributes(- from_id: predecessor.id,- to_id: child.id- )- expect(Relation.find_by!(relation_type: Relation::TYPE_FOLLOWS)).to have_attributes(- from_id: successor.id,- to_id: predecessor.id- )- expect(Relation.find_by!(relation_type: Relation::TYPE_INCLUDES)).to have_attributes(- from_id: successor.id,- to_id: child.id- )- expect(Relation.find_by!(relation_type: Relation::TYPE_BLOCKS)).to have_attributes(- from_id: child.id,- to_id: successor.id- )- end- end-context 'with a work package description referencing a work package with ##wp:ref notation' dolet(:work_packages_data) do[@@ -332,7 +273,7 @@ describe DemoData::WorkPackageSeeder do]end- it 'updates the description with a link to the work package with the right id' do+ it 'creates parent-child relations between work packages' dowp_major, wp_other = WorkPackage.order(:id).to_aexpect(wp_other.description).to eq("Check [this work package](/projects/#{project.identifier}/" \@@ -342,7 +283,7 @@ describe DemoData::WorkPackageSeeder docontext 'with a work package description referencing a query with ##query:ref notation' dolet(:seed_data) do- seed_data = Source::SeedData.new('work_packages' => work_packages_data)+ seed_data = standard_seed_data.merge(Source::SeedData.new('work_packages' => work_packages_data))seed_data.store_reference(:q_project_plan, query)seed_dataend@@ -362,7 +303,7 @@ describe DemoData::WorkPackageSeeder docontext 'with a work package description referencing a sprint with ##sprint:ref notation' dolet(:seed_data) do- seed_data = Source::SeedData.new('work_packages' => work_packages_data)+ seed_data = standard_seed_data.merge(Source::SeedData.new('work_packages' => work_packages_data))seed_data.store_reference(:sprint_backlog, sprint)seed_dataend@@ -382,7 +323,7 @@ describe DemoData::WorkPackageSeeder dodescribe 'assigned_to' dolet(:seed_data) do- seed_data = Source::SeedData.new('work_packages' => work_packages_data)+ seed_data = standard_seed_data.merge(Source::SeedData.new('work_packages' => work_packages_data))seed_data.store_reference(:user_bernard, a_user)seed_dataenddiff --git a/spec/seeders/root_seeder_standard_edition_spec.rb b/spec/seeders/root_seeder_standard_edition_spec.rbindex 79aa92f36cf..e75cc0abf7d 100644--- a/spec/seeders/root_seeder_standard_edition_spec.rb+++ b/spec/seeders/root_seeder_standard_edition_spec.rb@@ -77,6 +77,10 @@ describe RootSeeder,"team_planner" => 1)end++ it 'creates workflows' do+ expect(Workflow.count).to eq(1172)+ endenddescribe 'demo data' dodiff --git a/spec/seeders/seeder_spec.rb b/spec/seeders/seeder_spec.rbindex dcabc54aaf7..a4a35282f20 100644--- a/spec/seeders/seeder_spec.rb+++ b/spec/seeders/seeder_spec.rb@@ -47,4 +47,17 @@ RSpec.describe Seeder doexpect(seeder.user).to be_nilendend++ describe '#true?' do+ {+ 'true' => true,+ 'false' => false,+ '' => false,+ nil => false+ }.each do |value, expected|+ it "returns #{expected} when value is #{value.inspect}" do+ expect(seeder.true?(value)).to eq(expected)+ end+ end+ endenddiff --git a/spec/seeders/setting_seeder_spec.rb b/spec/seeders/setting_seeder_spec.rbindex 0037471d4ed..01fce794bec 100644--- a/spec/seeders/setting_seeder_spec.rb+++ b/spec/seeders/setting_seeder_spec.rb@@ -29,20 +29,32 @@require 'spec_helper'describe BasicData::SettingSeeder do- subject { described_class.new }+ subject { described_class.new(standard_seed_data) }let(:new_project_role) { Role.find_by(name: I18n.t(:default_role_project_admin)) }- let(:closed_status) { Status.find_by(name: I18n.t(:default_status_closed)) }+ let(:closed_status) { standard_seed_data.find_reference(:default_status_closed) }++ let(:standard_seed_data) do+ Source::SeedDataLoader.get_data(edition: 'standard').only('statuses')+ endbefore doallow(ActionMailer::Base).to receive(:perform_deliveries).and_return(false)allow(Delayed::Worker).to receive(:delay_jobs).and_return(false)- BasicData::BuiltinRolesSeeder.new.seed!- BasicData::RoleSeeder.new.seed!- BasicData::ColorSchemeSeeder.new.seed!- Standard::BasicData::StatusSeeder.new.seed!- described_class.new.seed!+ [+ BasicData::BuiltinRolesSeeder,+ BasicData::RoleSeeder,++ # Color records needed by StatusSeeder and TypeSeeder+ BasicData::ColorSchemeSeeder,++ # Status records needed by WorkPackageSeeder+ BasicData::StatusSeeder,++ # subject under test+ described_class+ ].each { |seeder| seeder.new(standard_seed_data).seed! }enddef reseed!diff --git a/spec/seeders/source/seed_data_spec.rb b/spec/seeders/source/seed_data_spec.rbindex 92e5f2e2c1a..e27bbe84735 100644--- a/spec/seeders/source/seed_data_spec.rb+++ b/spec/seeders/source/seed_data_spec.rb@@ -51,6 +51,7 @@ RSpec.describe Source::SeedData doobject = Object.newseed_data.store_reference(nil, object)expect(seed_data.find_reference(nil)).to be_nil+ expect(seed_data.find_reference(nil, default: 'hello')).to be_nilendit 'raises an error when the reference is already used' do@@ -58,5 +59,77 @@ RSpec.describe Source::SeedData doexpect { seed_data.store_reference(:ref, Object.new) }.to raise_error(ArgumentError)end++ it 'raises an error if the reference is not found' do+ expect { seed_data.find_reference(:ref) }+ .to raise_error(ArgumentError, 'Nothing registered with reference :ref')+ end++ it 'returns the given default value if the reference is not found' do+ expect(seed_data.find_reference(:ref, default: 42)).to eq(42)+ expect(seed_data.find_reference(:ref, default: 'hello')).to eq('hello')+ expect(seed_data.find_reference(:ref, default: nil)).to be_nil+ end+ end++ describe '#only' do+ let(:original_seed_data) do+ described_class.new(+ 'cats' => ['Oreo', 'Billy'],+ 'dogs' => ['Rex', 'Volt']+ )+ end++ it 'creates a copy of the seeding with only the given top level keys' do+ seed_data_dogs_only = original_seed_data.only('dogs')+ expect(seed_data_dogs_only.lookup('cats')).to be_nil+ expect(seed_data_dogs_only.lookup('dogs')).to eq(['Rex', 'Volt'])+ end++ it 'creates a copy of the inner registry storing references' do+ seed_data_dogs_only = original_seed_data.only('dogs')+ seed_data_dogs_only.store_reference(:ref, 'Puppy')+ expect(seed_data_dogs_only.find_reference(:ref)).to eq 'Puppy'+ expect(original_seed_data.find_reference(:ref, default: nil)).not_to eq 'Puppy'+ end+ end++ describe '#merge' do+ let(:dogs_seed_data) do+ described_class.new('dogs' => ['Rex', 'Volt'])+ end+ let(:cats_seed_data) do+ described_class.new('cats' => ['Oreo', 'Billy'])+ end++ it 'creates a new seed data instance with the data merged from both' do+ merged_seed_data = dogs_seed_data.merge(cats_seed_data)+ merged_seed_data.lookup('cats')+ expect(merged_seed_data.lookup('cats')).to eq(['Oreo', 'Billy'])+ expect(merged_seed_data.lookup('dogs')).to eq(['Rex', 'Volt'])+ end++ it 'creates a new seed data instance with the registry merged from both' do+ dogs_seed_data.store_reference(:best_dog, 'Pitou')+ cats_seed_data.store_reference(:best_cat, 'Kuzco')+ merged_seed_data = dogs_seed_data.merge(cats_seed_data)+ expect(merged_seed_data.find_reference(:best_dog)).to eq 'Pitou'+ expect(merged_seed_data.find_reference(:best_cat)).to eq 'Kuzco'+ # no leaking in original data+ expect(dogs_seed_data.find_reference(:best_cat, default: nil)).to be_nil+ expect(cats_seed_data.find_reference(:best_dog, default: nil)).to be_nil+ end++ it 'on conflicts, the keys from the given seed data are used' do+ dogs_seed_data.store_reference(:best_animal, 'Balto the dog')+ cats_seed_data.store_reference(:best_animal, 'Figaro the cat')+ merged_seed_data = dogs_seed_data.merge(cats_seed_data)+ expect(merged_seed_data.find_reference(:best_animal)).to eq('Figaro the cat')++ merged_seed_data = dogs_seed_data.merge(described_class.new('dogs' => ['Scooby-Doo', 'Droopy']))+ merged_seed_data.lookup(:dogs)+ expect(merged_seed_data.lookup('dogs')).to eq(['Scooby-Doo', 'Droopy'])+ expect(dogs_seed_data.lookup('dogs')).to eq(['Rex', 'Volt'])+ endendend