Skip to content

Commit

Permalink
Fix eula_url in product serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
tmuntaner committed May 14, 2018
1 parent 359e1e8 commit e5c8696
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/serializers/v3/product_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def arch
end

def eula_url
if object.eula_url
if object.eula_url.present?
RMT::Misc.replace_uri_parts(object.eula_url, base_url + RMT::DEFAULT_MIRROR_URL_PREFIX)
else
''
Expand Down
24 changes: 24 additions & 0 deletions spec/serializers/v3/product_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
end
let(:base_url) { 'http://example.com' }

describe '#eula_url' do
subject { described_class.new(product, base_url: base_url).eula_url }

let(:product) { create :product, eula_url: eula_url }

context "when the product's eula_url is an empty string" do
let(:eula_url) { '' }

it { is_expected.to eq '' }
end

context "when the product's eula_url is nil" do
let(:eula_url) { nil }

it { is_expected.to eq '' }
end

context "when the product's eula_url is a URL" do
let(:eula_url) { 'http://example.com/eula' }

it { is_expected.to eq 'http://example.com/repo/eula' }
end
end

describe 'SLES extension tree' do
subject(:serializer) { described_class.new(sles15, root_product: sles15, base_url: base_url) }

Expand Down

0 comments on commit e5c8696

Please sign in to comment.