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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/{README → README.md} +12 -0
  4. data/Rakefile +2 -0
  5. data/lib/prototype-rails/on_load_action_view.rb +5 -3
  6. metadata +15 -46
  7. data/test/assert_select_test.rb +0 -457
  8. data/test/controller/caching_test.rb +0 -43
  9. data/test/controller/content_type_test.rb +0 -16
  10. data/test/controller/mime_responds_test.rb +0 -213
  11. data/test/controller/new_base/content_type_test.rb +0 -19
  12. data/test/controller/new_base/render_rjs_test.rb +0 -71
  13. data/test/controller/render_js_test.rb +0 -22
  14. data/test/fixtures/functional_caching/_partial.erb +0 -3
  15. data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +0 -6
  16. data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +0 -1
  17. data/test/fixtures/old_content_type/render_default_for_rjs.rjs +0 -1
  18. data/test/fixtures/respond_to/all_types_with_layout.js.rjs +0 -1
  19. data/test/fixtures/respond_to/layouts/standard.html.erb +0 -1
  20. data/test/fixtures/respond_to/using_defaults.js.rjs +0 -1
  21. data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +0 -1
  22. data/test/fixtures/respond_with/using_resource.js.rjs +0 -1
  23. data/test/fixtures/test/_one.html.erb +0 -1
  24. data/test/fixtures/test/_partial.html.erb +0 -1
  25. data/test/fixtures/test/_partial.js.erb +0 -1
  26. data/test/fixtures/test/_two.html.erb +0 -1
  27. data/test/fixtures/test/delete_with_js.rjs +0 -2
  28. data/test/fixtures/test/enum_rjs_test.rjs +0 -6
  29. data/test/fixtures/test/greeting.js.rjs +0 -1
  30. data/test/fixtures/test/render_explicit_html_template.js.rjs +0 -1
  31. data/test/fixtures/test/render_implicit_html_template.js.rjs +0 -1
  32. data/test/javascript_helper_test.rb +0 -61
  33. data/test/lib/abstract_unit.rb +0 -225
  34. data/test/lib/controller/fake_models.rb +0 -29
  35. data/test/render_other_test.rb +0 -256
  36. data/test/template/prototype_helper_test.rb +0 -476
  37. data/test/template/render_test.rb +0 -24
  38. data/test/template/scriptaculous_helper_test.rb +0 -86
