summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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')