From 83ec89cff1681d65a239b94f313ca102e5b2843c Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 21 Oct 2019 15:15:15 -0600 Subject: Use the latest seeAlso url --- lib/license/management/repository.rb | 2 +- spec/license/management/report/v2_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb index a478dd6..164653c 100644 --- a/lib/license/management/repository.rb +++ b/lib/license/management/repository.rb @@ -36,7 +36,7 @@ module License { 'id' => data['licenseId'], 'name' => data['name'], - 'url' => data['detailsUrl'] + 'url' => data['seeAlso'][-1] } else log_info("could not find license named `#{license.send(:short_name)}` in SPDX index") diff --git a/spec/license/management/report/v2_spec.rb b/spec/license/management/report/v2_spec.rb index 766c08d..85c6158 100644 --- a/spec/license/management/report/v2_spec.rb +++ b/spec/license/management/report/v2_spec.rb @@ -39,5 +39,13 @@ RSpec.describe License::Management::Report::V2 do specify { expect(result[:licenses][0]['id']).to eq(spdx_id) } end end + + context "when choosing an appropriate url for a license" do + subject { described_class.new([dependency]) } + let(:license) { LicenseFinder::License.new(short_name: 'MIT', matcher: LicenseFinder::License::NoneMatcher.new, url: nil) } + let(:dependency) { double(name: 'x', summary: '', description: '', homepage: '', licenses: [license]) } + + specify { expect(subject.to_h[:licenses][0]['url']).to eql('https://opensource.org/licenses/MIT') } + end end end -- cgit v1.2.3