diff --git a/src/lib/installation/inst_confirm.rb b/src/lib/installation/inst_confirm.rb index 2d18437b9..132ac9872 100644 --- a/src/lib/installation/inst_confirm.rb +++ b/src/lib/installation/inst_confirm.rb @@ -106,7 +106,10 @@ def run(show_license = false) ) when :ok # Check whether the license has been accepted only if required - if license_required? && !InstData.product_license_accepted + if show_license && + license_required? && + !InstData.product_license_accepted + warn_license_required next end @@ -128,7 +131,7 @@ def run(show_license = false) # @param confirm_button_label [String] button layout install/update # @return [Yast::Term] layout def layout_without_license(heading, body, confirm_button_label) - display_info = UI.GetDisplayInfo + display_info = UI.GetDisplayInfo || {} size_x = display_info["Width"] || 800 size_y = display_info["Height"] || 600 diff --git a/test/lib/inst_confirm_test.rb b/test/lib/inst_confirm_test.rb index ec066f31f..847b41b7b 100755 --- a/test/lib/inst_confirm_test.rb +++ b/test/lib/inst_confirm_test.rb @@ -9,27 +9,75 @@ describe "#run" do before do allow(Yast::Pkg).to receive(:SourceGetCurrent).and_return([]) + allow(Yast::ProductLicense).to receive(:info_seen!).with(0) + allow(Yast::Storage).to receive(:GetCommitInfos).and_return([{:destructive => true}]) end - context "Installation mode" do + context "installation mode" do before do allow(Yast::Mode).to receive(:update).and_return(false) expect(Yast::Label).to receive(:InstallButton) end - context "data is already on disk" do - it "reports delete warning" do - expect(Yast::Storage).to receive(:GetCommitInfos).and_return([{:destructive => true}]) - confirm.run(false) - end - end + context "no license confirmation UI" do + it "returns true if the user clicks ok" do + expect(Yast::UI).to receive(:UserInput).and_return(:ok) + expect(confirm.run(false)).to eq(true) + end + + it "returns false if the user clicks abort" do + expect(Yast::UI).to receive(:UserInput).and_return(:abort) + expect(confirm.run(false)).to eq(false) + end + end + + context "license confirmation UI" do + before do + expect(Yast::ProductLicense).to receive(:AcceptanceNeeded).and_return(true) + expect(Yast::ProductLicense).to receive(:ShowLicenseInInstallation).with( + :base_license_rp, 0) + end + + context "user clicks ok" do + before do + expect(Yast::UI).to receive(:UserInput).and_return(:ok) + end + + it "returns true if the user has accepted license" do + allow(Yast::InstData).to receive(:product_license_accepted).and_return(true) + expect(confirm.run(true)).to eq(true) + end + end + + context "user clicks abort" do + before do + expect(Yast::UI).to receive(:UserInput).and_return(:abort) + end + + it "returns false if the user has not accepted license" do + allow(Yast::InstData).to receive(:product_license_accepted).and_return(false) + expect(confirm.run(true)).to eq(false) + end + + it "returns false even if the user has accepted license" do + allow(Yast::InstData).to receive(:product_license_accepted).and_return(true) + expect(confirm.run(true)).to eq(false) + end + end + end end - context "Update mode" do + context "update mode" do before do allow(Yast::Mode).to receive(:update).and_return(true) end + + it "shows the upgrade button" do + expect(Yast::Label).not_to receive(:InstallButton) + expect(Yast::UI).to receive(:UserInput).and_return(:ok) + expect(confirm.run(false)).to eq(true) + end end end end