diff --git a/app/seeders/basic_data/life_cycle_seeder.rb b/app/seeders/basic_data/life_cycle_seeder.rb index 0836e51b1964..b2466542bd46 100644 --- a/app/seeders/basic_data/life_cycle_seeder.rb +++ b/app/seeders/basic_data/life_cycle_seeder.rb @@ -27,13 +27,6 @@ #++ module BasicData class LifeCycleSeeder < ModelSeeder - REQUIRED_COLOURS = %i[ - default_color_orange_dark - default_color_red_dark - default_color_magenta_light - default_color_green_yellow - ].freeze - self.model_class = LifeCycle self.seed_data_model_key = "life_cycles" self.needs = [ @@ -68,7 +61,8 @@ def color_seeder def missing_colors # Build map for color names and references for a reverse lookup # ie: { "Orange (dark)" => :default_color_orange_dark, "Red (dark)"=>:default_color_red_dark } - required_color_map = REQUIRED_COLOURS.each_with_object({}) do |reference, colors| + required_colors = models_data.pluck("color_name") + required_color_map = required_colors.each_with_object({}) do |reference, colors| color_name = color_seeder.mapped_models_data.dig(reference, :name) or raise ArgumentError, "Could not find required color #{reference} in seed data definition." colors[color_name] = reference diff --git a/spec/seeders/basic_data/life_cycle_seeder_spec.rb b/spec/seeders/basic_data/life_cycle_seeder_spec.rb index 4eb3ed688b90..6481d6a065eb 100644 --- a/spec/seeders/basic_data/life_cycle_seeder_spec.rb +++ b/spec/seeders/basic_data/life_cycle_seeder_spec.rb @@ -45,6 +45,10 @@ name: Initiating type: Stage color_name: :default_color_orange_dark + - reference: :default_life_cycle_ready_for_executing + name: Ready for Executing + type: Gate + color_name: :default_color_purple - reference: :default_life_cycle_planning name: Planning type: Stage @@ -62,10 +66,13 @@ shared_examples_for "creates the life_cycles seeds" do it "creates the corresponding life cycles with the given attributes" do - expect(LifeCycle.count).to eq(4) + expect(LifeCycle.count).to eq(5) expect(Stage.find_by(name: "Initiating")).to have_attributes( color_id: Color.find_by(name: "Orange (dark)").id ) + expect(Gate.find_by(name: "Ready for Executing")).to have_attributes( + color_id: Color.find_by(name: "Purple").id + ) expect(Stage.find_by(name: "Planning")).to have_attributes( color_id: Color.find_by(name: "Red (dark)").id ) @@ -97,6 +104,8 @@ # using the first seed data as the expected value expect(second_seed_data.find_reference(:default_life_cycle_initiating)) .to eq(seed_data.find_reference(:default_life_cycle_initiating)) + expect(second_seed_data.find_reference(:default_life_cycle_ready_for_executing)) + .to eq(seed_data.find_reference(:default_life_cycle_ready_for_executing)) expect(second_seed_data.find_reference(:default_life_cycle_planning)) .to eq(seed_data.find_reference(:default_life_cycle_planning)) expect(second_seed_data.find_reference(:default_life_cycle_executing)) @@ -128,6 +137,9 @@ - reference: :default_color_red_dark name: Red (dark) hexcode: "#F05823" + - reference: :default_color_purple + name: Purple + hexcode: "#682D91" - reference: :default_color_magenta_light name: Magenta (light) hexcode: "#EC038A"