Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SLE-12-SP2-CASP' into proposa_error_master
- Loading branch information
Showing
5 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require "yast" | ||
|
||
Yast.import "UI" | ||
Yast.import "Label" | ||
Yast.import "Mode" | ||
Yast.import "Popup" | ||
|
||
module Installation | ||
class ProposalErrors | ||
include Yast::I18n | ||
include Yast::Logger | ||
|
||
ERROR_PROPOSAL_TIMEOUT = 60 | ||
|
||
def initialize | ||
textdomain "installation" | ||
@errors = [] | ||
end | ||
|
||
# clears previously stored errros | ||
def clear | ||
@errors = [] | ||
end | ||
|
||
# appends new error with given message | ||
def append(message) | ||
@errors << message | ||
end | ||
|
||
# returns true if there is no error or user approved stored errors | ||
def approved? | ||
return true if @errors.empty? | ||
|
||
headline = _("Error Found in Installation Settings") | ||
text = _("The following errors were found in the configuration proposal.\n" \ | ||
"If you continue with the installation it may not be successful.\n" \ | ||
"Errors:\n") | ||
sep = Yast::UI.TextMode ? "-" : "•" | ||
text += "#{sep} " + @errors.join("\n#{sep} ") | ||
|
||
if Yast::Mode.auto | ||
!Yast::Popup.TimedErrorAnyQuestion(headline, text, | ||
Yast::Label.BackButton, Yast::Label.ContinueButton, :focus_yes, | ||
ERROR_PROPOSAL_TIMEOUT) | ||
else | ||
!Yast::Popup.ErrorAnyQuestion(headline, text, | ||
Yast::Label.BackButton, Yast::Label.ContinueButton, :focus_yes) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "./test_helper" | ||
|
||
require "installation/proposal_errors" | ||
|
||
describe ::Installation::ProposalErrors do | ||
describe "#approved?" do | ||
it "returns true if there is no error stored" do | ||
expect(Yast::Popup).to_not receive(:ErrorAnyQuestion) | ||
expect(subject.approved?).to eq true | ||
end | ||
|
||
it "asks user to approve errors and returns true if approved" do | ||
subject.append("test") | ||
|
||
expect(Yast::Popup).to receive(:ErrorAnyQuestion).and_return(false) | ||
expect(subject.approved?).to eq true | ||
|
||
expect(Yast::Popup).to receive(:ErrorAnyQuestion).and_return(true) | ||
expect(subject.approved?).to eq false | ||
end | ||
|
||
it "in autoyast ask with timeout and return true if timeout exceed" do | ||
subject.append("test") | ||
allow(Yast::Mode).to receive(:auto).and_return(true) | ||
|
||
# timed error return false when timeout exceed | ||
expect(Yast::Popup).to receive(:TimedErrorAnyQuestion).and_return(false) | ||
expect(subject.approved?).to eq true | ||
end | ||
end | ||
end |