@@ -1,43 +0,0 @@
1
- require 'abstract_unit'
2
-
3
- # Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
4
- FILE_STORE_PATH = File.expand_path('../../../temp/test_cache', __FILE__)
5
-
6
- class CachingController < ActionController::Base
7
- abstract!
8
-
9
- self.cache_store = :file_store, FILE_STORE_PATH
10
- end
11
-
12
- class FunctionalCachingController < CachingController
13
- def js_fragment_cached_with_partial
14
- respond_to do |format|
15
- format.js
16
- end
17
- end
18
-
19
- def formatted_fragment_cached
20
- respond_to do |format|
21
- format.js
22
- end
23
- end
24
- end
25
-
26
- class FunctionalFragmentCachingTest < ActionController::TestCase
27
- def setup
28
- super
29
- @store = ActiveSupport::Cache::MemoryStore.new
30
- @controller = FunctionalCachingController.new
31
- @controller.perform_caching = true
32
- @controller.cache_store = @store
33
- @request = ActionController::TestRequest.new
34
- @response = ActionController::TestResponse.new
35
- end
36
-
37
- def test_fragment_caching_in_rjs_partials
38
- xhr :get, :js_fragment_cached_with_partial
39
- assert_response :success
40
- assert_match(/Old fragment caching in a partial/, @response.body)
41
- assert_match "Old fragment caching in a partial", @store.instance_variable_get('@data').values.first.value
42
- end
43
- end
@@ -1,16 +0,0 @@
1
- require 'abstract_unit'
2
-
3
- class OldContentTypeController < ActionController::Base
4
- def render_default_for_rjs
5
- end
6
- end
7
-
8
- class ContentTypeTest < ActionController::TestCase
9
- tests OldContentTypeController
10
-
11
- def test_default_for_rjs
12
- xhr :post, :render_default_for_rjs
13
- assert_equal Mime::JS, @response.content_type
14
- assert_equal "utf-8", @response.charset
15
- end
16
- end
@@ -1,213 +0,0 @@
1
- require 'abstract_unit'
2
- require 'controller/fake_models'
3
- require 'active_support/core_ext/hash/conversions'
4
-
5
- class RespondToController < ActionController::Base
6
- layout :set_layout
7
-
8
- def html_xml_or_rss
9
- respond_to do |type|
10
- type.html { render :text => "HTML" }
11
- type.xml { render :text => "XML" }
12
- type.rss { render :text => "RSS" }
13
- type.all { render :text => "Nothing" }
14
- end
15
- end
16
-
17
- def js_or_html
18
- respond_to do |type|
19
- type.js { render :text => "JS" }
20
- end
21
- end
22
-
23
- def json_or_yaml
24
- respond_to do |type|
25
- type.json { render :text => "JSON" }
26
- type.yaml { render :text => "YAML" }
27
- end
28
- end
29
-
30
- def html_or_xml
31
- respond_to do |type|
32
- type.html { render :text => "HTML" }
33
- type.xml { render :text => "XML" }
34
- type.all { render :text => "Nothing" }
35
- end
36
- end
37
-
38
- def json_xml_or_html
39
- respond_to do |type|
40
- type.json { render :text => 'JSON' }
41
- type.xml { render :xml => 'XML' }
42
- type.html { render :text => 'HTML' }
43
- end
44
- end
45
-
46
-
47
- def forced_xml
48
- request.format = :xml
49
-
50
- respond_to do |type|
51
- type.html { render :text => "HTML" }
52
- type.xml { render :text => "XML" }
53
- end
54
- end
55
-
56
- def just_xml
57
- respond_to do |type|
58
- type.xml { render :text => "XML" }
59
- end
60
- end
61
-
62
- def using_defaults
63
- respond_to do |type|
64
- type.js
65
- end
66
- end
67
-
68
- def using_defaults_with_type_list
69
- respond_to(:js)
70
- end
71
-
72
- def made_for_content_type
73
- respond_to do |type|
74
- type.rss { render :text => "RSS" }
75
- type.atom { render :text => "ATOM" }
76
- type.all { render :text => "Nothing" }
77
- end
78
- end
79
-
80
- def custom_type_handling
81
- respond_to do |type|
82
- type.html { render :text => "HTML" }
83
- type.custom("application/crazy-xml") { render :text => "Crazy XML" }
84
- type.all { render :text => "Nothing" }
85
- end
86
- end
87
-
88
-
89
- def custom_constant_handling
90
- respond_to do |type|
91
- type.html { render :text => "HTML" }
92
- type.mobile { render :text => "Mobile" }
93
- end
94
- end
95
-
96
- def custom_constant_handling_without_block
97
- respond_to do |type|
98
- type.html { render :text => "HTML" }
99
- type.mobile
100
- end
101
- end
102
-
103
- def handle_any
104
- respond_to do |type|
105
- type.html { render :text => "HTML" }
106
- type.any(:js, :xml) { render :text => "Either JS or XML" }
107
- end
108
- end
109
-
110
- def handle_any_any
111
- respond_to do |type|
112
- type.html { render :text => 'HTML' }
113
- type.any { render :text => 'Whatever you ask for, I got it' }
114
- end
115
- end
116
-
117
- def all_types_with_layout
118
- respond_to do |type|
119
- type.js
120
- end
121
- end
122
-
123
-
124
- def iphone_with_html_response_type
125
- request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone"
126
-
127
- respond_to do |type|
128
- type.html { @type = "Firefox" }
129
- type.iphone { @type = "iPhone" }
130
- end
131
- end
132
-
133
- def iphone_with_html_response_type_without_layout
134
- request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
135
-
136
- respond_to do |type|
137
- type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" }
138
- type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
139
- end
140
- end
141
-
142
- def rescue_action(e)
143
- raise
144
- end
145
-
146
- protected
147
- def set_layout
148
- if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
149
- "respond_to/layouts/standard"
150
- elsif action_name == "iphone_with_html_response_type_without_layout"
151
- "respond_to/layouts/missing"
152
- end
153
- end
154
- end
155
-
156
-
157
- class RespondToControllerTest < ActionController::TestCase
158
- tests RespondToController
159
-
160
- def test_using_defaults
161
- @request.accept = "text/javascript"
162
- get :using_defaults
163
- assert_equal "text/javascript", @response.content_type
164
- assert_equal '$("body").visualEffect("highlight");', @response.body
165
- end
166
-
167
- def test_using_defaults_with_type_list
168
- @request.accept = "text/javascript"
169
- get :using_defaults_with_type_list
170
- assert_equal "text/javascript", @response.content_type
171
- assert_equal '$("body").visualEffect("highlight");', @response.body
172
- end
173
-
174
- def test_rjs_type_skips_layout
175
- @request.accept = "text/javascript"
176
- get :all_types_with_layout
177
- assert_equal 'RJS for all_types_with_layout', @response.body
178
- end
179
-
180
- def test_xhr
181
- xhr :get, :using_defaults
182
- assert_equal '$("body").visualEffect("highlight");', @response.body
183
- end
184
- end
185
-
186
- class RespondWithController < ActionController::Base
187
- respond_to :html, :json, :js
188
-
189
- def using_resource
190
- respond_with(resource)
191
- end
192
- protected
193
-
194
- def resource
195
- Customer.new("david", request.delete? ? nil : 13)
196
- end
197
-
198
- def _render_js(js, options)
199
- self.content_type ||= Mime::JS
200
- self.response_body = js.respond_to?(:to_js) ? js.to_js : js
201
- end
202
- end
203
-
204
- class RespondWithControllerTest < ActionController::TestCase
205
- tests RespondWithController
206
-
207
- def test_using_resource
208
- @request.accept = "text/javascript"
209
- get :using_resource
210
- assert_equal "text/javascript", @response.content_type
211
- assert_equal '$("body").visualEffect("highlight");', @response.body
212
- end
213
- end
@@ -1,19 +0,0 @@
1
- require 'abstract_unit'
2
-
3
- module ContentType
4
- class ImpliedController < ActionController::Base
5
- # Template's mime type is used if no content_type is specified
6
-
7
- self.view_paths = [ActionView::FixtureResolver.new(
8
- "content_type/implied/i_am_js_rjs.js.rjs" => "page.alert 'hello'"
9
- )]
10
- end
11
-
12
- class ImpliedContentTypeTest < Rack::TestCase
13
- test "sets Content-Type as text/javascript when rendering *.js" do
14
- get "/content_type/implied/i_am_js_rjs", "format" => "js"
15
-
16
- assert_header "Content-Type", "text/javascript; charset=utf-8"
17
- end
18
- end
19
- end
@@ -1,71 +0,0 @@
1
- require 'abstract_unit'
2
-
3
- module RenderRjs
4
- class BasicController < ActionController::Base
5
- layout "application", :only => :index_respond_to
6
-
7
- self.view_paths = [ActionView::FixtureResolver.new(
8
- "layouts/application.html.erb" => "",
9
- "render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')",
10
- "render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
11
- "render_rjs/basic/index_no_js.js.erb" => "<%= render(:partial => 'developer') %>",
12
- "render_rjs/basic/_customer.js.erb" => "JS Partial",
13
- "render_rjs/basic/_customer.html.erb" => "HTML Partial",
14
- "render_rjs/basic/_developer.html.erb" => "HTML Partial",
15
- "render_rjs/basic/index_locale.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
16
- "render_rjs/basic/_customer.da.html.erb" => "Danish HTML Partial",
17
- "render_rjs/basic/_customer.da.js.erb" => "Danish JS Partial"
18
- )]
19
-
20
- def index
21
- render
22
- end
23
-
24
- def index_respond_to
25
- respond_to do |format|
26
- format.js { render :action => "index_no_js" }
27
- end
28
- end
29
-
30
- def index_locale
31
- self.locale = :da
32
- end
33
- end
34
-
35
- class TestBasic < Rack::TestCase
36
- testing BasicController
37
-
38
- def setup
39
- @old_locale = I18n.locale
40
- end
41
-
42
- def teardown
43
- I18n.locale = @old_locale
44
- end
45
-
46
- test "rendering a partial in an RJS template should pick the JS template over the HTML one" do
47
- get :index, "format" => "js"
48
- assert_response("$(\"customer\").update(\"JS Partial\");")
49
- end
50
-
51
- test "rendering a partial in an RJS template should pick the HTML one if no JS is available" do
52
- get :index_no_js, "format" => "js"
53
- assert_response("HTML Partial")
54
- end
55
-
56
- test "rendering a partial in an RJS template should pick the HTML one if no JS is available on respond_to" do
57
- get :index_respond_to, "format" => "js"
58
- assert_response("HTML Partial")
59
- end
60
-
61
- test "replacing an element with a partial in an RJS template should pick the HTML template over the JS one" do
62
- get :index_html, "format" => "js"
63
- assert_response("$(\"customer\").update(\"HTML Partial\");")
64
- end
65
-
66
- test "replacing an element with a partial in an RJS template with a locale should pick the localed HTML template" do
67
- get :index_locale, "format" => "js"
68
- assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
69
- end
70
- end
71
- end
@@ -1,22 +0,0 @@
1
- require 'abstract_unit'
2
-
3
- class RenderJSTest < ActionController::TestCase
4
- class TestController < ActionController::Base
5
- protect_from_forgery
6
-
7
- def self.controller_path
8
- 'test'
9
- end
10
-
11
- def greeting
12
- # let's just rely on the template
13
- end
14
- end
15
-
16
- tests TestController
17
-
18
- def test_render_with_default_from_accept_header
19
- xhr :get, :greeting
20
- assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body
21
- end
22
- end
@@ -1,3 +0,0 @@
1
- <% cache do %>
2
- Old fragment caching in a partial
3
- <% end %>
@@ -1,6 +0,0 @@
1
- page.assign 'title', 'Hey'
2
- cache do
3
- page['element_1'].visual_effect :highlight
4
- page['element_2'].visual_effect :highlight
5
- end
6
- page.assign 'footer', 'Bye'
@@ -1 +0,0 @@
1
- page.replace_html 'notices', :partial => 'partial'
@@ -1 +0,0 @@
1
- page.alert 'hello world!'
@@ -1 +0,0 @@
1
- page << "RJS for all_types_with_layout"
@@ -1 +0,0 @@
1
- <html><div id="html"><%= yield %></div></html>
@@ -1 +0,0 @@
1
- page[:body].visual_effect :highlight
@@ -1 +0,0 @@
1
- page[:body].visual_effect :highlight
@@ -1 +0,0 @@
1
- page[:body].visual_effect :highlight
@@ -1 +0,0 @@
1
- <%= render :partial => "two" %> world
@@ -1 +0,0 @@
1
- partial html
@@ -1 +0,0 @@
1
- partial js
@@ -1 +0,0 @@
1
- Hello
@@ -1,2 +0,0 @@
1
- page.remove 'person'
2
- page.visual_effect :highlight, "project-#{@project_id}"
@@ -1,6 +0,0 @@
1
- page.select('.product').each do |value|
2
- page.visual_effect :highlight
3
- page.visual_effect :highlight, value
4
- page.sortable(value, :url => { :action => "order" })
5
- page.draggable(value)
6
- end