summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Shea <connor.james.shea@gmail.com>2016-04-16 16:13:59 -0600
committerConnor Shea <connor.james.shea@gmail.com>2016-04-26 11:40:35 -0600
commitc402aeef027b73b71ad3ca49f79bc2aa6d47b97d (patch)
tree147315c79ad2e80abb6f555b2640060b3c7442a7
parent88e4802d10361ac1fedaebc413986fe04f9b5498 (diff)
downloadgitlab-ce-c402aeef027b73b71ad3ca49f79bc2aa6d47b97d.tar.gz
Allow alternative names for the CHANGELOG file.
"CHANGELOG", "NEWS", "HISTORY", and "CHANGES" are recognized as Changelog files. Also adds relevant tests for each of these names. Resolves #14864.
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/repository.rb2
-rw-r--r--spec/models/repository_spec.rb38
3 files changed, 39 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2be50c5bb11..af259b67d50 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ v 8.8.0 (unreleased)
- Add 'l' shortcut to open Label dropdown on issuables and 'i' to create new issue on a project
- Updated search UI
- Replace Devise Async with Devise ActiveJob integration. !3902 (Connor Shea)
+ - Allow "NEWS" and "CHANGES" as alternative names for CHANGELOG. !3768 (Connor Shea)
v 8.7.1 (unreleased)
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 61c8dce6060..d495c8d18f5 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -457,7 +457,7 @@ class Repository
def changelog
cache.fetch(:changelog) do
tree(:head).blobs.find do |file|
- file.name =~ /\A(changelog|history)/i
+ file.name =~ /\A(changelog|history|changes|news)/i
end
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index c19524a01f8..a306cc4aef8 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -134,7 +134,43 @@ describe Repository, models: true do
end
end
- describe '#license_blob' do
+ describe "#changelog" do
+ before do
+ repository.send(:cache).expire(:changelog)
+ end
+
+ it 'accepts changelog' do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changelog')])
+
+ expect(repository.changelog.name).to eq('changelog')
+ end
+
+ it 'accepts news instead of changelog' do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('news')])
+
+ expect(repository.changelog.name).to eq('news')
+ end
+
+ it 'accepts history instead of changelog' do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('history')])
+
+ expect(repository.changelog.name).to eq('history')
+ end
+
+ it 'accepts changes instead of changelog' do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changes')])
+
+ expect(repository.changelog.name).to eq('changes')
+ end
+
+ it 'is case-insensitive' do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('CHANGELOG')])
+
+ expect(repository.changelog.name).to eq('CHANGELOG')
+ end
+ end
+
+ describe "#license_blob" do
before do
repository.send(:cache).expire(:license_blob)
repository.remove_file(user, 'LICENSE', 'Remove LICENSE', 'master')