summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-26 16:15:10 +0000
committerRémy Coutable <remy@rymai.me>2016-07-26 16:15:10 +0000
commit5d185e66271588ee2e6415dd9f30ef912586b4c3 (patch)
treee1a9cc7daef40e9663e91f750c29fe2ef07c3715
parent8a95f1f32cd5d93044f4b7b4c9b606267910df79 (diff)
parente44bbcb99419357adbab798e7435f61e1c8047d7 (diff)
downloadgitlab-ce-5d185e66271588ee2e6415dd9f30ef912586b4c3.tar.gz
Merge branch '20233-confidential-issue' into 'master'
Show release notes in tag list ## What does this MR do? Two things in one! Ensure that a tag's message having an invalid UTF-8 byte sequence doesn't cause a 500, like at: https://gitlab.com/bitcubate/node/tags?page=9 (The problem tag is https://gitlab.com/bitcubate/node/tags/v0.1.0) Also ensure that the release notes are actually shown on the tag index, like they are supposed to. ## Are there points in the code the reviewer needs to double check? There's not much, so all of it. ## Why was this MR needed? The tags index was broken in two ways. ## What are the relevant issue numbers? Closes #20233 but does more than that. ## Screenshots (if relevant) Before: ![image](/uploads/5456fcc70f02794570762e6ed9c6d863/image.png) After: ![image](/uploads/0329bf93e0f1be2417e500e924bc775d/image.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - ~~API support added~~ - Tests - [x] Added for this feature/bug - [ ] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5503
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/tags_controller.rb3
-rw-r--r--spec/controllers/projects/tags_controller_spec.rb20
3 files changed, 23 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index dca9b209582..432d251dfc6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@ v 8.10.2 (unreleased)
- Fix backup restore. !5459
- Rescue Rugged::OSError (lock exists) when creating references. !5497
- Disable MySQL foreign key checks before dropping all tables. !5472
+ - Show release notes in tags list
- Use project ID in repository cache to prevent stale data from persisting across projects. !5460
- Ensure relative paths for video are rewritten as we do for images. !5474
- Ensure current user can retry a build before showing the 'Retry' button. !5476
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index 6dc495247c8..8592579abbd 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -10,11 +10,12 @@ class Projects::TagsController < Projects::ApplicationController
@tags = @repository.tags_sorted_by(@sort)
@tags = Kaminari.paginate_array(@tags).page(params[:page])
- @releases = project.releases.where(tag: @tags)
+ @releases = project.releases.where(tag: @tags.map(&:name))
end
def show
@tag = @repository.find_tag(params[:id])
+
@release = @project.releases.find_or_initialize_by(tag: @tag.name)
@commit = @repository.commit(@tag.target)
end
diff --git a/spec/controllers/projects/tags_controller_spec.rb b/spec/controllers/projects/tags_controller_spec.rb
new file mode 100644
index 00000000000..a6995145cc1
--- /dev/null
+++ b/spec/controllers/projects/tags_controller_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe Projects::TagsController do
+ let(:project) { create(:project, :public) }
+ let!(:release) { create(:release, project: project) }
+ let!(:invalid_release) { create(:release, project: project, tag: 'does-not-exist') }
+
+ describe 'GET index' do
+ before { get :index, namespace_id: project.namespace.to_param, project_id: project.to_param }
+
+ it 'returns the tags for the page' do
+ expect(assigns(:tags).map(&:name)).to eq(['v1.1.0', 'v1.0.0'])
+ end
+
+ it 'returns releases matching those tags' do
+ expect(assigns(:releases)).to include(release)
+ expect(assigns(:releases)).not_to include(invalid_release)
+ end
+ end
+end