Commit f295ff84 authored by Nihad Abbasov's avatar Nihad Abbasov

create atom feed for issues

parent 2b04c2a6
...@@ -22,6 +22,7 @@ class IssuesController < ApplicationController ...@@ -22,6 +22,7 @@ class IssuesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js format.js
format.atom { render :layout => false }
end end
end end
...@@ -38,7 +39,7 @@ class IssuesController < ApplicationController ...@@ -38,7 +39,7 @@ class IssuesController < ApplicationController
@notes = @issue.notes.order("created_at DESC").limit(20) @notes = @issue.notes.order("created_at DESC").limit(20)
@note = @project.notes.new(:noteable => @issue) @note = @project.notes.new(:noteable => @issue)
respond_to do |format| respond_to do |format|
format.html format.html
format.js { respond_with_notes } format.js { respond_with_notes }
end end
......
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 => project_issues_url(@project, :atom), :rel => "self", :type => "application/atom+xml"
xml.link :href => project_issues_url(@project), :rel => "alternate", :type => "text/html"
xml.id project_issues_url(@project)
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
@issues.each do |issue|
xml.entry do
xml.id project_issue_url(@project, issue)
xml.link :href => project_issue_url(@project, issue)
xml.title truncate(issue.title, :length => 80)
xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email)
xml.author do |author|
xml.name issue.author_name
xml.email issue.author_email
end
xml.summary issue.title
end
end
end
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
= javascript_include_tag "application" = javascript_include_tag "application"
- if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project))
= auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}") = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}")
- if request.path == project_issues_path(@project)
= auto_discovery_link_tag(:atom, project_issues_url(@project, :atom), :title => "#{@project.name} issues")
= csrf_meta_tags = csrf_meta_tags
= javascript_tag do = javascript_tag do
REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_URI = "#{request.env["REQUEST_URI"]}";
......
...@@ -27,6 +27,15 @@ describe "Issues" do ...@@ -27,6 +27,15 @@ describe "Issues" do
it { should have_content(@issue.project.name) } it { should have_content(@issue.project.name) }
it { should have_content(@issue.assignee.name) } it { should have_content(@issue.assignee.name) }
it "should render atom feed" do
visit project_issues_path(project, :atom)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "#{project.name} issues")
page.body.should have_selector("author email", :text => @issue.author_email)
page.body.should have_selector("entry summary", :text => @issue.title)
end
describe "Destroy" do describe "Destroy" do
before do before do
# admin access to remove issue # admin access to remove issue
...@@ -81,13 +90,13 @@ describe "Issues" do ...@@ -81,13 +90,13 @@ describe "Issues" do
end end
describe "fill in" do describe "fill in" do
describe 'assign to me' do describe 'assign to me' do
before do before do
fill_in "issue_title", :with => "bug 345" fill_in "issue_title", :with => "bug 345"
click_link "Select user" click_link "Select user"
within "#issue_assignee_id-menu" do within "#issue_assignee_id-menu" do
click_link @user.name click_link @user.name
end end
end end
it { expect { click_button "Save" }.to change {Issue.count}.by(1) } 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
end end
end end
describe 'assign to other' do describe 'assign to other' do
before do before do
fill_in "issue_title", :with => "bug 345" fill_in "issue_title", :with => "bug 345"
click_link "Select user" click_link "Select user"
within "#issue_assignee_id-menu" do within "#issue_assignee_id-menu" do
click_link @user2.name click_link @user2.name
end end
end end
it { expect { click_button "Save" }.to change {Issue.count}.by(1) } 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
end end
end end
describe "Show issue" do describe "Show issue" do
before do before do
@issue = Factory :issue, @issue = Factory :issue,
:author => @user, :author => @user,
...@@ -205,7 +214,7 @@ describe "Issues" do ...@@ -205,7 +214,7 @@ describe "Issues" do
@issue.save @issue.save
end end
end end
it "should be able to search on different statuses" do it "should be able to search on different statuses" do
@issue = Issue.first @issue = Issue.first
@issue.closed = true @issue.closed = true
...@@ -214,13 +223,13 @@ describe "Issues" do ...@@ -214,13 +223,13 @@ describe "Issues" do
visit project_issues_path(project) visit project_issues_path(project)
choose 'closed_issues' choose 'closed_issues'
fill_in 'issue_search', :with => 'foobar' fill_in 'issue_search', :with => 'foobar'
page.should have_content 'foobar' page.should have_content 'foobar'
page.should_not have_content 'foobar2' page.should_not have_content 'foobar2'
page.should_not have_content 'gitlab' page.should_not have_content 'gitlab'
end end
it "should search for term and return the correct results" do it "should search for term and return the correct results" do
visit project_issues_path(project) visit project_issues_path(project)
fill_in 'issue_search', :with => 'foobar' fill_in 'issue_search', :with => 'foobar'
......
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