diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-22 16:03:54 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-25 11:31:28 +0300 |
commit | b8c4a65da7d6551f7c916426ec911fe7199b04cc (patch) | |
tree | fc38ebb757b742d33039f4ea3ef14a1e254812d9 /spec/helpers | |
parent | 2eee6a0cbc02c80eb0750a7ca77ee31c4cf0884f (diff) |
Fix license detection to detect all license files, not only known licenses
Fixes #15470.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index c258cfebd73..62389188d2c 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -105,4 +105,30 @@ describe ProjectsHelper do end end end + + describe '#license_short_name' do + let(:project) { create(:project) } + + context 'when project.repository has a license_key' do + it 'returns the nickname of the license if present' do + allow(project.repository).to receive(:license_key).and_return('agpl-3.0') + + expect(helper.license_short_name(project)).to eq('GNU AGPLv3') + end + + it 'returns the name of the license if nickname is not present' do + allow(project.repository).to receive(:license_key).and_return('mit') + + expect(helper.license_short_name(project)).to eq('MIT License') + end + end + + context 'when project.repository has no license_key but a license_blob' do + it 'returns LICENSE' do + allow(project.repository).to receive(:license_key).and_return(nil) + + expect(helper.license_short_name(project)).to eq('LICENSE') + end + end + end end |