Skip to content

Commit

Permalink
Merge pull request #536 from yast/fix-system-role-help
Browse files Browse the repository at this point in the history
Fix system role help
  • Loading branch information
imobachgs committed Mar 14, 2017
2 parents 127d564 + 427c529 commit 719c541
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Mar 14 12:05:44 UTC 2017 - igonzalezsosa@suse.com

- Fix desktop selection during installation (bsc#1029312)
- 3.2.29

-------------------------------------------------------------------
Mon Mar 13 12:16:23 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.28
Version: 3.2.29
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 2 additions & 4 deletions src/lib/installation/widgets/system_role.rb
Expand Up @@ -105,7 +105,7 @@ def label
end

def items
::Installation::SystemRole.roles.map do |role|
::Installation::SystemRole.all.map do |role|
[role.id, role.label]
end
end
Expand All @@ -125,9 +125,7 @@ def store
private

def roles_help_text
::Installation::SystemRole.roles.map do |role|
role.label + "\n\n" + role.description
end.join("\n\n\n")
::Installation::SystemRole.all.map { |r| "#{r.label}\n\n#{r.description}" }.join("\n\n\n")
end
end

Expand Down
110 changes: 110 additions & 0 deletions test/lib/widgets/system_role_reader_test.rb
@@ -0,0 +1,110 @@
#!/usr/bin/env rspec

require_relative "../../test_helper"
require "installation/widgets/system_role"

describe ::Installation::Widgets::SystemRoleReader do
class DummySystemRoleReader
include Yast::Logger
include ::Installation::Widgets::SystemRoleReader
end

subject { DummySystemRoleReader.new }

let(:default_role) do
::Installation::SystemRole.new(id: "default", label: "Default Role", description: "Role description")
end

let(:alt_role) do
::Installation::SystemRole.new(id: "alt", label: "Alternate Role", description: "Role description")
end

before do
allow(::Installation::SystemRole).to receive(:all).and_return([default_role, alt_role])
end

describe "#default" do
before do
allow(::Installation::SystemRole).to receive(:default?).and_return(default?)
end

context "when a default is expected" do
let(:default?) { true }

it "returns the default role" do
expect(subject.default).to eq(default_role.id)
end
end

context "when not default is expected" do
let(:default?) { false }

it "returns nil" do
expect(subject.default).to be_nil
end
end
end

describe "#init" do
let(:current) { nil }

before do
allow(subject).to receive(:default).and_return("default")
allow(::Installation::SystemRole).to receive(:current).and_return(current)
end

context "when no system role is selected" do
it "sets the default value as the current one" do
expect(subject).to receive(:value=).with("default")
subject.init
end
end

context "when a system role is selected" do
let(:current) { "alt_role" }

it "sets the selected value as the current one" do
expect(subject).to receive(:value=).with(current)
subject.init
end
end
end

describe "#label" do
it "returns the roles caption" do
allow(Yast::ProductControl).to receive(:GetTranslatedText).with("roles_caption")
.and_return("caption")
expect(subject.label).to eq("caption")
end
end

describe "#items" do
it "returns roles ids and labels" do
expect(subject.items).to eq([["default", "Default Role"], ["alt", "Alternate Role"]])
end
end

describe "#help" do
it "returns role help" do
expect(subject.help).to include("Default Role\n\nRole description")
end
end

describe "#store" do
before do
allow(subject).to receive(:value).and_return("alt")
allow(alt_role).to receive(:overlay_features)
allow(alt_role).to receive(:adapt_services)
end

it "overlays role features" do
expect(alt_role).to receive(:overlay_features)
subject.store
end

it "adapts services" do
expect(alt_role).to receive(:adapt_services)
subject.store
end
end
end

0 comments on commit 719c541

Please sign in to comment.