Skip to content

Commit

Permalink
fix: Add back missing numbered by tag for VM-s
Browse files Browse the repository at this point in the history
  • Loading branch information
mromulus committed Feb 19, 2024
1 parent c93e97b commit 52b31df
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
15 changes: 13 additions & 2 deletions app/calculation/generate_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -164,6 +173,7 @@ def instance_result
name: "#{node.name} number #{subject.team_number}",
config_map: {},
children: [],
priority: 31 + node.depth * 3
}
end
else
Expand All @@ -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
Expand Down
25 changes: 22 additions & 3 deletions spec/calculations/generate_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand All @@ -452,7 +469,8 @@
id: ActorAPIName.result_for(actor, number: 1),
name: "#{actor.name} number 1",
children: [],
config_map: {}
config_map: {},
priority: 34
}
}

Expand All @@ -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
}
}

Expand Down

0 comments on commit 52b31df

Please sign in to comment.