Skip to content

Commit

Permalink
Do not validate whether an interface name exists if not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 2, 2019
1 parent 13567d3 commit 31e0f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lib/y2network/widgets/interface_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def initialize(settings)
textdomain "network"

@settings = settings
@old_name = @settings.name
end

def label
Expand Down Expand Up @@ -57,7 +58,7 @@ def items
end

def validate
if @settings.name_exists?(value)
if @old_name != value && @settings.name_exists?(value)
Yast::Popup.Error(
format(_("Configuration name %s already exists.\nChoose a different one."), value)
)
Expand Down
4 changes: 2 additions & 2 deletions test/y2network/widgets/interface_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
include_examples "CWM::ComboBox"

describe "#validate" do
let(:valid_name) { "eth0" }
let(:valid_name) { "eth1" }
let(:long_name) { "verylongcustomnicname123" }

it "passes for valid names only" do
Expand All @@ -52,7 +52,7 @@
expect(subject.validate).to be false
end

it "fails for already used names" do
it "fails for already used names if changed" do
allow(subject).to receive(:value).and_return valid_name
allow(Yast::NetworkInterfaces).to receive(:List).and_return [valid_name]

Expand Down

0 comments on commit 31e0f6c

Please sign in to comment.