Skip to content

Commit

Permalink
Made RSS feed a valid one + functional test for it (#2024)
Browse files Browse the repository at this point in the history
* Made rss feed builder a valid one

* Added tests for RSS Builder

* Update notes_controller_test.rb
  • Loading branch information
sagarpreet-chadha authored and jywarren committed Jan 17, 2018
1 parent 5289334 commit e606fc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/views/notes/rss.rss.builder
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.instruct!
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.channel do
xml.title "Recent research notes on PublicLab.org"
xml.description "Open source environmental science research at Public Lab"
xml.link "https://#{ request.host }/feed.rss"

xml.tag! 'atom:link', :rel => 'self', :type => 'application/rss+xml', :href => request.host.to_s

@notes.each do |node|

body = node.latest.render_body
body = "<p><![CDATA[ <img src='"+node.main_images.path(:default)+"' alt='"+node.main_image.title+"' > ]]></p> " + node.body if node.main_image
body = "<p><![CDATA[ <img src='"+node.main_image.path(:default)+"' alt='"+node.main_image.title+"' > ]]></p> " + node.body if node.main_image

xml.item do
xml.title node.title
Expand Down
7 changes: 7 additions & 0 deletions test/functional/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,11 @@ def teardown
assert_equal I18n.t('notes_controller.research_note_published'), flash[:notice]
end
end

def test_get_rss_feed
get :rss, :format => "rss"
assert_response :success
assert_equal 'application/rss+xml', @response.content_type
end

end

0 comments on commit e606fc2

Please sign in to comment.