class AtomFeedTest

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File actionview/test/template/atom_feed_helper_test.rb, line 229
def setup
  super
  @request.host = "www.nextangle.com"
end
test_entry_id_should_be_a_valid_tag() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 287
def test_entry_id_should_be_a_valid_tag
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "entry id", text: "tag:www.nextangle.com,2008:Scroll/1"
    assert_select "entry id", text: "tag:www.nextangle.com,2008:Scroll/2"
  end
end
test_entry_should_only_use_published_if_created_at_is_present() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 248
def test_entry_should_only_use_published_if_created_at_is_present
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "published", 1
  end
end
test_entry_with_prefilled_options_should_use_those_instead_of_querying_the_record() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 264
def test_entry_with_prefilled_options_should_use_those_instead_of_querying_the_record
  with_restful_routing(:scrolls) do
    get :index, params: { id: "entry_options" }

    assert_select "updated", Time.utc(2007, 1, 1).xmlschema
    assert_select "updated", Time.utc(2007, 1, 2).xmlschema
  end
end
test_feed_entry_type_option_default_to_text_html() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 345
def test_feed_entry_type_option_default_to_text_html
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "entry link[rel=alternate][type=\"text/html\"]"
  end
end
test_feed_entry_type_option_specified() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 352
def test_feed_entry_type_option_specified
  with_restful_routing(:scrolls) do
    get :index, params: { id: "entry_type_options" }
    assert_select "entry link[rel=alternate][type=\"text/xml\"]"
  end
end
test_feed_entry_url_false_option_adds_no_link() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 359
def test_feed_entry_url_false_option_adds_no_link
  with_restful_routing(:scrolls) do
    get :index, params: { id: "entry_url_false_option" }
    assert_select "entry link", false
  end
end
test_feed_id_should_be_a_valid_tag() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 280
def test_feed_id_should_be_a_valid_tag
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "id", text: "tag:www.nextangle.com,2008:/scrolls?id=defaults"
  end
end
test_feed_should_allow_nested_xml_blocks() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 295
def test_feed_should_allow_nested_xml_blocks
  with_restful_routing(:scrolls) do
    get :index, params: { id: "xml_block" }
    assert_select "author name", text: "DHH"
  end
end
test_feed_should_allow_overriding_ids() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 311
def test_feed_should_allow_overriding_ids
  with_restful_routing(:scrolls) do
    get :index, params: { id: "feed_with_overridden_ids" }
    assert_select "id", text: "tag:test.rubyonquails.org,2008:test/"
    assert_select "entry id", text: "tag:test.rubyonquails.org,2008:1"
    assert_select "entry id", text: "tag:test.rubyonquails.org,2008:2"
  end
end
test_feed_should_include_atomPub_namespace() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 302
def test_feed_should_include_atomPub_namespace
  with_restful_routing(:scrolls) do
    get :index, params: { id: "feed_with_atomPub_namespace" }
    assert_match %r{xml:lang="en-US"}, @response.body
    assert_match %r{xmlns="http://www\.w3\.org/2005/Atom"}, @response.body
    assert_match %r{xmlns:app="http://www\.w3\.org/2007/app"}, @response.body
  end
end
test_feed_should_include_two_entries() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 241
def test_feed_should_include_two_entries
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "entry", 2
  end
end
test_feed_should_use_default_language_if_none_is_given() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 234
def test_feed_should_use_default_language_if_none_is_given
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_match(%r{xml:lang="en-US"}, @response.body)
  end
end
test_feed_xhtml() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 336
def test_feed_xhtml
  with_restful_routing(:scrolls) do
    get :index, params: { id:  "feed_with_xhtml_content" }
    assert_match %r{xmlns="http://www\.w3\.org/1999/xhtml"}, @response.body
    assert_select "summary", text: /Something Boring/
    assert_select "summary", text: /after 2/
  end
end
test_feed_xml_processing_instructions() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 320
def test_feed_xml_processing_instructions
  with_restful_routing(:scrolls) do
    get :index, params: { id: "feed_with_xml_processing_instructions" }
    assert_match %r{<\?xml-stylesheet [^\?]*type="text/css"}, @response.body
    assert_match %r{<\?xml-stylesheet [^\?]*href="t\.css"}, @response.body
  end
end
test_feed_xml_processing_instructions_duplicate_targets() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 328
def test_feed_xml_processing_instructions_duplicate_targets
  with_restful_routing(:scrolls) do
    get :index, params: { id: "feed_with_xml_processing_instructions_duplicate_targets" }
    assert_match %r{<\?target1 (a="1" b="2"|b="2" a="1")\?>}, @response.body
    assert_match %r{<\?target1 (c="3" d="4"|d="4" c="3")\?>}, @response.body
  end
end
test_providing_builder_to_atom_feed() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 255
def test_providing_builder_to_atom_feed
  with_restful_routing(:scrolls) do
    get :index, params: { id: "provide_builder" }
    # because we pass in the non-default builder, the content generated by the
    # helper should go 'nowhere'.  Leaving the response body blank.
    assert @response.body.blank?
  end
end
test_self_url_should_default_to_current_request_url() click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 273
def test_self_url_should_default_to_current_request_url
  with_restful_routing(:scrolls) do
    get :index, params: { id: "defaults" }
    assert_select "link[rel=self][href=\"http://www.nextangle.com/scrolls?id=defaults\"]"
  end
end

Private Instance Methods

with_restful_routing(resources) { || ... } click to toggle source
# File actionview/test/template/atom_feed_helper_test.rb, line 367
def with_restful_routing(resources)
  with_routing do |set|
    set.draw do
      resources(resources)
    end
    yield
  end
end