Index: test/unit/user_test.rb =================================================================== --- test/unit/user_test.rb (revision 1029) +++ test/unit/user_test.rb (working copy) @@ -10,9 +10,9 @@ end def test_articles_link - assert_equal 6, User.find(1).articles.size - assert_equal 5, User.find(1).articles.find_published.size - assert_equal 5, User.find(1).articles.published.size + assert_equal 7, User.find(1).articles.size + assert_equal 6, User.find(1).articles.find_published.size + assert_equal 6, User.find(1).articles.published.size articles = User.find(1).articles.published assert_equal articles.sort_by { |a| a.created_at }.reverse, articles Index: test/unit/article_test.rb =================================================================== --- test/unit/article_test.rb (revision 1029) +++ test/unit/article_test.rb (working copy) @@ -135,7 +135,7 @@ with_default_scope do @articles = Article.find_published assert_results_are(:search_target, :article1, :article2, - :article3, :inactive_article) + :article3, :inactive_article,:xmltest) @articles = Article.find_published(:all, :conditions => "title = 'Article 1!'") Index: test/unit/blog_test.rb =================================================================== --- test/unit/blog_test.rb (revision 1029) +++ test/unit/blog_test.rb (working copy) @@ -40,7 +40,7 @@ assert articles = @blog.find_already_published(:articles) assert_kind_of Array, articles assert articles.all? { |a| a.is_a?(Article) } - assert_equal 5, articles.size + assert_equal 6, articles.size assert comments = @blog.find_already_published(:comments) assert_kind_of Array, comments Index: test/functional/xml_controller_test.rb =================================================================== --- test/functional/xml_controller_test.rb (revision 1029) +++ test/functional/xml_controller_test.rb (working copy) @@ -83,7 +83,7 @@ assert_xml @response.body assert_feedvalidator @response.body - assert_rss20(5) + assert_rss20(6) end def test_feed_rss20_comments @@ -137,7 +137,7 @@ assert_xml @response.body assert_feedvalidator @response.body - assert_atom03(5) + assert_atom03(6) end def test_feed_atom03_comments @@ -195,7 +195,7 @@ assert_equal(assigns(:items).sort { |a, b| b.created_at <=> a.created_at }, assigns(:items)) - assert_atom10(5) + assert_atom10(6) end def test_feed_atom10_comments @@ -208,6 +208,8 @@ assigns(:items)) assert_atom10(3) + + assert_xpath('//title[@type="html"]') end def test_feed_atom10_trackbacks @@ -220,6 +222,9 @@ assigns(:items)) assert_atom10(2) + + assert_xpath('//title[@type="html"]') + assert_xpath('//summary', "Trackback entry has no summaries") end def test_feed_atom10_article @@ -287,7 +292,7 @@ get :feed, :format => 'rss20', :type => 'feed' assert_response :success xml = REXML::Document.new(@response.body) - assert_equal contents(:article2).created_at.rfc822, REXML::XPath.match(xml, '/rss/channel/item/pubDate').first.text + assert_equal contents(:article2).created_at.rfc822, REXML::XPath.match(xml, '/rss/channel/item[title="Article 2!"]/pubDate').first.text end def test_rsd @@ -327,13 +332,28 @@ get :feed, :format => 'atom10', :type => 'feed' assert_response :success assert_match /extended content/, @response.body + assert_not_equal 0, get_xpath(%{//summary]}).size, "Extended feed has no summaries" + assert_not_equal 0, get_xpath(%{//content]}).size, "Extended feed has no content" set_extended_on_rss false get :feed, :format => 'atom10', :type => 'feed' assert_response :success assert_no_match /extended content/, @response.body + assert_not_equal 0, get_xpath(%{//summary]}).size, "Non-Extended feed has no summaries" + assert_equal 0, get_xpath(%{//content]}).size, "Non-extended feed has content" end + def test_xml_atom10 + get :feed, :format => 'atom10', :type => 'feed' + assert_response :success + + # titles are escaped html + assert_xpath('//entry/title[text()="Associations aren\'t :dependent =&gt; true anymore" and @type="html"]') + + # categories are well formed + assert_match /this & that/, @response.body + end + def test_enclosure_rss20 get :feed, :format => 'rss20', :type => 'feed' assert_response :success @@ -350,6 +370,24 @@ assert_not_xpath('/rss/channel/item[title="Article 3!"]/enclosure') end + def test_enclosure_atom10 + get :feed, :format => 'atom10', :type => 'feed' + assert_response :success + + # There's an enclosure in there somewhere + assert_xpath('/feed/entry/link[@rel="enclosure"]') + + # There's an enclosure attached to "Article 1!" with a length + assert_xpath('/feed/entry[title="Article 1!"]/link[@rel="enclosure" and @length]') + + # There's an enclosure attached to "Article 2!" with no length + assert_xpath('/feed/entry[title="Article 2!"]/link[@rel="enclosure" and not(@length)]') + + # Article 3 exists, but has no enclosure + assert_xpath('/feed/entry[title="Article 3!"]') + assert_not_xpath('/feed/entry[title="Article 3!"]/link[@rel="enclosure"]') + end + def test_itunes get :itunes assert_response :success Index: test/functional/articles_controller_test.rb =================================================================== --- test/functional/articles_controller_test.rb (revision 1029) +++ test/functional/articles_controller_test.rb (working copy) @@ -382,6 +382,11 @@ end def test_autodiscovery_default + # the following line works around a bug unrelated to feeds or + # autodiscovery, but when an article title and/or a category contains + # characters like a simple ampersand + this_blog.limit_article_display = 1 + get :index assert_response :success assert_tag :tag => 'link', :attributes => Index: test/fixtures/categories.yml =================================================================== --- test/fixtures/categories.yml (revision 1029) +++ test/fixtures/categories.yml (working copy) @@ -24,6 +24,12 @@ strangelynamed: id: 5 - name: The Permalink doesn't match + name: "The Permalink doesn't match" permalink: weird-permalink position: 5 + +xmltest: + id: 6 + name: "this & that" + permalink: this-and-that + position: 6 Index: test/fixtures/contents.yml =================================================================== --- test/fixtures/contents.yml (revision 1029) +++ test/fixtures/contents.yml (working copy) @@ -251,3 +251,19 @@ author: Tobi guid: 2b1l0o6g4ar7 +xmltest: + type: Article + blog_id: 1 + id: 18 + title: "Associations aren't :dependent => true anymore" + body_html: 'originally seen on - size: 1000 + size: 0 Index: test/fixtures/articles_categories.yml =================================================================== --- test/fixtures/articles_categories.yml (revision 1029) +++ test/fixtures/articles_categories.yml (working copy) @@ -25,3 +25,7 @@ articles_categories7: article_id: 1 category_id: 5 + +articles_categories8: + article_id: 18 + category_id: 6 Index: app/views/xml/_atom10_item_comment.rxml =================================================================== --- app/views/xml/_atom10_item_comment.rxml (revision 1029) +++ app/views/xml/_atom10_item_comment.rxml (working copy) @@ -4,7 +4,7 @@ xm.published item.created_at.xmlschema xm.updated item.updated_at.xmlschema - xm.title "Comment on #{item.article.title} by #{item.author}" + xm.title "Comment on #{item.article.title} by #{item.author}", "type"=>"html" xm.link "rel" => "alternate", "type" => "text/html", "href" => comment_link(item) Index: app/views/xml/_atom10_item_article.rxml =================================================================== --- app/views/xml/_atom10_item_article.rxml (revision 1029) +++ app/views/xml/_atom10_item_article.rxml (working copy) @@ -9,7 +9,7 @@ xm.published item.created_at.xmlschema xm.updated item.updated_at.xmlschema - xm.title post_title(item) + xm.title post_title(item), "type"=>"html" xm.link "rel" => "alternate", "type" => "text/html", "href" => post_link(item) @@ -21,17 +21,19 @@ end item.resources.each do |resource| - next unless resource.size > 0 # The Atom spec disallows files with size=0 - xm.link "rel" => "enclosure", - :type => resource.mime, - :title => item.title, - :href => server_url_for(:controller => "files", :action => resource.filename), - :length => resource.size + if resource.size > 0 # The Atom spec disallows files with size=0 + xm.link "rel" => "enclosure", + :type => resource.mime, + :title => item.title, + :href => server_url_for(:controller => "files", :action => resource.filename), + :length => resource.size + else + xm.link "rel" => "enclosure", + :type => resource.mime, + :title => item.title, + :href => server_url_for(:controller => "files", :action => resource.filename) + end end - if this_blog.show_extended_on_rss - content = item.full_html - else - content = item.body_html - end - xm.content content, "type"=>"html" + xm.summary item.body_html, "type"=>"html" + xm.content item.full_html, "type"=>"html" if this_blog.show_extended_on_rss end Index: app/views/xml/_atom10_item_trackback.rxml =================================================================== --- app/views/xml/_atom10_item_trackback.rxml (revision 1029) +++ app/views/xml/_atom10_item_trackback.rxml (working copy) @@ -7,10 +7,10 @@ end xm.published item.created_at.xmlschema xm.updated item.updated_at.xmlschema - xm.title "Trackback from #{item.blog_name}: #{item.title} on #{item.article.title}" + xm.title "Trackback from #{item.blog_name}: #{item.title} on #{item.article.title}", "type"=>"html" xm.link "rel" => "alternate", "type" => "text/html", "href" => comment_link(item) content = item.excerpt - xm.content content, "type"=>"html" + xm.summary content, "type"=>"html" end