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

[50965] Add default % Complete for seeded statuses

Christophe Bliard715b1162a49d
diff --git a/app/seeders/basic_data/status_seeder.rb b/app/seeders/basic_data/status_seeder.rb
index 9d9069ea33c..6f26f64c155 100644
--- a/app/seeders/basic_data/status_seeder.rb
+++ b/app/seeders/basic_data/status_seeder.rb
@@ -28,7 +28,7 @@
module BasicData
class StatusSeeder < ModelSeeder
self.model_class = Status
- self.seed_data_model_key = 'statuses'
+ self.seed_data_model_key = "statuses"
self.attribute_names_for_lookups = %i[name is_closed is_default]
self.needs = [
BasicData::ColorSeeder,
@@ -37,11 +37,12 @@ module BasicData
def model_attributes(status_data)
{
- 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']
+ name: status_data["name"],
+ color_id: color_id(status_data["color_name"]),
+ default_done_ratio: status_data["default_done_ratio"] || 0,
+ is_closed: true?(status_data["is_closed"]),
+ is_default: true?(status_data["is_default"]),
+ position: status_data["position"]
}
end
end
diff --git a/app/seeders/standard.yml b/app/seeders/standard.yml
index e64223af7f2..668713e3249 100644
--- a/app/seeders/standard.yml
+++ b/app/seeders/standard.yml
@@ -49,60 +49,74 @@ statuses:
- reference: :default_status_new
t_name: New
color_name: cyan-7
+ default_done_ratio: 0
is_default: true
position: 1
- reference: :default_status_in_specification
t_name: In specification
color_name: blue-2
+ default_done_ratio: 10
position: 2
- reference: :default_status_specified
t_name: Specified
color_name: blue-2
+ default_done_ratio: 20
position: 3
- reference: :default_status_confirmed
t_name: Confirmed
color_name: violet-2
+ default_done_ratio: 20
position: 4
- reference: :default_status_to_be_scheduled
t_name: To be scheduled
color_name: yellow-2
+ default_done_ratio: 20
position: 5
- reference: :default_status_scheduled
t_name: Scheduled
color_name: lime-2
+ default_done_ratio: 20
position: 6
- reference: :default_status_in_progress
t_name: In progress
color_name: grape-5
+ default_done_ratio: 50
position: 7
- reference: :default_status_developed
t_name: Developed
color_name: green-3
+ default_done_ratio: 70
position: 8
- reference: :default_status_in_testing
t_name: In testing
color_name: cyan-5
+ default_done_ratio: 80
position: 9
- reference: :default_status_tested
t_name: Tested
color_name: teal-6
+ default_done_ratio: 90
position: 10
- reference: :default_status_test_failed
t_name: Test failed
color_name: red-5
+ default_done_ratio: 70
position: 11
- reference: :default_status_closed
t_name: Closed
color_name: gray-3
+ default_done_ratio: 100
is_closed: true
position: 12
- reference: :default_status_on_hold
t_name: On hold
color_name: orange-3
+ default_done_ratio: 0
position: 13
- reference: :default_status_rejected
t_name: Rejected
color_name: red-3
+ default_done_ratio: 0
is_closed: true
position: 14
diff --git a/modules/bim/app/seeders/bim.yml b/modules/bim/app/seeders/bim.yml
index cdb6e5de451..b089a0b312e 100644
--- a/modules/bim/app/seeders/bim.yml
+++ b/modules/bim/app/seeders/bim.yml
@@ -70,19 +70,23 @@ statuses:
t_name: New
color_name: blue-6
is_default: true
+ default_done_ratio: 0
position: 1
- reference: :default_status_in_progress
t_name: In progress
color_name: orange-6
+ default_done_ratio: 40
position: 2
- reference: :default_status_resolved
t_name: Resolved
color_name: green-3
+ default_done_ratio: 80
position: 3
- reference: :default_status_closed
t_name: Closed
color_name: gray-3
is_closed: true
+ default_done_ratio: 100
position: 4
time_entry_activities:
diff --git a/spec/seeders/basic_data/status_seeder_spec.rb b/spec/seeders/basic_data/status_seeder_spec.rb
index cd556c3874d..a35b4e31009 100644
--- a/spec/seeders/basic_data/status_seeder_spec.rb
+++ b/spec/seeders/basic_data/status_seeder_spec.rb
@@ -28,10 +28,10 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe BasicData::StatusSeeder do
- include_context 'with basic seed data'
+ include_context "with basic seed data"
subject(:seeder) { described_class.new(seed_data) }
@@ -41,7 +41,7 @@ RSpec.describe BasicData::StatusSeeder do
seeder.seed!
end
- context 'with some statuses defined' do
+ context "with some statuses defined" do
let(:data_hash) do
YAML.load <<~SEEDING_DATA_YAML
statuses:
@@ -54,48 +54,61 @@ RSpec.describe BasicData::StatusSeeder do
- reference: :status_in_progress
name: In progress
color_name: grape-5
+ default_done_ratio: 50
position: 2
- reference: :status_closed
name: Closed
color_name: gray-3
+ default_done_ratio: 100
is_closed: true
position: 3
SEEDING_DATA_YAML
end
- it 'creates the corresponding statuses with the given attributes' do
+ 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(
+ 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(
+ expect(Status.find_by(name: "In progress")).to have_attributes(
+ default_done_ratio: 50,
+ position: 2
+ )
+ expect(Status.find_by(name: "Closed")).to have_attributes(
is_closed: true,
is_default: false,
+ default_done_ratio: 100,
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(
+ 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
+ it "sets default_done_ratio to 0 if not specified" do
+ expect(Status.find_by(name: "New")).to have_attributes(
+ default_done_ratio: 0
+ )
+ 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
+ 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
- context 'when seeding a second time' do
+ context "when seeding a second time" do
subject(:second_seeder) { described_class.new(second_seed_data) }
let(:second_seed_data) { basic_seed_data.merge(Source::SeedData.new(data_hash)) }
@@ -104,7 +117,7 @@ RSpec.describe BasicData::StatusSeeder do
second_seeder.seed!
end
- it 'registers existing matching statuses as references in the seed data' do
+ it "registers existing matching statuses as references in the seed data" do
# using the first seed data as the expected value
expect(second_seed_data.find_reference(:status_closed))
.to eq(seed_data.find_reference(:status_closed))
@@ -116,14 +129,14 @@ RSpec.describe BasicData::StatusSeeder do
end
end
- context 'without statuses defined' do
+ 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
+ it "creates no statuses" do
expect(Status.count).to eq(0)
end
end