summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@localhost.localdomain>2015-10-01 20:34:23 +0200
committerZeger-Jan van de Weg <mail@zjvandeweg.nl>2015-10-15 21:50:15 +0200
commit3f08e4b186bd02b37f34ccf1bc641a95f9d865ce (patch)
tree139b27b544c27bd67d510c199a23628a089e8624
parent7248566632d5de39e7b57594dcf6e021ae912282 (diff)
downloadgitlab-ce-3f08e4b186bd02b37f34ccf1bc641a95f9d865ce.tar.gz
Add specs on #license
-rw-r--r--CHANGELOG2
-rw-r--r--app/models/repository.rb6
-rw-r--r--spec/models/repository_spec.rb11
3 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3d0beb0b7ad..f274942f7b1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -62,6 +62,7 @@ v 8.0.4
- Fix "Assign All" button on Runner admin page
- Fix search in Files
- Add full project namespace to payload of system webhooks (Ricardo Band)
+ - Accept COPYING as licence file (Zeger-Jan van de Weg)
v 8.0.3
- Fix URL shown in Slack notifications
@@ -82,7 +83,6 @@ v 8.0.2
- Fix Reply by email for non-UTF-8 messages.
- Add option to use StartTLS with Reply by email IMAP server.
- Allow AWS S3 Server-Side Encryption with Amazon S3-Managed Keys for backups (Paul Beattie)
- - Accept COPYING as licence file (Zeger-Jan van de Weg)
v 8.0.1
- Remove git refs used internally by GitLab from network graph (Stan Hu)
diff --git a/app/models/repository.rb b/app/models/repository.rb
index dc7cd926745..8cd182e1b0b 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -216,7 +216,11 @@ class Repository
# If `licence`, `copying` and `copying.lesser` are found, return in the
# following order: licence, copying, copying.lesser
- licenses.find { |l| l =~ /\Alicence/i } || licenses.sort.first
+ regex = [/\Alicense(\..*)?\z/i, /\Acopying(\..{0,3})?\z/i, /\Acopying.lesser/i]
+
+ regex.map do |re|
+ licenses.find { |l| l.name =~ re }
+ end.compact.first
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 05e51532eb8..60b93988476 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -91,4 +91,15 @@ describe Repository do
it { expect(subject.data.lines[2]).to eq(" - Feature: Replace teams with group membership\n") }
end
end
+
+ describe "#license" do
+ it 'test selection preference' do
+ repository.send(:cache).expire(:license)
+ TestBlob = Struct.new(:name)
+ files = [TestBlob.new('file'), TestBlob.new('license'), TestBlob.new('copying')]
+ expect(repository.tree).to receive(:blobs).and_return(files)
+
+ expect(repository.license.name).to eq('license')
+ end
+ end
end