Skip to content

Commit

Permalink
Updated based on CR.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jan 17, 2017
1 parent f8b8bac commit 9344250
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/lib/network/lan_items_summary.rb
Expand Up @@ -47,7 +47,6 @@ def default
next if !Yast::LanItems.IsItemConfigured(item)

ifcfg = LanItems.GetDeviceMap(item) || {}

items << Summary.Device(conf["ifcfg"], ifcfg_protocol(ifcfg))
end

Expand All @@ -56,7 +55,7 @@ def default
Summary.DevicesList(items)
end

# Generates a one line text summary showing the .
# Generates a one line text summary for the configured interfaces.
#
# @example with one configured interface
# LanItemsSummary.new.one_line
Expand All @@ -76,7 +75,6 @@ def one_line
next if !LanItems.IsItemConfigured(item)

ifcfg = LanItems.GetDeviceMap(item) || {}

protocols << ifcfg_protocol(ifcfg)

configured << conf["ifcfg"]
Expand All @@ -86,11 +84,12 @@ def one_line

case configured.size
when 0
return _("Not configured")
return Summary.NotConfigured
when 1
output << configured.join(", ")
else
output << "Multiple Interfaces"
# TRANSLATORS: informs that multiple interfaces are configured
output << _("Multiple Interfaces")
end

output.join(" / ")
Expand Down
17 changes: 9 additions & 8 deletions test/lan_items_summary_test.rb
Expand Up @@ -6,6 +6,8 @@
Yast.import "LanItems"

describe Yast::LanItemsSummary do
MULTIPLE_INTERFACES = N_("Multiple Interfaces")

let(:dhcp_maps) do
[
{ "BOOTPROTO" => "dhcp" },
Expand All @@ -19,9 +21,8 @@
0 => { "ifcfg" => "eth0" },
1 => { "ifcfg" => "eth1" },
2 => { "ifcfg" => "br0" }
}
}.freeze
end
let(:no_interfaces) { _("Not configured") }

before do
allow(Yast::LanItems).to receive(:Items).and_return(items)
Expand All @@ -32,7 +33,7 @@
end

describe "#default" do
it "retuns a Richtext summary of the configured interfaces" do
it "returns a Richtext summary of the configured interfaces" do
expect(subject.default)
.to eql "<ul>" \
"<li><p>eth0<br>DHCP</p></li>" \
Expand All @@ -50,13 +51,13 @@

describe "#one_line" do
it "returns a plain text summary of the configured interfaces in one line" do
expect(subject.one_line).to eql "Multiple Interfaces"
expect(subject.one_line).to eql(MULTIPLE_INTERFACES)
end

context "when there are no configured interfaces" do
let(:items) { {} }
it "returns 'Not configured'" do
expect(subject.one_line).to eql(no_interfaces)
it "returns Summary.NotConfigured" do
expect(subject.one_line).to eql(Yast::Summary.NotConfigured)
end
end

Expand All @@ -75,15 +76,15 @@
let(:dhcp_maps) { [{ "BOOTPROTO" => "dhcp" }, { "BOOTPROTO" => "dhcp" }] }

it "returns the bootproto and 'Multiple Interfaces'" do
expect(subject.one_line).to eql "DHCP / Multiple Interfaces"
expect(subject.one_line).to eql("DHCP / #{MULTIPLE_INTERFACES}")
end
end

context "with different bootproto" do
let(:dhcp_maps) { [{ "BOOTPROTO" => "DHCP" }, { "IPADDR" => "1.2.3.4" }] }

it "returns 'Multiple Interfaces'" do
expect(subject.one_line).to eql "Multiple Interfaces"
expect(subject.one_line).to eql(MULTIPLE_INTERFACES)
end
end
end
Expand Down

0 comments on commit 9344250

Please sign in to comment.