Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reimport tests

  • Loading branch information...
commit 91491913b4e3b71ff8d8586c7a61a83525649600 1 parent 7fd146b
@josh josh authored
Showing with 99 additions and 2 deletions.
  1. +99 −2 test/test_prototype_helper.rb
View
101 test/test_prototype_helper.rb
@@ -1,7 +1,74 @@
+if ENV['RAILS_ROOT']
+ environment = File.expand_path('vendor/gems/environment', ENV['RAILS_ROOT'])
+ require environment if File.exist?("#{environment}.rb")
+end
+
+$:.unshift File.expand_path('../../lib', __FILE__)
+
require 'test/unit'
-require 'prototype_legacy_helper'
+require 'action_view'
+require 'action_controller'
+require 'active_model'
+require 'prototype_helper'
+
+class Bunny < Struct.new(:Bunny, :id)
+end
+
+class Author
+ extend ActiveModel::Naming
+
+ attr_reader :id
+ def save; @id = 1 end
+ def new_record?; @id.nil? end
+ def name
+ @id.nil? ? 'new author' : "author ##{@id}"
+ end
+end
+
+class Article
+ extend ActiveModel::Naming
+
+ attr_reader :id
+ attr_reader :author_id
+ def save; @id = 1; @author_id = 1 end
+ def new_record?; @id.nil? end
+ def name
+ @id.nil? ? 'new article' : "article ##{@id}"
+ end
+end
+
+class Author::Nested < Author; end
+
+class PrototypeHelperTest < ActionView::TestCase
+ attr_accessor :formats, :output_buffer, :template_format
+
+ def _evaluate_assigns_and_ivars() end
+
+ def reset_formats(format)
+ @format = format
+ end
+
+ def setup
+ @record = @author = Author.new
+ @article = Article.new
+ super
+ @template = self
+ @controller = Class.new do
+ def url_for(options)
+ if options.is_a?(String)
+ options
+ else
+ url = "http://www.example.com/"
+ url << options[:action].to_s if options and options[:action]
+ url << "?a=#{options[:a]}" if options && options[:a]
+ url << "&b=#{options[:b]}" if options && options[:a] && options[:b]
+ url
+ end
+ end
+ end.new
+ end
+
-class TestPrototypeHelper < ActionView::TestCase
def test_observe_form
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>),
observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" })
@@ -226,4 +293,34 @@ def test_link_to_function_with_href
assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>),
link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/')
end
+
+ protected
+ def request_forgery_protection_token
+ nil
+ end
+
+ def protect_against_forgery?
+ false
+ end
+
+ def create_generator
+ block = Proc.new { |*args| yield *args if block_given? }
+ JavaScriptGenerator.new self, &block
+ end
+
+ def author_path(record)
+ "/authors/#{record.id}"
+ end
+
+ def authors_path
+ "/authors"
+ end
+
+ def author_articles_path(author)
+ "/authors/#{author.id}/articles"
+ end
+
+ def author_article_path(author, article)
+ "/authors/#{author.id}/articles/#{article.id}"
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.