Skip to content

Commit

Permalink
Merge pull request #476 from yast/offline_refactoring
Browse files Browse the repository at this point in the history
Small refactoring related to the offline medium (jsc#SLE-7101)
  • Loading branch information
lslezak committed Oct 1, 2019
2 parents a87224c + 4e24c8d commit e1de24e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Oct 1 07:52:29 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

- Small refactoring related to the offline medium (jsc#SLE-7101)
- 4.2.29

-------------------------------------------------------------------
Fri Sep 27 15:21:37 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

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


Name: yast2-packager
Version: 4.2.28
Version: 4.2.29
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
13 changes: 13 additions & 0 deletions src/lib/y2packager/product_location.rb
Expand Up @@ -15,6 +15,7 @@
require "y2packager/repomd_downloader"
require "y2packager/solvable_pool"
require "y2packager/product_finder"
require "y2packager/resolvable"

Yast.import "URL"

Expand Down Expand Up @@ -98,10 +99,22 @@ def summary
details.summary
end

alias_method :label, :summary

# Just forward to the details object to easily use the Y2Packager::PRODUCT_SORTER
# @return [Integer,nil] Product order, `nil` if not defined
def order
details&.order
end

# Is the product selected to install?
#
# @return [Boolean,nil] `true` if the product is selected to install, `false` otherwise,
# `nil` if the product name is not set
def selected?
return nil unless details

Y2Packager::Resolvable.any?(kind: :product, name: details.product, status: :selected)
end
end
end
34 changes: 34 additions & 0 deletions test/product_location_test.rb
Expand Up @@ -119,4 +119,38 @@ def find_product(arr, product)
end
end
end

describe "#label" do
subject { described_class.new("foo", "/dir/foo", product: product) }
let(:product) { instance_double(Y2Packager::ProductLocationDetails, summary: "summary") }

it "returns the summary content" do
expect(subject.label).to eq("summary")
end
end

describe "#selected?" do
subject { described_class.new("foo", "/dir/foo", product: product) }
let(:product) { instance_double(Y2Packager::ProductLocationDetails, product: "product") }

before do
expect(Y2Packager::Resolvable).to receive(:any?)
.with(kind: :product, name: "product", status: :selected)
.and_return(product_selected)
end

context "product selected" do
let(:product_selected) { true }
it "returns true" do
expect(subject.selected?).to eq(true)
end
end

context "product not selected" do
let(:product_selected) { false }
it "returns false" do
expect(subject.selected?).to eq(false)
end
end
end
end

0 comments on commit e1de24e

Please sign in to comment.