diff options
| author | mo khan <mo.khan@gmail.com> | 2019-10-21 15:15:15 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-10-21 15:15:15 -0600 |
| commit | 83ec89cff1681d65a239b94f313ca102e5b2843c (patch) | |
| tree | 1077d76e904836fbdd0eed9d9e76d6ab4832050c | |
| parent | a6adceebeb1ca109439636f90459263ddc828682 (diff) | |
Use the latest seeAlso url
| -rw-r--r-- | lib/license/management/repository.rb | 2 | ||||
| -rw-r--r-- | spec/license/management/report/v2_spec.rb | 8 |
2 files changed, 9 insertions, 1 deletions
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 |
