diff --git a/app/views/dashboard/issues.atom.builder b/app/views/dashboard/issues.atom.builder index 0404d0728ea116a9adb8c409657112314058a623..bdea1064096b32f874a9ddcd660d6a6bf2af063d 100644 --- a/app/views/dashboard/issues.atom.builder +++ b/app/views/dashboard/issues.atom.builder @@ -1,7 +1,7 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{current_user.name} issues" - xml.link href: issues_dashboard_url(format: :atom, private_token: current_user.try(:private_token)), rel: "self", type: "application/atom+xml" + xml.link href: url_for(params), rel: "self", type: "application/atom+xml" xml.link href: issues_dashboard_url, rel: "alternate", type: "text/html" xml.id issues_dashboard_url xml.updated @issues.first.created_at.xmlschema if @issues.reorder(nil).any? diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 1eec4db45a07be6dce1bac2b8b3f58f28061d459..3caaf827ff5ad82559e7ea13c2aeb714fad24760 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -2,13 +2,13 @@ - header_title "Issues", issues_dashboard_path(assignee_id: current_user.id) = content_for :meta_tags do - if current_user - = auto_discovery_link_tag(:atom, issues_dashboard_url(format: :atom, private_token: current_user.private_token), title: "#{current_user.name} issues") + = auto_discovery_link_tag(:atom, url_for(params.merge(format: :atom, private_token: current_user.private_token)), title: "#{current_user.name} issues") .top-area = render 'shared/issuable/nav', type: :issues .nav-controls - if current_user - = link_to issues_dashboard_url(format: :atom, private_token: current_user.private_token), class: 'btn' do + = link_to url_for(params.merge(format: :atom, private_token: current_user.private_token)), class: 'btn' do = icon('rss') %span.icon-label Subscribe diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder index b16280403253f890204ff6b74dba591caacc3c70..0cc6466d34eadaaa16348e7e9b7c9fb60ac00597 100644 --- a/app/views/groups/issues.atom.builder +++ b/app/views/groups/issues.atom.builder @@ -1,7 +1,7 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{@group.name} issues" - xml.link href: issues_group_url(format: :atom, private_token: current_user.try(:private_token)), rel: "self", type: "application/atom+xml" + xml.link href: url_for(params), rel: "self", type: "application/atom+xml" xml.link href: issues_group_url, rel: "alternate", type: "text/html" xml.id issues_group_url xml.updated @issues.first.created_at.xmlschema if @issues.reorder(nil).any? diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 4434f1cbd356388cf31b0701f4253bf1802c7657..dc6c1bb69de9fdd8d2e067095b1def6b8dd98912 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -1,13 +1,13 @@ - page_title "Issues" = content_for :meta_tags do - if current_user - = auto_discovery_link_tag(:atom, issues_group_url(@group, format: :atom, private_token: current_user.private_token), title: "#{@group.name} issues") + = auto_discovery_link_tag(:atom, url_for(params.merge(format: :atom, private_token: current_user.private_token)), title: "#{@group.name} issues") .top-area = render 'shared/issuable/nav', type: :issues .nav-controls - if current_user - = link_to issues_group_url(@group, format: :atom, private_token: current_user.private_token), class: 'btn' do + = link_to url_for(params.merge(format: :atom, private_token: current_user.private_token)), class: 'btn' do = icon('rss') %span.icon-label Subscribe diff --git a/app/views/projects/issues/index.atom.builder b/app/views/projects/issues/index.atom.builder index 36957560de0cf6466c0aea564ee3050d417d8e4d..a0df0db77c5cecc6e5fbc0c6488df3724e08b390 100644 --- a/app/views/projects/issues/index.atom.builder +++ b/app/views/projects/issues/index.atom.builder @@ -1,7 +1,7 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "#{@project.name} issues" - xml.link href: namespace_project_issues_url(@project.namespace, @project, format: :atom, private_token: current_user.try(:private_token)), rel: "self", type: "application/atom+xml" + xml.link href: url_for(params), rel: "self", type: "application/atom+xml" xml.link href: namespace_project_issues_url(@project.namespace, @project), rel: "alternate", type: "text/html" xml.id namespace_project_issues_url(@project.namespace, @project) xml.updated @issues.first.created_at.xmlschema if @issues.reorder(nil).any? diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index cc57cfdb342340cfc9bdadf4d5d26f01b9a8b17a..c493ff3585b468b31d2a7d0e20375e4f56372b5a 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -8,7 +8,7 @@ = content_for :meta_tags do - if current_user - = auto_discovery_link_tag(:atom, namespace_project_issues_url(@project.namespace, @project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") + = auto_discovery_link_tag(:atom, url_for(params.merge(format: :atom, private_token: current_user.private_token)), title: "#{@project.name} issues") %div{ class: (container_class) } - if @project.issues.any? @@ -16,7 +16,7 @@ = render 'shared/issuable/nav', type: :issues .nav-controls - if current_user - = link_to namespace_project_issues_path(@project.namespace, @project, :atom, { private_token: current_user.private_token }), class: 'btn append-right-10' do + = link_to url_for(params.merge(format: :atom, private_token: current_user.private_token)), class: 'btn append-right-10' do = icon('rss') %span.icon-label Subscribe diff --git a/changelogs/unreleased/22947-fix_issues_atom_feed_url.yml b/changelogs/unreleased/22947-fix_issues_atom_feed_url.yml new file mode 100644 index 0000000000000000000000000000000000000000..2312afdb3d7a272bd485c4d298aec09227f4f123 --- /dev/null +++ b/changelogs/unreleased/22947-fix_issues_atom_feed_url.yml @@ -0,0 +1,4 @@ +--- +title: Issues atom feed url reflect filters on dashboard +merge_request: 7114 +author: Lucas Deschamps diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb index 4dd9548cfc51737649d28629e63851f771c4f7d7..21ee6cedbae213fa9b69029d9ec547da9a977218 100644 --- a/spec/features/atom/dashboard_issues_spec.rb +++ b/spec/features/atom/dashboard_issues_spec.rb @@ -19,6 +19,17 @@ describe "Dashboard Issues Feed", feature: true do expect(body).to have_selector('title', text: "#{user.name} issues") end + it "renders atom feed with url parameters" do + visit issues_dashboard_path(:atom, private_token: user.private_token, state: 'opened', assignee_id: user.id) + + link = find('link[type="application/atom+xml"]') + params = CGI::parse(URI.parse(link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('state' => ['opened']) + expect(params).to include('assignee_id' => [user.id.to_s]) + end + context "issue with basic fields" do let!(:issue2) { create(:issue, author: user, assignee: user, project: project2, description: 'test desc') } diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index 09c140868fb818bdbc5adb966081040ed09c15fd..863412d18eb7dc36ffec875de38b4638cc47c08a 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -3,10 +3,14 @@ require 'spec_helper' describe 'Issues Feed', feature: true do describe 'GET /issues' do let!(:user) { create(:user) } + let!(:group) { create(:group) } let!(:project) { create(:project) } let!(:issue) { create(:issue, author: user, project: project) } - before { project.team << [user, :developer] } + before do + project.team << [user, :developer] + group.add_developer(user) + end context 'when authenticated' do it 'renders atom feed' do @@ -33,5 +37,28 @@ describe 'Issues Feed', feature: true do expect(body).to have_selector('entry summary', text: issue.title) end end + + it "renders atom feed with url parameters for project issues" do + visit namespace_project_issues_path(project.namespace, project, + :atom, private_token: user.private_token, state: 'opened', assignee_id: user.id) + + link = find('link[type="application/atom+xml"]') + params = CGI::parse(URI.parse(link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('state' => ['opened']) + expect(params).to include('assignee_id' => [user.id.to_s]) + end + + it "renders atom feed with url parameters for group issues" do + visit issues_group_path(group, :atom, private_token: user.private_token, state: 'opened', assignee_id: user.id) + + link = find('link[type="application/atom+xml"]') + params = CGI::parse(URI.parse(link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('state' => ['opened']) + expect(params).to include('assignee_id' => [user.id.to_s]) + end end end diff --git a/spec/features/dashboard_issues_spec.rb b/spec/features/dashboard_issues_spec.rb index 9b54b5301e587d3a3b47ba54222faf39d6510d33..b898f9bc64fb3ca7c065b7df443c1479262751b8 100644 --- a/spec/features/dashboard_issues_spec.rb +++ b/spec/features/dashboard_issues_spec.rb @@ -44,6 +44,22 @@ describe "Dashboard Issues filtering", feature: true, js: true do expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1) expect(page).to have_selector('.issue', count: 1) end + + it 'updates atom feed link' do + visit_issues(milestone_title: '', assignee_id: user.id) + + link = find('.nav-controls a', text: 'Subscribe') + params = CGI::parse(URI.parse(link[:href]).query) + auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) + auto_discovery_params = CGI::parse(URI.parse(auto_discovery_link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('milestone_title' => ['']) + expect(params).to include('assignee_id' => [user.id.to_s]) + expect(auto_discovery_params).to include('private_token' => [user.private_token]) + expect(auto_discovery_params).to include('milestone_title' => ['']) + expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s]) + end end def show_milestone_dropdown @@ -51,7 +67,7 @@ describe "Dashboard Issues filtering", feature: true, js: true do expect(page).to have_selector('.dropdown-content', visible: true) end - def visit_issues - visit issues_dashboard_path + def visit_issues(*args) + visit issues_dashboard_path(*args) end end diff --git a/spec/features/issues/filter_issues_spec.rb b/spec/features/issues/filter_issues_spec.rb index 78208aed46dd84e59219321d9f2b2c9603fe3512..2798db92f0f7b769045a08854b43284ec3f5f29e 100644 --- a/spec/features/issues/filter_issues_spec.rb +++ b/spec/features/issues/filter_issues_spec.rb @@ -4,6 +4,7 @@ describe 'Filter issues', feature: true do include WaitForAjax let!(:project) { create(:project) } + let!(:group) { create(:group) } let!(:user) { create(:user)} let!(:milestone) { create(:milestone, project: project) } let!(:label) { create(:label, project: project) } @@ -11,6 +12,7 @@ describe 'Filter issues', feature: true do before do project.team << [user, :master] + group.add_developer(user) login_as(user) create(:issue, project: project) end @@ -347,4 +349,36 @@ describe 'Filter issues', feature: true do end end end + + it 'updates atom feed link for project issues' do + visit namespace_project_issues_path(project.namespace, project, milestone_title: '', assignee_id: user.id) + + link = find('.nav-controls a', text: 'Subscribe') + params = CGI::parse(URI.parse(link[:href]).query) + auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) + auto_discovery_params = CGI::parse(URI.parse(auto_discovery_link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('milestone_title' => ['']) + expect(params).to include('assignee_id' => [user.id.to_s]) + expect(auto_discovery_params).to include('private_token' => [user.private_token]) + expect(auto_discovery_params).to include('milestone_title' => ['']) + expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s]) + end + + it 'updates atom feed link for group issues' do + visit issues_group_path(group, milestone_title: '', assignee_id: user.id) + + link = find('.nav-controls a', text: 'Subscribe') + params = CGI::parse(URI.parse(link[:href]).query) + auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) + auto_discovery_params = CGI::parse(URI.parse(auto_discovery_link[:href]).query) + + expect(params).to include('private_token' => [user.private_token]) + expect(params).to include('milestone_title' => ['']) + expect(params).to include('assignee_id' => [user.id.to_s]) + expect(auto_discovery_params).to include('private_token' => [user.private_token]) + expect(auto_discovery_params).to include('milestone_title' => ['']) + expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s]) + end end