Skip to content

Commit

Permalink
bsc#1013976 into master (#473)
Browse files Browse the repository at this point in the history
* bsc#1013976 in CASP (#472)
* setting popup timeout in autoyast upgrade mode (#443 and #456)
* fix non-existing icon (bsc#988377)
* Do not crash when proposals are set in the AY profile (bsc#1013976)
  • Loading branch information
imobachgs committed Dec 7, 2016
1 parent 9542681 commit b0d1fc9
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Dec 7 14:00:53 UTC 2016 - igonzalezsosa@suse.com

- Do not crash when the proposal screen is configured through
an AutoYaST profile and tabs are not being used (bsc#1013976)
- 3.2.11

-------------------------------------------------------------------
Tue Nov 22 12:27:17 UTC 2016 - jreidinger@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.10
Version: 3.2.11
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 3 additions & 3 deletions src/lib/installation/proposal_runner.rb
Expand Up @@ -604,11 +604,11 @@ def load_matching_submodules_list
# setup the list
@submodules_presentation = @store.presentation_order

p = Yast::AutoinstConfig.getProposalList
proposals = Yast::AutoinstConfig.getProposalList

if !p.nil? && p != []
if proposals && !proposals.empty?
# array intersection
@submodules_presentation &= v
@submodules_presentation &= proposals
end
end

Expand Down
101 changes: 95 additions & 6 deletions test/proposal_runner_test.rb
Expand Up @@ -4,11 +4,18 @@

require "installation/proposal_runner"

Yast.import "ProductControl"
Yast.import "GetInstArgs"
Yast.import "Mode"

describe ::Installation::ProposalRunner do
let(:autoyast_proposals) { [] }

before do
# mock constant to avoid dependency on autoyast
autoinst_config = double(Confirm: false)
autoinst_config = double(Confirm: false, getProposalList: autoyast_proposals)
stub_const("Yast::AutoinstConfig", autoinst_config)
allow(Yast::UI).to receive(:UserInput).and_return(:accept)
end

describe ".new" do
Expand All @@ -19,24 +26,106 @@ class C < ::Installation::ProposalStore; end
end

describe "#run" do
PROPERTIES = {
"enable_skip" => "no",
"label" => "Installation Settings",
"mode" => "autoinstallation",
"name" => "initial",
"stage" => "initial",
"unique_id" => "auto_inst_proposal",
"proposal_modules" => [
{ "name" => "hwinfo", "presentation_order" => "90" },
{ "name" => "keyboard", "presentation_order" => "15" }
]
}.freeze

let(:properties) { PROPERTIES }
let(:proposals) { [["keyboard_proposal", 90], ["hwinfo_proposal", 15]] }
let(:keyboard_description) do
{ "id" => "keyboard_stuff", "menu_title" => "&Keyboard Layout", "rich_text_title" => "Keyboard Layout" }
end
let(:hwinfo_description) do
{ "id" => "init_hwinfo", "menu_title" => "S&ystem", "rich_text_title" => "System" }
end

before do
allow(Yast::ProductControl).to receive(:getProposalProperties)
.and_return(properties)
allow(Yast::ProductControl).to receive(:getProposals)
.and_return(proposals)
allow_any_instance_of(::Installation::ProposalStore).to receive(:proposal_names)
.and_return(proposals.map(&:first))
allow(Yast::WFM).to receive(:CallFunction).and_call_original
allow(Yast::WFM).to receive(:CallFunction)
.with("keyboard_proposal", ["Description", {}]).and_return(keyboard_description)
allow(Yast::WFM).to receive(:CallFunction)
.with("hwinfo_proposal", ["Description", {}]).and_return(hwinfo_description)
end

it "do nothing if run non-interactive" do
Yast.import "Mode"
allow(Yast::Mode).to receive(:autoinst).and_return(true)

expect(subject.run).to eq :auto
end

it "do nothing if given proposal type is disabled" do
Yast.import "ProductControl"
Yast.import "GetInstArgs"
allow(Yast::ProductControl).to receive(:GetDisabledProposals).and_return(["initial"])
allow(Yast::GetInstArgs).to receive(:proposal).and_return("initial")

expect(subject.run).to eq :auto
end

it "passes a smoke test" do
expect { subject.run }.to_not raise_error
context "when proposal contains tabs" do
let(:properties) do
PROPERTIES.merge(
"proposal_tabs" => [
{ "label" => "Overview", "proposal_modules" => ["keyboard"] },
{ "label" => "Expert", "proposal_modules" => ["hwinfo", "keyboard"] }
]
)
end

it "makes a proposal" do
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("keyboard_proposal", anything).and_return("preformatted_proposal" => "")
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("hwinfo_proposal", anything).and_return("preformatted_proposal" => "")
expect(subject.run).to eq(:next)
end

context "and the proposal screen is configured through AutoYaST" do
let(:autoyast_proposals) { ["keyboard_proposal"] } # check bsc#1013976

it "makes a proposal" do
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("keyboard_proposal", anything).and_return("preformatted_proposal" => "")
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("hwinfo_proposal", anything).and_return("preformatted_proposal" => "")
expect(subject.run).to eq(:next)
end
end
end

context "when proposal does not contain tabs" do
it "makes a proposal" do
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("keyboard_proposal", anything).and_return("preformatted_proposal" => "")
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("hwinfo_proposal", anything).and_return("preformatted_proposal" => "")
expect(subject.run).to eq(:next)
end

context "and the proposal screen is configured through AutoYaST" do
let(:autoyast_proposals) { ["keyboard_proposal"] } # check bsc#1013976

it "makes a proposal" do
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("keyboard_proposal", anything).and_return("preformatted_proposal" => "")
expect_any_instance_of(::Installation::ProposalStore).to receive(:make_proposal)
.with("hwinfo_proposal", anything).and_return("preformatted_proposal" => "")
expect(subject.run).to eq(:next)
end
end
end
end
end

0 comments on commit b0d1fc9

Please sign in to comment.