Skip to content

Commit

Permalink
Don't call additional methods on builders passed to the atom_feed hel…
Browse files Browse the repository at this point in the history
…per.

Additionally, actually test that the atom_feed helper works with :xml as an option.

[#1836 state:committed]
  • Loading branch information
NZKoz committed Aug 9, 2009
1 parent 45f5bdf commit 370bf14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/atom_feed_helper.rb
Expand Up @@ -98,7 +98,7 @@ def atom_feed(options = {}, &block)
options[:schema_date] = "2005" # The Atom spec copyright date
end

xml = options[:xml] || eval("xml", block.binding)
xml = options.delete(:xml) || eval("xml", block.binding)
xml.instruct!
if options[:instruct]
options[:instruct].each do |target,attrs|
Expand Down
29 changes: 29 additions & 0 deletions actionpack/test/template/atom_feed_helper_test.rb
Expand Up @@ -157,6 +157,26 @@ class ScrollsController < ActionController::Base
end
end
EOT
FEEDS["provide_builder"] = <<-'EOT'
# we pass in the new_xml to the helper so it doesn't
# call anything on the original builder
new_xml = Builder::XmlMarkup.new(:target=>'')
atom_feed(:xml => new_xml) do |feed|
feed.title("My great blog!")
feed.updated((@scrolls.first.created_at))
for scroll in @scrolls
feed.entry(scroll) do |entry|
entry.title(scroll.title)
entry.content(scroll.body, :type => 'html')
entry.author do |author|
author.name("DHH")
end
end
end
end
EOT
def index
@scrolls = [
Scroll.new(1, "1", "Hello One", "Something <i>COOL!</i>", Time.utc(2007, 12, 12, 15), Time.utc(2007, 12, 12, 15)),
Expand Down Expand Up @@ -202,6 +222,15 @@ def test_entry_should_only_use_published_if_created_at_is_present
end
end

def test_providing_builder_to_atom_feed
with_restful_routing(:scrolls) do
get :index, :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

def test_entry_with_prefilled_options_should_use_those_instead_of_querying_the_record
with_restful_routing(:scrolls) do
get :index, :id => "entry_options"
Expand Down

0 comments on commit 370bf14

Please sign in to comment.