diff --git a/app/calculation/generate_tags.rb b/app/calculation/generate_tags.rb index b2fd03db..c6820a32 100644 --- a/app/calculation/generate_tags.rb +++ b/app/calculation/generate_tags.rb @@ -17,7 +17,7 @@ def result when Capability capability_result when API::V3::InstancePresenter - instance_result || [] + api_instance_result || [] when Enumerable subject.map { |item| self.class.result_for(item, options) }.flatten else @@ -113,6 +113,15 @@ def network_result def virtual_machine_result [].tap do |results| + if subject.numbered_actor && !subject.numbered_actor.subtree.include?(subject.actor) + results << { + id: ActorAPIName.result_for(subject.actor, numbered_by: subject.numbered_actor), + name: "#{subject.actor.name}, numbered by #{subject.numbered_actor.name}", + config_map: {}, + children: [], + priority: 32 + subject.actor.depth * 3 + } + end if subject.customization_specs.size > 1 results << { id: "#{subject.name.tr('-', '_')}_all_specs", @@ -151,7 +160,7 @@ def capability_result }] end - def instance_result + def api_instance_result return if !subject.team_number actor = subject.spec.virtual_machine.actor @@ -164,6 +173,7 @@ def instance_result name: "#{node.name} number #{subject.team_number}", config_map: {}, children: [], + priority: 31 + node.depth * 3 } end else @@ -172,6 +182,7 @@ def instance_result name: "#{actor.name}, numbered by #{nr_actor.name} - number #{subject.team_number}", config_map: {}, children: [], + priority: 32 + actor.depth * 3 }] end end diff --git a/spec/calculations/generate_tags_spec.rb b/spec/calculations/generate_tags_spec.rb index e3eb9793..d77e85fb 100644 --- a/spec/calculations/generate_tags_spec.rb +++ b/spec/calculations/generate_tags_spec.rb @@ -89,6 +89,22 @@ it { is_expected.to include(result) } end + + context 'numbered by another actor' do + let(:virtual_machine) { create(:virtual_machine, numbered_by:) } + let(:numbered_by) { create(:actor, number: 2) } + let(:result) { + { + id: ActorAPIName.result_for(virtual_machine.actor, numbered_by:), + name: "#{virtual_machine.actor.name}, numbered by #{numbered_by.name}", + config_map: {}, + children: [], + priority: 32 + } + } + + it { is_expected.to include(result) } + end end context 'for customization specs' do @@ -436,7 +452,8 @@ id: ActorAPIName.result_for(vm.actor, number: 1, numbered_by: numbered_actor), name: "#{vm.actor.name}, numbered by #{numbered_actor.name} - number 1", children: [], - config_map: {} + config_map: {}, + priority: 32 } } @@ -452,7 +469,8 @@ id: ActorAPIName.result_for(actor, number: 1), name: "#{actor.name} number 1", children: [], - config_map: {} + config_map: {}, + priority: 34 } } @@ -461,7 +479,8 @@ id: ActorAPIName.result_for(root_actor, number: 1), name: "#{root_actor.name} number 1", children: [], - config_map: {} + config_map: {}, + priority: 31 } }