Skip to content

Commit

Permalink
fix(service): fix reporting of missing registration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 23, 2025
1 parent 9c63e86 commit 7964dcc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
4 changes: 1 addition & 3 deletions service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ def missing_registration_issue
def missing_registration?
return false unless product

registration.reg_code.nil? &&
product.registration &&
missing_base_product?
product.registration && missing_base_product?
end

# Whether the base product is missing
Expand Down
27 changes: 18 additions & 9 deletions service/test/agama/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,28 +543,37 @@

context "and the product requires registration" do
let(:product_id) { "test1" }
let(:product) do
Agama::Software::Product.new("test1").tap do |p|
p.registration = true
p.name = "test1"
end
end

before do
allow(subject.registration).to receive(:reg_code).and_return(reg_code)
allow(subject).to receive(:product).and_return(product)
allow(Y2Packager::Resolvable).to receive(:find)
.with(kind: :product, name: product.name)
.and_return(resolvables)
end

context "and the product is not registered" do
let(:reg_code) { nil }
context "and the base product is not available" do
let(:resolvables) { [] }

it "contains a missing registration issue" do
expect(subject.product_issues).to contain_exactly(
an_object_having_attributes(
description: /product must be registered/i
kind: :missing_registration
)
)
end
end

context "and the product is registered" do
let(:reg_code) { "1234XX5678" }
context "and the base product is available" do
let(:resolvables) { [instance_double("Product")] }

it "does not contain issues" do
expect(subject.product_issues).to be_empty
it "does not contain issues" do
expect(subject.product_issues).to be_empty
end
end
end
end
Expand Down

0 comments on commit 7964dcc

Please sign in to comment.