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,6 +22,7 @@ class IssuesController < ApplicationController | ||
22 | respond_to do |format| | 22 | respond_to do |format| |
23 | format.html # index.html.erb | 23 | format.html # index.html.erb |
24 | format.js | 24 | format.js |
25 | + format.atom { render :layout => false } | ||
25 | end | 26 | end |
26 | end | 27 | end |
27 | 28 | ||
@@ -38,7 +39,7 @@ class IssuesController < ApplicationController | @@ -38,7 +39,7 @@ class IssuesController < ApplicationController | ||
38 | @notes = @issue.notes.order("created_at DESC").limit(20) | 39 | @notes = @issue.notes.order("created_at DESC").limit(20) |
39 | @note = @project.notes.new(:noteable => @issue) | 40 | @note = @project.notes.new(:noteable => @issue) |
40 | 41 | ||
41 | - respond_to do |format| | 42 | + respond_to do |format| |
42 | format.html | 43 | format.html |
43 | format.js { respond_with_notes } | 44 | format.js { respond_with_notes } |
44 | end | 45 | end |
@@ -0,0 +1,23 @@ | @@ -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,6 +7,8 @@ | ||
7 | = javascript_include_tag "application" | 7 | = javascript_include_tag "application" |
8 | - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) | 8 | - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) |
9 | = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}") | 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 | = csrf_meta_tags | 12 | = csrf_meta_tags |
11 | = javascript_tag do | 13 | = javascript_tag do |
12 | REQ_URI = "#{request.env["REQUEST_URI"]}"; | 14 | REQ_URI = "#{request.env["REQUEST_URI"]}"; |
spec/requests/issues_spec.rb
@@ -27,6 +27,15 @@ describe "Issues" do | @@ -27,6 +27,15 @@ describe "Issues" do | ||
27 | it { should have_content(@issue.project.name) } | 27 | it { should have_content(@issue.project.name) } |
28 | it { should have_content(@issue.assignee.name) } | 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 | describe "Destroy" do | 39 | describe "Destroy" do |
31 | before do | 40 | before do |
32 | # admin access to remove issue | 41 | # admin access to remove issue |
@@ -81,13 +90,13 @@ describe "Issues" do | @@ -81,13 +90,13 @@ describe "Issues" do | ||
81 | end | 90 | end |
82 | 91 | ||
83 | describe "fill in" do | 92 | describe "fill in" do |
84 | - describe 'assign to me' do | 93 | + describe 'assign to me' do |
85 | before do | 94 | before do |
86 | fill_in "issue_title", :with => "bug 345" | 95 | fill_in "issue_title", :with => "bug 345" |
87 | click_link "Select user" | 96 | click_link "Select user" |
88 | within "#issue_assignee_id-menu" do | 97 | within "#issue_assignee_id-menu" do |
89 | click_link @user.name | 98 | click_link @user.name |
90 | - end | 99 | + end |
91 | end | 100 | end |
92 | 101 | ||
93 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } | 102 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } |
@@ -107,13 +116,13 @@ describe "Issues" do | @@ -107,13 +116,13 @@ describe "Issues" do | ||
107 | end | 116 | end |
108 | end | 117 | end |
109 | 118 | ||
110 | - describe 'assign to other' do | 119 | + describe 'assign to other' do |
111 | before do | 120 | before do |
112 | fill_in "issue_title", :with => "bug 345" | 121 | fill_in "issue_title", :with => "bug 345" |
113 | click_link "Select user" | 122 | click_link "Select user" |
114 | within "#issue_assignee_id-menu" do | 123 | within "#issue_assignee_id-menu" do |
115 | click_link @user2.name | 124 | click_link @user2.name |
116 | - end | 125 | + end |
117 | end | 126 | end |
118 | 127 | ||
119 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } | 128 | it { expect { click_button "Save" }.to change {Issue.count}.by(1) } |
@@ -145,7 +154,7 @@ describe "Issues" do | @@ -145,7 +154,7 @@ describe "Issues" do | ||
145 | end | 154 | end |
146 | end | 155 | end |
147 | 156 | ||
148 | - describe "Show issue" do | 157 | + describe "Show issue" do |
149 | before do | 158 | before do |
150 | @issue = Factory :issue, | 159 | @issue = Factory :issue, |
151 | :author => @user, | 160 | :author => @user, |
@@ -205,7 +214,7 @@ describe "Issues" do | @@ -205,7 +214,7 @@ describe "Issues" do | ||
205 | @issue.save | 214 | @issue.save |
206 | end | 215 | end |
207 | end | 216 | end |
208 | - | 217 | + |
209 | it "should be able to search on different statuses" do | 218 | it "should be able to search on different statuses" do |
210 | @issue = Issue.first | 219 | @issue = Issue.first |
211 | @issue.closed = true | 220 | @issue.closed = true |
@@ -214,13 +223,13 @@ describe "Issues" do | @@ -214,13 +223,13 @@ describe "Issues" do | ||
214 | visit project_issues_path(project) | 223 | visit project_issues_path(project) |
215 | choose 'closed_issues' | 224 | choose 'closed_issues' |
216 | fill_in 'issue_search', :with => 'foobar' | 225 | fill_in 'issue_search', :with => 'foobar' |
217 | - | 226 | + |
218 | page.should have_content 'foobar' | 227 | page.should have_content 'foobar' |
219 | page.should_not have_content 'foobar2' | 228 | page.should_not have_content 'foobar2' |
220 | page.should_not have_content 'gitlab' | 229 | page.should_not have_content 'gitlab' |
221 | end | 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 | visit project_issues_path(project) | 233 | visit project_issues_path(project) |
225 | fill_in 'issue_search', :with => 'foobar' | 234 | fill_in 'issue_search', :with => 'foobar' |
226 | 235 |