Skip to content

Commit

Permalink
Update from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Knut Alejandro Anderssen González <teclator@gmail.com>
Co-Authored-By: Ladislav Slezák <lslezak@suse.cz>
  • Loading branch information
3 people committed Nov 12, 2018
1 parent 7e7a893 commit cbd8166
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
26 changes: 14 additions & 12 deletions src/lib/network/clients/network_proposal.rb
@@ -1,3 +1,4 @@
require "cgi"
require "installation/proposal_client"

module Yast
Expand Down Expand Up @@ -58,40 +59,41 @@ def preformatted_proposal
end

def switch_backend_link
# TRANSLATORS: information about the network backend in use. %s is the name of backend,
# example "wicked" or "NetworkManager"
backend_in_use = _("Using <b>%s</b>")
# TRANSLATORS: text of link for switch to another network backend. %s is the name of backend
# example "wicked" or "NetworkManager"
switch_to = _("switch to %s")

if wicked_backend?
info = _("Using Wicked")
switcher = Hyperlink(SWITCH_TO_NETWORK_MANAGER, _("switch to Network Manager"))
current_backend = "wicked"
link_to_another_backend = Hyperlink(SWITCH_TO_NETWORK_MANAGER, switch_to % "NetworkManager")
else
info = _("Using Network Manager")
switcher = Hyperlink(SWITCH_TO_WICKED, _("switch to Wicked"))
current_backend = "NetworkManager"
link_to_another_backend = Hyperlink(SWITCH_TO_WICKED, switch_to % "wicked")
end

"<ul><li>#{info} (#{switcher})</li></ul>"
"<ul><li>#{backend_in_use % current_backend} (#{link_to_another_backend})</li></ul>"
end

def launch_network_configuration(args)
log.info "Launching network configuration"

Yast::Wizard.OpenAcceptDialog

result = Yast::WFM.CallFunction("inst_lan", [args.merge("skip_detection" => true)])

log.info "Returning from the network configuration with: #{result}"

result
ensure
Yast::Wizard.CloseDialog
end

def switch_to_wicked
Yast::NetworkService.use_wicked

:next
end

def switch_to_network_manager
Yast::NetworkService.use_network_manager

:next
end

Expand All @@ -101,7 +103,7 @@ def wicked_backend?

# TODO: move to HTML.ycp
def Hyperlink(href, text)
Builtins.sformat("<a href=\"%1\">%2</a>", href, text)
Builtins.sformat("<a href=\"%1\">%2</a>", href, CGI.escapeHTML(text))
end
end
end
24 changes: 12 additions & 12 deletions test/network_proposal_test.rb
Expand Up @@ -31,33 +31,33 @@
expect(proposal).to include("label_proposal", "preformatted_proposal", "links")
end

context "when using a Wicked backend" do
context "when using the wicked backend" do
it "includes the Yast::Lan proposal summary" do
expect(proposal["preformatted_proposal"]).to include("rich_text_summary")
end

it "includes a link for switch to Network Manager" do
expect(proposal["preformatted_proposal"]).to match(/.*href.*Network Manager.*/)
it "includes a link for switch to NetworkManager" do
expect(proposal["preformatted_proposal"]).to match(/.*href.*NetworkManager.*/)
end

it "does not include a link for switch to Wicked" do
expect(proposal["preformatted_proposal"]).to_not match(/.*href.*Wicked.*/)
it "does not include a link for switch to wicked" do
expect(proposal["preformatted_proposal"]).to_not match(/.*href.*wicked.*/)
end
end

context "when using a Network Manager backend" do
context "when using the NetworkManager backend" do
let(:using_wicked) { false }

it "does not include the Yast::Lan proposal summary" do
expect(proposal["preformatted_proposal"]).to_not include("rich_text_summary")
end

it "does not include a link for switch to Network Manager" do
expect(proposal["preformatted_proposal"]).to_not match(/.*href.*Network Manager.*/)
it "does not include a link for switch to NetworkManager" do
expect(proposal["preformatted_proposal"]).to_not match(/.*href.*NetworkManager.*/)
end

it "includes a link for switch to Wicked" do
expect(proposal["preformatted_proposal"]).to match(/.*href.*Wicked.*/)
it "includes a link for switch to wicked" do
expect(proposal["preformatted_proposal"]).to match(/.*href.*wicked.*/)
end
end
end
Expand Down Expand Up @@ -103,7 +103,7 @@
expect(Yast::WFM).to_not receive(:CallFuntion).with("inst_lan", anything)
end

it "changes the netwotk backend to Wicked" do
it "changes the netwotk backend to wicked" do
expect(Yast::NetworkService).to receive(:use_wicked)

subject.ask_user(args)
Expand All @@ -121,7 +121,7 @@
expect(Yast::WFM).to_not receive(:CallFuntion).with("inst_lan", anything)
end

it "changes the netwotk backend to Network Manager" do
it "changes the netwotk backend to NetworkManager" do
expect(Yast::NetworkService).to receive(:use_network_manager)

subject.ask_user(args)
Expand Down

0 comments on commit cbd8166

Please sign in to comment.