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

Fix spec by setting ColorSeeder.attribute_names_for_lookups to allow existing colors to be looked up

Dombi Attilae056fbc5219a
diff --git a/app/seeders/basic_data/color_seeder.rb b/app/seeders/basic_data/color_seeder.rb
index 225c372b704..760ec3ed6cf 100644
--- a/app/seeders/basic_data/color_seeder.rb
+++ b/app/seeders/basic_data/color_seeder.rb
@@ -29,6 +29,7 @@ module BasicData
class ColorSeeder < ModelSeeder
self.model_class = Color
self.seed_data_model_key = "colors"
+ self.attribute_names_for_lookups = %i[name]
def model_attributes(color_data)
{
diff --git a/app/seeders/source/seed_data.rb b/app/seeders/source/seed_data.rb
index f3813a98e8c..13f9726bfe3 100644
--- a/app/seeders/source/seed_data.rb
+++ b/app/seeders/source/seed_data.rb
@@ -60,7 +60,10 @@ class Source::SeedData
default
else
references = [reference, *fallbacks].map(&:inspect)
- message = "Nothing registered with #{'reference'.pluralize(references.count)} #{references.to_sentence(locale: false)}"
+ message = <<~STRING
+ Nothing registered with #{'reference'.pluralize(references.count)} #{references.to_sentence(locale: false)}
+ Perhaps you forgot to add the `attribute_names_for_lookups` for your seeder?
+ STRING
raise ArgumentError, message
end
end
diff --git a/modules/bim/app/seeders/bim/basic_data_seeder.rb b/modules/bim/app/seeders/bim/basic_data_seeder.rb
index fd404d89db3..a8ec9238e1d 100644
--- a/modules/bim/app/seeders/bim/basic_data_seeder.rb
+++ b/modules/bim/app/seeders/bim/basic_data_seeder.rb
@@ -37,6 +37,7 @@ module Bim
::BasicData::TimeEntryActivitySeeder,
::BasicData::ColorSeeder,
::BasicData::ColorSchemeSeeder,
+ ::BasicData::LifeCycleSeeder,
::BasicData::WorkflowSeeder,
::BasicData::PrioritySeeder,
::Bim::BasicData::SettingSeeder,
diff --git a/spec/seeders/root_seeder_standard_edition_spec.rb b/spec/seeders/root_seeder_standard_edition_spec.rb
index c86d87d6be3..9227a442464 100644
--- a/spec/seeders/root_seeder_standard_edition_spec.rb
+++ b/spec/seeders/root_seeder_standard_edition_spec.rb
@@ -63,6 +63,7 @@ RSpec.describe RootSeeder,
expect(VersionSetting.count).to eq 4
expect(Boards::Grid.count).to eq 5
expect(Boards::Grid.count { |grid| grid.options.has_key?(:filters) }).to eq 1
+ expect(LifeCycle.count).to eq 4
end
it "links work packages to their version" do
@@ -171,6 +172,7 @@ RSpec.describe RootSeeder,
expect(Version.count).to eq 4
expect(VersionSetting.count).to eq 4
expect(Boards::Grid.count).to eq 5
+ expect(LifeCycle.count).to eq 4
end
end
end
diff --git a/spec/seeders/source/seed_data_spec.rb b/spec/seeders/source/seed_data_spec.rb
index 2e701c2376e..7da540555b9 100644
--- a/spec/seeders/source/seed_data_spec.rb
+++ b/spec/seeders/source/seed_data_spec.rb
@@ -62,11 +62,11 @@ RSpec.describe Source::SeedData do
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")
+ .to raise_error(ArgumentError, /Nothing registered with reference :ref/)
expect { seed_data.find_reference(:ref, :other_ref) }
- .to raise_error(ArgumentError, "Nothing registered with references :ref and :other_ref")
+ .to raise_error(ArgumentError, /Nothing registered with references :ref and :other_ref/)
expect { seed_data.find_reference(:ref, :other_ref, :yet_another_ref) }
- .to raise_error(ArgumentError, "Nothing registered with references :ref, :other_ref, and :yet_another_ref")
+ .to raise_error(ArgumentError, /Nothing registered with references :ref, :other_ref, and :yet_another_ref/)
end
it "returns the given default value if the reference is not found" do