diff --git a/Gemfile b/Gemfile index ca4157cf47da071b8af1ec4f76b347646bd6ed02..3c9a5ba9559e05760bd0ff3c5f8efe590a3c112f 100644 --- a/Gemfile +++ b/Gemfile @@ -191,7 +191,7 @@ gem 'babosa', '~> 1.0.2' gem "loofah", "~> 2.0.3" # Working with license -gem 'licensee', "~> 7.0.0" +gem 'licensee', '~> 8.0.0' # Protect against bruteforcing gem "rack-attack", '~> 4.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 2a6faeff2f45bc65a7c6ba993b98fcefdc9fac41..3cff184b00bb10533c0cb954ad02e355751f7036 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -452,8 +452,8 @@ GEM addressable (~> 2.3) letter_opener (1.1.2) launchy (~> 2.2) - licensee (7.0.0) - rugged (~> 0.23) + licensee (8.0.0) + rugged (>= 0.24b) listen (3.0.5) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -959,7 +959,7 @@ DEPENDENCIES jquery-ui-rails (~> 5.0.0) kaminari (~> 0.16.3) letter_opener (~> 1.1.2) - licensee (~> 7.0.0) + licensee (~> 8.0.0) loofah (~> 2.0.3) mail_room (~> 0.6.1) method_source (~> 0.8) diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 61df948df60cd2b32ca45ce5654a876e7c8f8507..e7af928b0e901777168803fd4ed0683030f32d1e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -441,13 +441,14 @@ class Variable < Grape::Entity end class License < Grape::Entity - expose :key, :name, :nickname, :featured + expose :key, :name, :nickname + expose :featured, as: :popular expose :url, as: :html_url expose(:source_url) { |license| license.meta['source'] } expose(:description) { |license| license.meta['description'] } - expose(:conditions) { |license| license.meta['required'] } - expose(:permissions) { |license| license.meta['permitted'] } - expose(:limitations) { |license| license.meta['forbidden'] } + expose(:conditions) { |license| license.meta['conditions'] } + expose(:permissions) { |license| license.meta['permissions'] } + expose(:limitations) { |license| license.meta['limitations'] } expose :content end end diff --git a/spec/requests/api/licenses_spec.rb b/spec/requests/api/licenses_spec.rb index 61a58231c54db87709e80e61a9da08c2b1cee8e0..c17dcb222a9d36b5bdb8d0319c945d46f53fc424 100644 --- a/spec/requests/api/licenses_spec.rb +++ b/spec/requests/api/licenses_spec.rb @@ -9,9 +9,9 @@ it { expect(json_response['key']).to eq('mit') } it { expect(json_response['name']).to eq('MIT License') } it { expect(json_response['nickname']).to be_nil } - it { expect(json_response['featured']).to be true } + it { expect(json_response['popular']).to be true } it { expect(json_response['html_url']).to eq('http://choosealicense.com/licenses/mit/') } - it { expect(json_response['source_url']).to eq('http://opensource.org/licenses/MIT') } + it { expect(json_response['source_url']).to eq('https://opensource.org/licenses/MIT') } it { expect(json_response['description']).to include('A permissive license that is short and to the point.') } it { expect(json_response['conditions']).to eq(%w[include-copyright]) } it { expect(json_response['permissions']).to eq(%w[commercial-use modifications distribution private-use]) } @@ -26,7 +26,7 @@ expect(response.status).to eq(200) expect(json_response).to be_an Array expect(json_response.size).to eq(15) - expect(json_response.first['key']).to eq('agpl-3.0') + expect(json_response.map { |l| l['key'] }).to include('agpl-3.0') end describe 'the popular parameter' do @@ -37,7 +37,7 @@ expect(response.status).to eq(200) expect(json_response).to be_an Array expect(json_response.size).to eq(3) - expect(json_response.first['key']).to eq('apache-2.0') + expect(json_response.map { |l| l['key'] }).to include('apache-2.0') end end end