Skip to content

Commit

Permalink
Merge pull request #2673 from lgalis/azure_container_disk_size_displa…
Browse files Browse the repository at this point in the history
…y_fix

Disk Name should not display 0 for unavailable Used/Provisioned size
  • Loading branch information
Dan Clarizio committed Nov 8, 2017
2 parents 310c36a + baf246f commit 2faeb15
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/helpers/textual_mixins/textual_devices.rb
Expand Up @@ -42,11 +42,10 @@ def disks_attributes
location = disk.location
size = disk.size
prov = disk.used_percent_of_provisioned
device_name = _("Hard Disk (%{controller_type} %{location}), Size %{size}, " \
"Percent Used Provisioned Space %{space}") % {:controller_type => ctrl_type,
:location => location,
:size => size,
:space => prov}
device_name = _("Hard Disk (%{controller_type} %{location}), Size %{size}") % {:controller_type => ctrl_type,
:location => location,
:size => size}
device_name << _(", Percent Used Provisioned Space %{space}") % {:space => prov} unless disk.size_on_disk.nil?
description = _("%{filename}, Mode: %{mode}") % {:filename => disk.filename, :mode => disk.mode}
Device.new(device_name, description, nil, :disk)
end
Expand Down
12 changes: 12 additions & 0 deletions spec/helpers/textual_mixins/textual_devices_spec.rb
Expand Up @@ -35,6 +35,18 @@
end
it { is_expected.not_to be_empty }
end

context "with hdd with no size_on_disk collected (AZURE)" do
let(:hw) do
FactoryGirl.create(:hardware,
:disks => [FactoryGirl.create(:disk,
:device_type => "disk",
:size => "1072693248",
:controller_type => "AZURE")])
end
it { expect(subject[0][:name]).to include("Hard Disk (AZURE ), Size 1072693248") }
it { expect(subject[0][:name]).not_to include("Percent Used Provisioned Space") }
end
end

describe "#network_attributes" do
Expand Down

0 comments on commit 2faeb15

Please sign in to comment.