prototype-rails 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/{README → README.md} +12 -0
- data/Rakefile +2 -0
- data/lib/prototype-rails/on_load_action_view.rb +5 -3
- metadata +15 -46
- data/test/assert_select_test.rb +0 -457
- data/test/controller/caching_test.rb +0 -43
- data/test/controller/content_type_test.rb +0 -16
- data/test/controller/mime_responds_test.rb +0 -213
- data/test/controller/new_base/content_type_test.rb +0 -19
- data/test/controller/new_base/render_rjs_test.rb +0 -71
- data/test/controller/render_js_test.rb +0 -22
- data/test/fixtures/functional_caching/_partial.erb +0 -3
- data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +0 -6
- data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +0 -1
- data/test/fixtures/old_content_type/render_default_for_rjs.rjs +0 -1
- data/test/fixtures/respond_to/all_types_with_layout.js.rjs +0 -1
- data/test/fixtures/respond_to/layouts/standard.html.erb +0 -1
- data/test/fixtures/respond_to/using_defaults.js.rjs +0 -1
- data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +0 -1
- data/test/fixtures/respond_with/using_resource.js.rjs +0 -1
- data/test/fixtures/test/_one.html.erb +0 -1
- data/test/fixtures/test/_partial.html.erb +0 -1
- data/test/fixtures/test/_partial.js.erb +0 -1
- data/test/fixtures/test/_two.html.erb +0 -1
- data/test/fixtures/test/delete_with_js.rjs +0 -2
- data/test/fixtures/test/enum_rjs_test.rjs +0 -6
- data/test/fixtures/test/greeting.js.rjs +0 -1
- data/test/fixtures/test/render_explicit_html_template.js.rjs +0 -1
- data/test/fixtures/test/render_implicit_html_template.js.rjs +0 -1
- data/test/javascript_helper_test.rb +0 -61
- data/test/lib/abstract_unit.rb +0 -225
- data/test/lib/controller/fake_models.rb +0 -29
- data/test/render_other_test.rb +0 -256
- data/test/template/prototype_helper_test.rb +0 -476
- data/test/template/render_test.rb +0 -24
- data/test/template/scriptaculous_helper_test.rb +0 -86
@@ -1 +0,0 @@
|
|
1
|
-
page[:body].visual_effect :highlight
|
@@ -1 +0,0 @@
|
|
1
|
-
page.call "document.write", render(:partial => 'one')
|
@@ -1 +0,0 @@
|
|
1
|
-
page.call "document.write", render(:partial => "one")
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
|
3
|
-
class JavaScriptHelperTest < ActionView::TestCase
|
4
|
-
tests ActionView::Helpers::JavaScriptHelper
|
5
|
-
|
6
|
-
def _evaluate_assigns_and_ivars() end
|
7
|
-
|
8
|
-
attr_accessor :formats, :output_buffer
|
9
|
-
|
10
|
-
def update_details(details)
|
11
|
-
@details = details
|
12
|
-
yield if block_given?
|
13
|
-
end
|
14
|
-
|
15
|
-
def setup
|
16
|
-
super
|
17
|
-
ActiveSupport.escape_html_entities_in_json = true
|
18
|
-
@template = self
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
ActiveSupport.escape_html_entities_in_json = false
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_link_to_function_with_rjs_block
|
26
|
-
html = link_to_function( "Greet me!" ) do |page|
|
27
|
-
page.replace_html 'header', "<h1>Greetings</h1>"
|
28
|
-
end
|
29
|
-
assert_dom_equal %(<a href="#" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E");; return false;">Greet me!</a>), html
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_link_to_function_with_rjs_block_and_options
|
33
|
-
html = link_to_function( "Greet me!", :class => "updater" ) do |page|
|
34
|
-
page.replace_html 'header', "<h1>Greetings</h1>"
|
35
|
-
end
|
36
|
-
assert_dom_equal %(<a href="#" class="updater" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E");; return false;">Greet me!</a>), html
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_link_to_function_with_inner_block_does_not_raise_exception
|
40
|
-
html = link_to_function( "Greet me!" ) do |page|
|
41
|
-
page.replace_html 'header', (content_tag :h1 do
|
42
|
-
'Greetings'
|
43
|
-
end)
|
44
|
-
end
|
45
|
-
assert_dom_equal %(<a href="#" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E");; return false;">Greet me!</a>), html
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_button_to_function_with_rjs_block
|
49
|
-
html = button_to_function( "Greet me!" ) do |page|
|
50
|
-
page.replace_html 'header', "<h1>Greetings</h1>"
|
51
|
-
end
|
52
|
-
assert_dom_equal %(<input type="button" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E");;" value="Greet me!" />), html
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_button_to_function_with_rjs_block_and_options
|
56
|
-
html = button_to_function( "Greet me!", :class => "greeter" ) do |page|
|
57
|
-
page.replace_html 'header', "<h1>Greetings</h1>"
|
58
|
-
end
|
59
|
-
assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C\/h1\\u003E");;" value="Greet me!" />), html
|
60
|
-
end
|
61
|
-
end
|
data/test/lib/abstract_unit.rb
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require 'active_support'
|
6
|
-
require 'active_support/test_case'
|
7
|
-
require 'action_controller'
|
8
|
-
require 'action_view'
|
9
|
-
require 'action_view/testing/resolvers'
|
10
|
-
|
11
|
-
require 'prototype-rails/on_load_action_controller'
|
12
|
-
require 'prototype-rails/on_load_action_view'
|
13
|
-
|
14
|
-
FIXTURE_LOAD_PATH = File.expand_path('../../fixtures', __FILE__)
|
15
|
-
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
|
16
|
-
|
17
|
-
|
18
|
-
module SetupOnce
|
19
|
-
extend ActiveSupport::Concern
|
20
|
-
|
21
|
-
included do
|
22
|
-
cattr_accessor :setup_once_block
|
23
|
-
self.setup_once_block = nil
|
24
|
-
|
25
|
-
setup :run_setup_once
|
26
|
-
end
|
27
|
-
|
28
|
-
module ClassMethods
|
29
|
-
def setup_once(&block)
|
30
|
-
self.setup_once_block = block
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def run_setup_once
|
36
|
-
if self.setup_once_block
|
37
|
-
self.setup_once_block.call
|
38
|
-
self.setup_once_block = nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
|
44
|
-
|
45
|
-
module ActiveSupport
|
46
|
-
class TestCase
|
47
|
-
include SetupOnce
|
48
|
-
# Hold off drawing routes until all the possible controller classes
|
49
|
-
# have been loaded.
|
50
|
-
setup_once do
|
51
|
-
SharedTestRoutes.draw do
|
52
|
-
get ':controller(/:action)'
|
53
|
-
end
|
54
|
-
|
55
|
-
ActionDispatch::IntegrationTest.app.routes.draw do
|
56
|
-
get ':controller(/:action)'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class RoutedRackApp
|
63
|
-
attr_reader :routes
|
64
|
-
|
65
|
-
def initialize(routes, &blk)
|
66
|
-
@routes = routes
|
67
|
-
@stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes)
|
68
|
-
end
|
69
|
-
|
70
|
-
def call(env)
|
71
|
-
@stack.call(env)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
class BasicController
|
76
|
-
attr_accessor :request
|
77
|
-
|
78
|
-
def config
|
79
|
-
@config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config).tap do |config|
|
80
|
-
# VIEW TODO: View tests should not require a controller
|
81
|
-
public_dir = "#{FIXTURE_LOAD_PATH}/public"
|
82
|
-
config.assets_dir = public_dir
|
83
|
-
config.javascripts_dir = "#{public_dir}/javascripts"
|
84
|
-
config.stylesheets_dir = "#{public_dir}/stylesheets"
|
85
|
-
config
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
|
91
|
-
setup do
|
92
|
-
@routes = SharedTestRoutes
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.build_app(routes = nil)
|
96
|
-
RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
|
97
|
-
middleware.use "ActionDispatch::ShowExceptions", ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
|
98
|
-
middleware.use "ActionDispatch::Callbacks"
|
99
|
-
middleware.use "ActionDispatch::ParamsParser"
|
100
|
-
middleware.use "ActionDispatch::Cookies"
|
101
|
-
middleware.use "ActionDispatch::Flash"
|
102
|
-
middleware.use "Rack::Head"
|
103
|
-
yield(middleware) if block_given?
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
self.app = build_app
|
108
|
-
|
109
|
-
# Stub Rails dispatcher so it does not get controller references and
|
110
|
-
# simply return the controller#action as Rack::Body.
|
111
|
-
class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
|
112
|
-
protected
|
113
|
-
def controller_reference(controller_param)
|
114
|
-
controller_param
|
115
|
-
end
|
116
|
-
|
117
|
-
def dispatch(controller, action, env)
|
118
|
-
[200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.stub_controllers
|
123
|
-
old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
|
124
|
-
ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
|
125
|
-
ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
|
126
|
-
yield ActionDispatch::Routing::RouteSet.new
|
127
|
-
ensure
|
128
|
-
ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
|
129
|
-
ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
|
130
|
-
end
|
131
|
-
|
132
|
-
def with_routing(&block)
|
133
|
-
temporary_routes = ActionDispatch::Routing::RouteSet.new
|
134
|
-
old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
|
135
|
-
old_routes = SharedTestRoutes
|
136
|
-
silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
|
137
|
-
|
138
|
-
yield temporary_routes
|
139
|
-
ensure
|
140
|
-
self.class.app = old_app
|
141
|
-
silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
|
142
|
-
end
|
143
|
-
|
144
|
-
def with_autoload_path(path)
|
145
|
-
path = File.join(File.dirname(__FILE__), "fixtures", path)
|
146
|
-
if ActiveSupport::Dependencies.autoload_paths.include?(path)
|
147
|
-
yield
|
148
|
-
else
|
149
|
-
begin
|
150
|
-
ActiveSupport::Dependencies.autoload_paths << path
|
151
|
-
yield
|
152
|
-
ensure
|
153
|
-
ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
|
154
|
-
ActiveSupport::Dependencies.clear
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# Temporary base class
|
161
|
-
class Rack::TestCase < ActionDispatch::IntegrationTest
|
162
|
-
def self.testing(klass = nil)
|
163
|
-
if klass
|
164
|
-
@testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
|
165
|
-
else
|
166
|
-
@testing
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def get(thing, *args)
|
171
|
-
if thing.is_a?(Symbol)
|
172
|
-
super("#{self.class.testing}/#{thing}", *args)
|
173
|
-
else
|
174
|
-
super
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def assert_body(body)
|
179
|
-
assert_equal body, Array.wrap(response.body).join
|
180
|
-
end
|
181
|
-
|
182
|
-
def assert_status(code)
|
183
|
-
assert_equal code, response.status
|
184
|
-
end
|
185
|
-
|
186
|
-
def assert_response(body, status = 200, headers = {})
|
187
|
-
assert_body body
|
188
|
-
assert_status status
|
189
|
-
headers.each do |header, value|
|
190
|
-
assert_header header, value
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def assert_content_type(type)
|
195
|
-
assert_equal type, response.headers["Content-Type"]
|
196
|
-
end
|
197
|
-
|
198
|
-
def assert_header(name, value)
|
199
|
-
assert_equal value, response.headers[name]
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
module ActionController
|
204
|
-
class Base
|
205
|
-
include ActionController::Testing
|
206
|
-
# This stub emulates the Railtie including the URL helpers from a Rails application
|
207
|
-
include SharedTestRoutes.url_helpers
|
208
|
-
|
209
|
-
self.view_paths = FIXTURE_LOAD_PATH
|
210
|
-
|
211
|
-
def self.test_routes(&block)
|
212
|
-
routes = ActionDispatch::Routing::RouteSet.new
|
213
|
-
routes.draw(&block)
|
214
|
-
include routes.url_helpers
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
class TestCase
|
219
|
-
include ActionDispatch::TestProcess
|
220
|
-
|
221
|
-
setup do
|
222
|
-
@routes = SharedTestRoutes
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "active_model"
|
2
|
-
|
3
|
-
class Customer < Struct.new(:name, :id)
|
4
|
-
extend ActiveModel::Naming
|
5
|
-
include ActiveModel::Conversion
|
6
|
-
|
7
|
-
undef_method :to_json
|
8
|
-
|
9
|
-
def to_xml(options={})
|
10
|
-
if options[:builder]
|
11
|
-
options[:builder].name name
|
12
|
-
else
|
13
|
-
"<name>#{name}</name>"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_js(options={})
|
18
|
-
"name: #{name.inspect}"
|
19
|
-
end
|
20
|
-
alias :to_text :to_js
|
21
|
-
|
22
|
-
def errors
|
23
|
-
[]
|
24
|
-
end
|
25
|
-
|
26
|
-
def persisted?
|
27
|
-
id.present?
|
28
|
-
end
|
29
|
-
end
|
data/test/render_other_test.rb
DELETED
@@ -1,256 +0,0 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
require 'pathname'
|
3
|
-
require 'securerandom'
|
4
|
-
|
5
|
-
ActionController.add_renderer :simon do |says, options|
|
6
|
-
self.content_type = Mime::TEXT
|
7
|
-
self.response_body = "Simon says: #{says}"
|
8
|
-
end
|
9
|
-
|
10
|
-
class RenderOtherTest < ActionController::TestCase
|
11
|
-
class TestController < ActionController::Base
|
12
|
-
protect_from_forgery
|
13
|
-
|
14
|
-
def self.controller_path
|
15
|
-
'test'
|
16
|
-
end
|
17
|
-
|
18
|
-
layout :determine_layout
|
19
|
-
|
20
|
-
module RenderTestHelper
|
21
|
-
def rjs_helper_method_from_module
|
22
|
-
page.visual_effect :highlight
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
helper RenderTestHelper
|
27
|
-
helper do
|
28
|
-
def rjs_helper_method(value)
|
29
|
-
page.visual_effect :highlight, value
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def enum_rjs_test
|
34
|
-
render :update do |page|
|
35
|
-
page.select('.product').each do |value|
|
36
|
-
page.rjs_helper_method_from_module
|
37
|
-
page.rjs_helper_method(value)
|
38
|
-
page.sortable(value, :url => { :action => "order" })
|
39
|
-
page.draggable(value)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def render_explicit_html_template
|
45
|
-
end
|
46
|
-
|
47
|
-
def render_custom_code_rjs
|
48
|
-
render :update, :status => 404 do |page|
|
49
|
-
page.replace :foo, :partial => 'partial'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def render_implicit_html_template
|
54
|
-
end
|
55
|
-
|
56
|
-
def render_js_with_explicit_template
|
57
|
-
@project_id = 4
|
58
|
-
render :template => 'test/delete_with_js'
|
59
|
-
end
|
60
|
-
|
61
|
-
def render_js_with_explicit_action_template
|
62
|
-
@project_id = 4
|
63
|
-
render :action => 'delete_with_js'
|
64
|
-
end
|
65
|
-
|
66
|
-
def delete_with_js
|
67
|
-
@project_id = 4
|
68
|
-
end
|
69
|
-
|
70
|
-
def update_page
|
71
|
-
render :update do |page|
|
72
|
-
page.replace_html 'balance', '$37,000,000.00'
|
73
|
-
page.visual_effect :highlight, 'balance'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def update_page_with_instance_variables
|
78
|
-
@money = '$37,000,000.00'
|
79
|
-
@div_id = 'balance'
|
80
|
-
render :update do |page|
|
81
|
-
page.replace_html @div_id, @money
|
82
|
-
page.visual_effect :highlight, @div_id
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def update_page_with_view_method
|
87
|
-
render :update do |page|
|
88
|
-
page.replace_html 'person', pluralize(2, 'person')
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def partial_as_rjs
|
93
|
-
render :update do |page|
|
94
|
-
page.replace :foo, :partial => 'partial'
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def respond_to_partial_as_rjs
|
99
|
-
respond_to do |format|
|
100
|
-
format.js do
|
101
|
-
render :update do |page|
|
102
|
-
page.replace :foo, :partial => 'partial'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def render_alternate_default
|
109
|
-
# For this test, the method "default_render" is overridden:
|
110
|
-
@alternate_default_render = lambda do
|
111
|
-
render :update do |page|
|
112
|
-
page.replace :foo, :partial => 'partial'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def render_simon_says
|
118
|
-
render :simon => "foo"
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
def default_render
|
123
|
-
@alternate_default_render ||= nil
|
124
|
-
if @alternate_default_render
|
125
|
-
@alternate_default_render.call
|
126
|
-
else
|
127
|
-
super
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def determine_layout
|
132
|
-
case action_name
|
133
|
-
when "hello_world", "layout_test", "rendering_without_layout",
|
134
|
-
"rendering_nothing_on_layout", "render_text_hello_world",
|
135
|
-
"render_text_hello_world_with_layout",
|
136
|
-
"hello_world_with_layout_false",
|
137
|
-
"partial_only", "partial_only_with_layout",
|
138
|
-
"accessing_params_in_template",
|
139
|
-
"accessing_params_in_template_with_layout",
|
140
|
-
"render_with_explicit_template",
|
141
|
-
"render_with_explicit_string_template",
|
142
|
-
"update_page", "update_page_with_instance_variables"
|
143
|
-
|
144
|
-
"layouts/standard"
|
145
|
-
when "action_talk_to_layout", "layout_overriding_layout"
|
146
|
-
"layouts/talk_from_action"
|
147
|
-
when "render_implicit_html_template_from_xhr_request"
|
148
|
-
(request.xhr? ? 'layouts/xhr' : 'layouts/standard')
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
tests TestController
|
154
|
-
|
155
|
-
def setup
|
156
|
-
# enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
|
157
|
-
# a more accurate simulation of what happens in "real life".
|
158
|
-
super
|
159
|
-
@controller.logger = Logger.new(nil)
|
160
|
-
|
161
|
-
@request.host = "www.nextangle.com"
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_enum_rjs_test
|
165
|
-
pre = %[$$(".product").each(function(value, index) {
|
166
|
-
new Effect.Highlight(element,{});
|
167
|
-
new Effect.Highlight(value,{});
|
168
|
-
Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('].gsub(/^\s+/, '')
|
169
|
-
post = %[')})}});\nnew Draggable(value, {});\n});]
|
170
|
-
|
171
|
-
get :enum_rjs_test
|
172
|
-
assert_match pre, @response.body
|
173
|
-
assert_match post, @response.body
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
|
177
|
-
[:js, "js"].each do |format|
|
178
|
-
assert_nothing_raised do
|
179
|
-
get :render_explicit_html_template, :format => format
|
180
|
-
assert_equal %(document.write("Hello world\\n");), @response.body
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_render_custom_code_rjs
|
186
|
-
get :render_custom_code_rjs
|
187
|
-
assert_response 404
|
188
|
-
assert_equal %(Element.replace("foo", "partial html");), @response.body
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
|
192
|
-
[:js, "js"].each do |format|
|
193
|
-
assert_nothing_raised do
|
194
|
-
get :render_implicit_html_template, :format => format
|
195
|
-
assert_equal %(document.write("Hello world\\n");), @response.body
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_render_rjs_template_explicitly
|
201
|
-
get :render_js_with_explicit_template
|
202
|
-
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_rendering_rjs_action_explicitly
|
206
|
-
get :render_js_with_explicit_action_template
|
207
|
-
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_render_rjs_with_default
|
211
|
-
get :delete_with_js
|
212
|
-
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_update_page
|
216
|
-
get :update_page
|
217
|
-
assert_template nil
|
218
|
-
assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type']
|
219
|
-
assert_equal 2, @response.body.split($/).length
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_update_page_with_instance_variables
|
223
|
-
get :update_page_with_instance_variables
|
224
|
-
assert_template nil
|
225
|
-
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
226
|
-
assert_match(/balance/, @response.body)
|
227
|
-
assert_match(/\$37/, @response.body)
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_update_page_with_view_method
|
231
|
-
get :update_page_with_view_method
|
232
|
-
assert_template nil
|
233
|
-
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
234
|
-
assert_match(/2 people/, @response.body)
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_should_render_html_formatted_partial_with_rjs
|
238
|
-
xhr :get, :partial_as_rjs
|
239
|
-
assert_equal %(Element.replace("foo", "partial html");), @response.body
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_should_render_html_formatted_partial_with_rjs_and_js_format
|
243
|
-
xhr :get, :respond_to_partial_as_rjs
|
244
|
-
assert_equal %(Element.replace("foo", "partial html");), @response.body
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_should_render_with_alternate_default_render
|
248
|
-
xhr :get, :render_alternate_default
|
249
|
-
assert_equal %(Element.replace("foo", "partial html");), @response.body
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_using_custom_render_option
|
253
|
-
get :render_simon_says
|
254
|
-
assert_equal "Simon says: foo", @response.body
|
255
|
-
end
|
256
|
-
end
|