From 649cf7975d310bbfb2f1d446c478860098c9eee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Mon, 18 May 2020 16:17:53 +0100 Subject: [PATCH] Remove duplicate entry from .gitignore --- .gitignore | 1 - .../y2network/sysconfig/interfaces_writer.rb | 6 ++++-- .../sysconfig/interfaces_writer_test.rb | 18 +++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index a7ff1b3fd..f2552d385 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,4 @@ testsuite/run/ .yardoc /coverage *.pot -config.* /test/data/scr_read/var/log diff --git a/src/lib/y2network/sysconfig/interfaces_writer.rb b/src/lib/y2network/sysconfig/interfaces_writer.rb index e8584be01..f48607af5 100644 --- a/src/lib/y2network/sysconfig/interfaces_writer.rb +++ b/src/lib/y2network/sysconfig/interfaces_writer.rb @@ -23,8 +23,6 @@ require "y2network/sysconfig/interface_file" require "y2network/sysconfig/routes_file" -Yast.import "Mode" - module Y2Network module Sysconfig # This class writes interfaces specific configuration @@ -33,6 +31,7 @@ module Sysconfig # hardware specific configuration through udev rules. # # @see Y2Network::InterfacesCollection + # @param reload [Boolean] whether the udev rules should be reloaded or not class InterfacesWriter def initialize(reload: true) @reload = reload @@ -48,6 +47,9 @@ def write(interfaces) private + # Whether the udev rules should be reloaded or not + # + # @return [Boolean] true if needs to be reloaded after written def reload? @reload end diff --git a/test/y2network/sysconfig/interfaces_writer_test.rb b/test/y2network/sysconfig/interfaces_writer_test.rb index a9ba78d75..a20c551ce 100644 --- a/test/y2network/sysconfig/interfaces_writer_test.rb +++ b/test/y2network/sysconfig/interfaces_writer_test.rb @@ -70,19 +70,23 @@ eth0.rename("eth1", renaming_mechanism) end - it "sets the interface down" do - expect(Yast::Execute).to receive(:on_target).with("/sbin/ifdown", "eth0") - subject.write(interfaces) + context "and the reload is forced" do + it "sets the interface down" do + expect(Yast::Execute).to receive(:on_target).with("/sbin/ifdown", "eth0") + subject.write(interfaces) + end end - context "during autoinstallation" do + context "and the reload is not forced (ie: autoinstallation)" do before do allow(Yast::Mode).to receive(:autoinst).and_return(true) end - it "does not set the interface down" do - expect(Yast::Execute).to_not receive(:on_target).with("/sbin/ifdown", any_args) - subject.write(interfaces) + context "if not forced the reload" do + it "does not set the interface down" do + expect(Yast::Execute).to receive(:on_target).with("/sbin/ifdown", any_args) + subject.write(interfaces) + end end end