Skip to content

Commit

Permalink
Merge 484627f into fb3ef65
Browse files Browse the repository at this point in the history
  • Loading branch information
gilsonsouza committed May 31, 2017
2 parents fb3ef65 + 484627f commit 7b49292
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,7 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "rake yast2-core yast2-devtools yast2-testsuite yast2-ruby-bindings yast2-pkg-bindings ruby2.1-dev libaugeas-dev pkg-config" -g "rspec:3.3.0 yast-rake gettext coveralls rubocop:0.41.2 cheetah abstract_method cfa"
- sh ./travis_setup.sh -p "rake yast2-core yast2-devtools yast2-testsuite yast2-ruby-bindings yast2-pkg-bindings ruby2.1-dev libaugeas-dev pkg-config gettext" -g "rspec:3.3.0 yast-rake gettext coveralls rubocop:0.41.2 cheetah abstract_method cfa"
script:
- rake check:pot
- rubocop
Expand Down
8 changes: 5 additions & 3 deletions library/general/src/modules/Report.rb
Expand Up @@ -45,6 +45,7 @@ def main
Yast.import "Mode"
Yast.import "Popup"
Yast.import "Summary"
Yast.import "CommandLine"

# stored messages
@errors = []
Expand Down Expand Up @@ -486,7 +487,9 @@ def Warning(warning_string)
Builtins.y2warning(1, "%1", warning_string) if @log_warnings

if @display_warnings
if Ops.greater_than(@timeout_warnings, 0)
if Mode.commandline
CommandLine.Print "Warning: #{warning_string}"
elsif Ops.greater_than(@timeout_warnings, 0)
Popup.TimedWarning(warning_string, @timeout_warnings)
else
Popup.Warning(warning_string)
Expand Down Expand Up @@ -527,8 +530,7 @@ def Error(error_string)

if @display_errors
if Mode.commandline
Yast.import "CommandLine"
CommandLine.Print error_string
CommandLine.Print "Error: #{error_string}"
elsif Ops.greater_than(@timeout_errors, 0)
Popup.TimedError(error_string, @timeout_errors)
else
Expand Down
15 changes: 15 additions & 0 deletions library/general/test/popup_test.rb
Expand Up @@ -273,6 +273,21 @@
expect(subject).to receive(:VSpacing).with(40)
subject.TimedLongErrorGeometry("Title", 1, 30, 40)
end

context "when arguments are bad" do
it "raises exception when the block parameter is missing" do
# no block passed
expect { subject.Feedback("Label", "Message") }.to raise_error(ArgumentError, /block must be supplied/)
end
end
end

describe ".AnyTimedMessage" do
it "is an adapter for anyTimedMessageInternal" do
expect(subject).to receive(:anyTimedMessageInternal)
.with("headline", "message", Integer)
expect(subject.AnyTimedMessage("headline", "message", 5)).to eq nil
end
end

#
Expand Down
97 changes: 97 additions & 0 deletions library/general/test/report_test.rb
Expand Up @@ -171,4 +171,101 @@
end
end

describe ".Warning" do
let(:show) { true }
let(:message) { "Message" }

before do
allow(Yast::Mode).to receive(:commandline).and_return(commandline?)
end

context "while in command-line mode" do
let(:commandline?) { true }

it "prints the message only on console" do
expect(Yast::CommandLine).to receive(:Print)
.with(/#{message}/)
expect(Yast::Popup).to_not receive(:Warning)
expect(Yast::Popup).to_not receive(:TimedWarning)
subject.Warning(message)
end
end

context "while in UI mode and timeout is disabled" do
let(:timeout) { 0 }
let(:commandline?) { false }

before(:each) do
subject.DisplayWarnings(show, timeout)
end

it "shows a popup" do
expect(Yast::Popup).to receive(:Warning).with(/#{message}/)
subject.Warning(message)
end
end

context "while in UI mode and timeout is enabled" do
let(:timeout) { 1 }
let(:commandline?) { false }

before(:each) do
subject.DisplayWarnings(show, timeout)
end

it "shows timed popup" do
expect(Yast::Popup).to receive(:TimedWarning).with(/#{message}/, timeout)
subject.Warning(message)
end
end
end

describe ".Error" do
let(:show) { true }
let(:message) { "Message" }

before do
allow(Yast::Mode).to receive(:commandline).and_return(commandline?)
end

context "while in command-line mode" do
let(:commandline?) { true }

it "prints the message only on console" do
expect(Yast::CommandLine).to receive(:Print)
.with(/#{message}/)
expect(Yast::Popup).to_not receive(:Error)
expect(Yast::Popup).to_not receive(:TimedError)
subject.Error(message)
end
end

context "while in UI mode and timeout is disabled" do
let(:timeout) { 0 }
let(:commandline?) { false }

before(:each) do
subject.DisplayErrors(show, timeout)
end

it "shows a popup" do
expect(Yast::Popup).to receive(:Error).with(/#{message}/)
subject.Error(message)
end
end

context "while in UI mode and timeout is enabled" do
let(:timeout) { 1 }
let(:commandline?) { false }

before(:each) do
subject.DisplayErrors(show, timeout)
end

it "shows a timed popup" do
expect(Yast::Popup).to receive(:TimedError).with(/#{message}/, timeout)
subject.Error(message)
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue May 30 12:05:21 UTC 2017 - gsouza@suse.com

- Warning messages shouldn't open UI in command-line mode
(bsc#1036440).
- 3.1.215.2

-------------------------------------------------------------------
Tue Mar 28 10:19:44 WEST 2017 - knut.anderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 3.1.215.1
Version: 3.1.215.2
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0
Expand Down

0 comments on commit 7b49292

Please sign in to comment.