Skip to content

Commit

Permalink
Merge branch 'SLE-12-SP2-CASP' into reset-blocker-m
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Mar 20, 2017
2 parents 79cc5b1 + 2fb2ee2 commit 88d15a0
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 5 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Mar 16 13:07:44 UTC 2017 - mvidner@suse.com

- Allow proceeding with the installation after a blocking condition
has been corrected in the overview dialog (bsc#1029291).
- 3.2.31

-------------------------------------------------------------------
Wed Mar 15 10:19:33 UTC 2017 - igonzalezsosa@suse.com

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


Name: yast2-installation
Version: 3.2.30
Version: 3.2.31
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 2 additions & 4 deletions src/lib/installation/widgets/overview.rb
Expand Up @@ -78,6 +78,8 @@ def items
)
)
@blocking = [:blocker, :fatal].include?(d["warning_level"])
else
@blocking = false
end
@items = d["label_proposal"]
end
Expand Down Expand Up @@ -112,10 +114,6 @@ def validate
false
end

def blocking?
@blocking
end

private

def button_id
Expand Down
128 changes: 128 additions & 0 deletions test/widgets_overview_test.rb
@@ -0,0 +1,128 @@
#! /usr/bin/env rspec

require_relative "test_helper"

require "installation/widgets/overview"

# TODO: these shared examples will soon be available in yast2.rpm
# and then we can just `require "cwm/rspec"`
RSpec.shared_examples "CWM::AbstractWidget" do
context "these methods are only tested if they exist" do
describe "#label" do
it "produces a String" do
next unless subject.respond_to?(:label)
expect(subject.label).to be_a String
end
end

describe "#help" do
it "produces a String" do
next unless subject.respond_to?(:help)
expect(subject.help).to be_a String
end
end

describe "#opt" do
it "produces Symbols" do
next unless subject.respond_to?(:opt)
expect(subject.opt).to be_an Enumerable
subject.opt.each do |o|
expect(o).to be_a Symbol
end
end
end

describe "#handle" do
it "produces a Symbol or nil" do
next unless subject.respond_to?(:handle)
m = subject.method(:handle)
args = m.arity == 0 ? [] : [:dummy_event]
expect(subject.handle(* args)).to be_a(Symbol).or be_nil
end
end

describe "#validate" do
it "produces a Boolean (or nil)" do
next unless subject.respond_to?(:validate)
expect(subject.validate).to be(true).or be(false).or be_nil
end
end
end
end

RSpec.shared_examples "CWM::CustomWidget" do
include_examples "CWM::AbstractWidget"
describe "#contents" do
it "produces a Term" do
expect(subject.contents).to be_a Yast::Term
end
end
end

describe ::Installation::Widgets::Overview do
subject { ::Installation::Widgets::Overview.new(client: "adventure") }
let(:description) do
{
"menu_title" => "An Unexpected Journey"
}
end
let(:proposal) do
{
"label_proposal" => ["Walk to the Lonely Mountain", "Take Gold and Reign"]
}
end
let(:proposal_oops) do
{
"label_proposal" => ["Walk to the Lonely Mountain", "Take Gold and Reign"],
"warning" => "Dragon guarding the gold, no thief in your party",
"warning_level" => :fatal
}
end

before do
allow(Yast::WFM).to receive(:CallFunction)
.with("adventure", ["Description", {}])
.and_return(description)
allow(Yast::WFM).to receive(:CallFunction)
.with("adventure", ["MakeProposal", { "simple_mode" => true }])
.and_return(proposal)
allow(Yast::WFM).to receive(:CallFunction)
.with("adventure", ["AskUser", {}])
end

include_examples "CWM::CustomWidget"
context "when there is a problem" do
before do
allow(Yast::WFM).to receive(:CallFunction)
.with("adventure", ["MakeProposal", { "simple_mode" => true }])
.and_return(proposal_oops)
end

describe "#validate" do
it "returns false" do
subject.contents
expect(subject.validate).to be false
end
end
end

context "when there is a problem and the user corrects it" do
before do
allow(Yast::WFM).to receive(:CallFunction)
.with("adventure", ["MakeProposal", { "simple_mode" => true }])
.and_return(proposal_oops, proposal)
end

describe "#validate" do
it "first returns false, then returns true" do
subject.contents
expect(subject.validate).to be false

subject.handle(:hire_mr_baggins)

subject.contents
expect(subject.validate).to be true
end
end
end
end

0 comments on commit 88d15a0

Please sign in to comment.