Permalink
Browse files

Update calls to yast2 systemd classes (#170)

* Remove dead code

* Update calls to Yast2::Systemd::Target

* Update yast2 dependency

* Update version and changelog
  • Loading branch information...
dgdavid committed Aug 23, 2018
1 parent fa30a92 commit 04795b80e7f74bbac87984bc42842863e1afe54c
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Aug 23 14:23:27 UTC 2018 - dgonzalez@suse.com

- Update calls to YaST2 systemd classes (related to fate#319428)
- 4.1.5

-------------------------------------------------------------------
Thu Aug 23 13:11:36 UTC 2018 - jlopez@suse.com

@@ -24,16 +24,16 @@
######################################################################

Name: yast2-services-manager
Version: 4.1.4
Version: 4.1.5
Release: 0
BuildArch: noarch

BuildRoot: %{_tmppath}/%{name}-build
Source0: %{name}-%{version}.tar.bz2

Requires: ruby
# Yast2::SystemService#found?
Requires: yast2 >= 4.0.83
# Yast2::Systemd::Target
Requires: yast2 >= 4.1.3
Requires: yast2-ruby-bindings >= 1.2.0
# To show service logs
Suggests: yast2-journal >= 4.1.1
@@ -45,11 +45,11 @@ Conflicts: yast2-runlevel

BuildRequires: ruby
BuildRequires: update-desktop-files
# Yast2::Systemd::Target
BuildRequires: yast2 >= 4.1.3
BuildRequires: yast2-ruby-bindings >= 1.2.0
# To show service logs
BuildRequires: yast2-journal >= 4.1.1
# Yast2::SystemService#found?
BuildRequires: yast2 >= 4.0.83
# Support for 'data' directory in rake install task
BuildRequires: rubygem(yast-rake) >= 0.1.7
BuildRequires: rubygem(rspec)
@@ -6,7 +6,6 @@ module Yast
import "Mode"
import "Service"
import "ServicesProposal"
import "SystemdService"
import "Stage"

class ServicesManagerServiceClass < Module
@@ -248,7 +247,7 @@ def switch(name)
#
# @param name [String] service name
# @param mode [Symbol] Start mode
# @see Yast::SystemdServiceClass::Service#start_modes
# @see Yast2::SystemService#start_modes
def set_start_mode(name, mode)
exists?(name) { |s| s.start_mode = mode }
end
@@ -1,8 +1,8 @@
require "yast"
require "yast2/systemd/target"

module Yast
import 'Stage'
import 'SystemdTarget'

class ServicesManagerTargetClass < Module
include Yast::Logger
@@ -83,11 +83,11 @@ def read
# Reads the data on a running system only
return true if Stage.initial

default_target = SystemdTarget.get_default
default_target = Yast2::Systemd::Target.get_default
@initial_default_target = default_target ? default_target.name : ""
@default_target = @initial_default_target

SystemdTarget.all.each do |target|
Yast2::Systemd::Target.all.each do |target|
next unless target.allow_isolate?
next if BLACKLISTED_TARGETS.member?(target.name)

@@ -135,7 +135,7 @@ def inspect
def save
return true unless modified?
log.info('Saving default target...')
SystemdTarget.set_default(default_target)
Yast2::Systemd::Target.set_default(default_target)
end

def reset
@@ -49,8 +49,8 @@ class Template < Struct.new(
before do
allow(Yast::Mode).to receive(:mode).and_return("normal")

allow(SystemdTarget).to receive(:all).and_return(TestTarget::ALL)
allow(SystemdTarget).to receive(:get_default).and_return(TestTarget::GRAPHICAL)
allow(Yast2::Systemd::Target).to receive(:all).and_return(TestTarget::ALL)
allow(Yast2::Systemd::Target).to receive(:get_default).and_return(TestTarget::GRAPHICAL)
end

describe "#default_target" do
@@ -104,7 +104,7 @@ class Template < Struct.new(
let(:target) { "graphical" }

it "does not perform changes in the underlying system" do
expect(SystemdTarget).to_not receive(:set_default)
expect(Yast2::Systemd::Target).to_not receive(:set_default)

subject.save
end
@@ -114,7 +114,7 @@ class Template < Struct.new(
let(:target) { "multi-user" }

it "saves the changes in the underlying system" do
expect(SystemdTarget).to receive(:set_default).with("multi-user")
expect(Yast2::Systemd::Target).to receive(:set_default).with("multi-user")

subject.save
end
@@ -156,8 +156,8 @@ def stub_list_units(services_specs)
def stub_targets(targets_specs)
targets = targets_specs.map { |s| stub_target(s) }

allow(Yast::SystemdTarget).to receive(:default_target).and_return(targets.first)
allow(Yast::SystemdTarget).to receive(:all).and_return(targets)
allow(Yast2::Systemd::Target).to receive(:default_target).and_return(targets.first)
allow(Yast2::Systemd::Target).to receive(:all).and_return(targets)
end

# Stubs a target
@@ -166,7 +166,7 @@ def stub_targets(targets_specs)
#
# @param target_specs [Hash]
def stub_target(target_specs)
instance_double(Yast::SystemdTargetClass::Target, target_specs)
instance_double(Yast2::Systemd::Target, target_specs)
end

# Checks whether a widgets tree contains the given id

0 comments on commit 04795b8

Please sign in to comment.