Skip to content

Commit

Permalink
Changes based on CR
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 15, 2019
1 parent 069f193 commit 0c7c531
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/network/edit_nic_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def update_routes?(previous_name)
Popup.YesNoHeadline(
Label.WarningMsg,
# TRANSLATORS: Ask for fixing a possible conflict after renaming
# an interface, %1 is the previous interface name %2 is the current one
# an interface, %s are the previous and current interface names
format(_("The interface %s has been renamed to %s. There are \n" \
"some routes that still use the previous name.\n\n" \
"Would you like to update them now?\n"),
Expand Down
17 changes: 15 additions & 2 deletions src/modules/LanItems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,18 @@ def GetDeviceNames(items)
items.map { |itemId| GetDeviceName(itemId) }.reject(&:empty?)
end

# Return the actual name of the current {LanItem}
#
# @return [String] the actual name for the current device
def current_name
renamed?(@current) ? renamed_to(@current) : GetDeviceName(@current)
current_name_for?(@current)
end

# Return the current device names
#
# @ return [Array<String>]
def current_device_names
GetNetcardInterfaces().map { |i| renamed?(i) ? renamed_to(i) : GetDeviceName(i) }.reject(&:empty?)
GetNetcardInterfaces().map { |i| current_name_for?(i) }.reject(&:empty?)
end

# Returns device name for current lan item (see LanItems::current)
Expand Down Expand Up @@ -2647,6 +2653,13 @@ def enslaved?(ifcfg_name)

private

# Return the current name of the {LanItem} given
#
# @param item_id [Integer] a key for {#Items}
def current_name_for?(item_id)
renamed?(item_id) ? renamed_to(item_id) : GetDeviceName(item_id)
end

# Checks if given lladdr can be written into ifcfg
#
# @param lladdr [String] logical link address, usually MAC address in case
Expand Down
6 changes: 1 addition & 5 deletions test/lib/network/edit_nic_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
require "yast"
require "network/edit_nic_name"

current_name = "spec0".freeze
new_name = "new1".freeze
existing_new_name = "existing_new_name".freeze

Yast.import "LanItems"

describe Yast::EditNicName do
let(:subject) { described_class.new }
let(:current_name) { "spec0" }
let(:new_name) { "new1" }
let(:existing_new_name) { existing_new_name }
let(:existing_new_name) { "existing_new_name" }
let(:interface_hwinfo) { { "dev_name" => current_name, "mac" => "00:01:02:03:04:05" } }

describe "#run" do
Expand Down

0 comments on commit 0c7c531

Please sign in to comment.