Commit 0df18ca9 authored by Francisco Javier López's avatar Francisco Javier López Committed by Sean McGivern

Added atom feed for tags

parent 990278be
......@@ -17,6 +17,11 @@ class Projects::TagsController < Projects::ApplicationController
tag_names = @tags.map(&:name)
@tags_pipelines = @project.pipelines.latest_successful_for_refs(tag_names)
@releases = project.releases.where(tag: tag_names)
respond_to do |format|
format.html
format.atom { render layout: 'xml.atom' }
end
end
def show
......
commit = @repository.commit(tag.dereferenced_target)
release = @releases.find { |r| r.tag == tag.name }
tag_url = project_tag_url(@project, tag.name)
if commit
xml.entry do
xml.id tag_url
xml.link href: tag_url
xml.title truncate(tag.name, length: 80)
xml.summary strip_gpg_signature(tag.message)
xml.content markdown_field(release, :description), type: 'html'
xml.updated release.updated_at.xmlschema if release
xml.media :thumbnail, width: '40', height: '40', url: image_url(avatar_icon_for_email(commit.author_email))
xml.author do |author|
xml.name commit.author_name
xml.email commit.author_email
end
end
end
xml.title "#{@project.name} tags"
xml.link href: project_tags_url(@project, @ref, rss_url_options), rel: 'self', type: 'application/atom+xml'
xml.link href: project_tags_url(@project, @ref), rel: 'alternate', type: 'text/html'
xml.id project_tags_url(@project, @ref)
xml.updated @releases.first.updated_at.xmlschema if @releases.any?
xml << render(partial: 'tag', collection: @tags) if @tags.any?
- @no_container = true
- @sort ||= sort_value_recently_updated
- page_title s_('TagsPage|Tags')
= content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_tags_url(@project, rss_url_options), title: "#{@project.name} tags")
.flex-list{ class: container_class }
.top-area.adjust
......@@ -25,6 +27,8 @@
- if can?(current_user, :push_code, @project)
= link_to new_project_tag_path(@project), class: 'btn btn-create new-tag-btn' do
= s_('TagsPage|New tag')
= link_to project_tags_path(@project, rss_url_options), title: _("Tags feed"), class: 'btn rss-btn has-tooltip' do
= icon("rss")
= render_if_exists 'projects/commits/mirror_status'
......
---
title: Added atom feed for tags
merge_request: 21428
author:
type: added
......@@ -5411,6 +5411,9 @@ msgstr[1] ""
msgid "Tags"
msgstr ""
msgid "Tags feed"
msgstr ""
msgid "Tags:"
msgstr ""
......
# frozen_string_literal: true
require 'spec_helper'
describe 'User views tags', :feature do
context 'rss' do
shared_examples 'has access to the tags RSS feed' do
it do
visit project_tags_path(project, format: :atom)
expect(page).to have_gitlab_http_status(200)
end
end
shared_examples 'does not have access to the tags RSS feed' do
it do
visit project_tags_path(project, format: :atom)
expect(page).to have_gitlab_http_status(401)
end
end
context 'when project public' do
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
context 'when user signed in' do
let(:user) { create(:user) }
before do
project.add_developer(user)
sign_in(user)
visit project_tags_path(project)
end
it_behaves_like "it has an RSS button with current_user's feed token"
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
it_behaves_like 'has access to the tags RSS feed'
end
context 'when user signed out' do
before do
visit project_tags_path(project)
end
it_behaves_like 'it has an RSS button without a feed token'
it_behaves_like 'an autodiscoverable RSS feed without a feed token'
it_behaves_like 'has access to the tags RSS feed'
end
end
context 'when project is not public' do
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
context 'when user signed in' do
let(:user) { create(:user) }
before do
project.add_developer(user)
sign_in(user)
end
it_behaves_like 'has access to the tags RSS feed'
end
context 'when user signed out' do
it_behaves_like 'does not have access to the tags RSS feed'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment