Commit f295ff84d9597b60c985657aa03fc1ef1e087aa8
1 parent
2b04c2a6
Exists in
master
and in
4 other branches
create atom feed for issues
Showing
4 changed files
with
44 additions
and
9 deletions
Show diff stats
app/controllers/issues_controller.rb
| ... | ... | @@ -22,6 +22,7 @@ class IssuesController < ApplicationController |
| 22 | 22 | respond_to do |format| |
| 23 | 23 | format.html # index.html.erb |
| 24 | 24 | format.js |
| 25 | + format.atom { render :layout => false } | |
| 25 | 26 | end |
| 26 | 27 | end |
| 27 | 28 | |
| ... | ... | @@ -38,7 +39,7 @@ class IssuesController < ApplicationController |
| 38 | 39 | @notes = @issue.notes.order("created_at DESC").limit(20) |
| 39 | 40 | @note = @project.notes.new(:noteable => @issue) |
| 40 | 41 | |
| 41 | - respond_to do |format| | |
| 42 | + respond_to do |format| | |
| 42 | 43 | format.html |
| 43 | 44 | format.js { respond_with_notes } |
| 44 | 45 | end | ... | ... |
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +xml.instruct! | |
| 2 | +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do | |
| 3 | + xml.title "#{@project.name} issues" | |
| 4 | + xml.link :href => project_issues_url(@project, :atom), :rel => "self", :type => "application/atom+xml" | |
| 5 | + xml.link :href => project_issues_url(@project), :rel => "alternate", :type => "text/html" | |
| 6 | + xml.id project_issues_url(@project) | |
| 7 | + xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? | |
| 8 | + | |
| 9 | + @issues.each do |issue| | |
| 10 | + xml.entry do | |
| 11 | + xml.id project_issue_url(@project, issue) | |
| 12 | + xml.link :href => project_issue_url(@project, issue) | |
| 13 | + xml.title truncate(issue.title, :length => 80) | |
| 14 | + xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") | |
| 15 | + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email) | |
| 16 | + xml.author do |author| | |
| 17 | + xml.name issue.author_name | |
| 18 | + xml.email issue.author_email | |
| 19 | + end | |
| 20 | + xml.summary issue.title | |
| 21 | + end | |
| 22 | + end | |
| 23 | +end | ... | ... |
app/views/layouts/project.html.haml
| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | = javascript_include_tag "application" |
| 8 | 8 | - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) |
| 9 | 9 | = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}") |
| 10 | + - if request.path == project_issues_path(@project) | |
| 11 | + = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom), :title => "#{@project.name} issues") | |
| 10 | 12 | = csrf_meta_tags |
| 11 | 13 | = javascript_tag do |
| 12 | 14 | REQ_URI = "#{request.env["REQUEST_URI"]}"; | ... | ... |
spec/requests/issues_spec.rb
| ... | ... | @@ -27,6 +27,15 @@ describe "Issues" do |
| 27 | 27 | it { should have_content(@issue.project.name) } |
| 28 | 28 | it { should have_content(@issue.assignee.name) } |
| 29 | 29 | |
| 30 | + it "should render atom feed" do | |
| 31 | + visit project_issues_path(project, :atom) | |
| 32 | + | |
| 33 | + page.response_headers['Content-Type'].should have_content("application/atom+xml") | |
| 34 | + page.body.should have_selector("title", :text => "#{project.name} issues") | |
| 35 | + page.body.should have_selector("author email", :text => @issue.author_email) | |
| 36 | + page.body.should have_selector("entry summary", :text => @issue.title) | |
| 37 | + end | |
| 38 | + | |
| 30 | 39 | describe "Destroy" do |
| 31 | 40 | before do |
| 32 | 41 | # admin access to remove issue |
| ... | ... | @@ -81,13 +90,13 @@ describe "Issues" do |
| 81 | 90 | end |
| 82 | 91 | |
| 83 | 92 | describe "fill in" do |
| 84 | - describe 'assign to me' do | |
| 93 | + describe 'assign to me' do | |
| 85 | 94 | before do |
| 86 | 95 | fill_in "issue_title", :with => "bug 345" |
| 87 | 96 | click_link "Select user" |
| 88 | 97 | within "#issue_assignee_id-menu" do |
| 89 | 98 | click_link @user.name |
| 90 | - end | |
| 99 | + end | |
| 91 | 100 | end |
| 92 | 101 | |
| 93 | 102 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } |
| ... | ... | @@ -107,13 +116,13 @@ describe "Issues" do |
| 107 | 116 | end |
| 108 | 117 | end |
| 109 | 118 | |
| 110 | - describe 'assign to other' do | |
| 119 | + describe 'assign to other' do | |
| 111 | 120 | before do |
| 112 | 121 | fill_in "issue_title", :with => "bug 345" |
| 113 | 122 | click_link "Select user" |
| 114 | 123 | within "#issue_assignee_id-menu" do |
| 115 | 124 | click_link @user2.name |
| 116 | - end | |
| 125 | + end | |
| 117 | 126 | end |
| 118 | 127 | |
| 119 | 128 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } |
| ... | ... | @@ -145,7 +154,7 @@ describe "Issues" do |
| 145 | 154 | end |
| 146 | 155 | end |
| 147 | 156 | |
| 148 | - describe "Show issue" do | |
| 157 | + describe "Show issue" do | |
| 149 | 158 | before do |
| 150 | 159 | @issue = Factory :issue, |
| 151 | 160 | :author => @user, |
| ... | ... | @@ -205,7 +214,7 @@ describe "Issues" do |
| 205 | 214 | @issue.save |
| 206 | 215 | end |
| 207 | 216 | end |
| 208 | - | |
| 217 | + | |
| 209 | 218 | it "should be able to search on different statuses" do |
| 210 | 219 | @issue = Issue.first |
| 211 | 220 | @issue.closed = true |
| ... | ... | @@ -214,13 +223,13 @@ describe "Issues" do |
| 214 | 223 | visit project_issues_path(project) |
| 215 | 224 | choose 'closed_issues' |
| 216 | 225 | fill_in 'issue_search', :with => 'foobar' |
| 217 | - | |
| 226 | + | |
| 218 | 227 | page.should have_content 'foobar' |
| 219 | 228 | page.should_not have_content 'foobar2' |
| 220 | 229 | page.should_not have_content 'gitlab' |
| 221 | 230 | end |
| 222 | 231 | |
| 223 | - it "should search for term and return the correct results" do | |
| 232 | + it "should search for term and return the correct results" do | |
| 224 | 233 | visit project_issues_path(project) |
| 225 | 234 | fill_in 'issue_search', :with => 'foobar' |
| 226 | 235 | ... | ... |