rad_core 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/Rakefile +2 -2
  2. data/bin/rad +20 -25
  3. data/lib/components/config.rb +1 -1
  4. data/lib/components/configurators.rb +2 -2
  5. data/lib/components/controller.rb +2 -2
  6. data/lib/components/conveyors.rb +2 -2
  7. data/lib/components/environment.rb +1 -1
  8. data/lib/components/environment.yml +28 -28
  9. data/lib/components/flash.rb +1 -1
  10. data/lib/components/html.rb +1 -1
  11. data/lib/components/http.rb +1 -1
  12. data/lib/components/http.yml +1 -1
  13. data/lib/components/logger.rb +2 -2
  14. data/lib/components/mailer.rb +2 -2
  15. data/lib/components/remote.rb +1 -1
  16. data/lib/components/router.rb +3 -3
  17. data/lib/components/template.rb +2 -2
  18. data/lib/components/web.rb +3 -3
  19. data/lib/rad.rb +1 -1
  20. data/lib/rad/_support/active_support.rb +7 -7
  21. data/lib/rad/_support/active_support/locales/ru/actionview.yml +8 -8
  22. data/lib/rad/_support/active_support/locales/ru/activesupport.yml +4 -4
  23. data/lib/rad/_support/active_support/locales/ru/datetime.yml +5 -5
  24. data/lib/rad/_support/active_support/time.rb +2 -2
  25. data/lib/rad/_support/addressable.rb +6 -6
  26. data/lib/rad/_support/class_loader.rb +1 -1
  27. data/lib/rad/_support/extensions.rb +5 -5
  28. data/lib/rad/_support/filters.rb +13 -13
  29. data/lib/rad/_support/hacks_and_fixes.rb +5 -5
  30. data/lib/rad/_support/mime.rb +4 -4
  31. data/lib/rad/_support/module.rb +11 -11
  32. data/lib/rad/_support/require.rb +5 -5
  33. data/lib/rad/_support/rson.rb +4 -4
  34. data/lib/rad/_support/string.rb +9 -9
  35. data/lib/rad/cli/helper.rb +5 -5
  36. data/lib/rad/configurators/_require.rb +2 -2
  37. data/lib/rad/configurators/abstract.rb +5 -5
  38. data/lib/rad/configurators/web.rb +8 -8
  39. data/lib/rad/controller/_abstract.rb +15 -14
  40. data/lib/rad/controller/_abstract/miscellaneous.rb +5 -5
  41. data/lib/rad/controller/_abstract/render.rb +40 -40
  42. data/lib/rad/controller/_abstract/responder.rb +1 -1
  43. data/lib/rad/controller/_context.rb +1 -1
  44. data/lib/rad/controller/_http.rb +11 -11
  45. data/lib/rad/controller/_require.rb +6 -6
  46. data/lib/rad/controller/processors/controller_caller.rb +3 -3
  47. data/lib/rad/controller/processors/controller_error_handling.rb +14 -14
  48. data/lib/rad/controller/processors/controller_logger.rb +1 -1
  49. data/lib/rad/conveyors/_conveyor.rb +9 -9
  50. data/lib/rad/conveyors/_conveyors.rb +4 -4
  51. data/lib/rad/conveyors/_params.rb +5 -5
  52. data/lib/rad/conveyors/_processor.rb +2 -2
  53. data/lib/rad/conveyors/_workspace.rb +5 -5
  54. data/lib/rad/conveyors/processors/conveyor_logger.rb +3 -3
  55. data/lib/rad/environment/_config.rb +4 -4
  56. data/lib/rad/environment/_environment.rb +10 -10
  57. data/lib/rad/environment/_files_helper.rb +5 -5
  58. data/lib/rad/environment/_logger.rb +9 -9
  59. data/lib/rad/environment/_require.rb +4 -4
  60. data/lib/rad/gems.rb +14 -14
  61. data/lib/rad/html/_flash.rb +5 -5
  62. data/lib/rad/html/_helpers/basic_html_helper.rb +12 -12
  63. data/lib/rad/html/_helpers/form_helper.rb +19 -19
  64. data/lib/rad/html/_helpers/javascript_helper.rb +6 -6
  65. data/lib/rad/html/_helpers/model_helper.rb +17 -17
  66. data/lib/rad/html/_require.rb +1 -1
  67. data/lib/rad/html/processors/prepare_flash.rb +3 -3
  68. data/lib/rad/html/processors/scoped_params.rb +4 -4
  69. data/lib/rad/http/_http.rb +4 -4
  70. data/lib/rad/http/_http_adapter.rb +5 -5
  71. data/lib/rad/http/_request.rb +11 -11
  72. data/lib/rad/http/_require.rb +8 -8
  73. data/lib/rad/http/_response.rb +5 -5
  74. data/lib/rad/http/_support/rack/fixes.rb +3 -3
  75. data/lib/rad/http/_support/rack/rack_adapter.rb +5 -5
  76. data/lib/rad/http/processors/evaluate_format.rb +4 -4
  77. data/lib/rad/http/processors/http_logger.rb +3 -3
  78. data/lib/rad/http/processors/http_writer.rb +7 -7
  79. data/lib/rad/http/processors/prepare_params.rb +5 -5
  80. data/lib/rad/mailer/_letter.rb +1 -1
  81. data/lib/rad/mailer/_mailer.rb +1 -1
  82. data/lib/rad/mailer/_mailer_controller.rb +6 -6
  83. data/lib/rad/mailer/_require.rb +1 -1
  84. data/lib/rad/mailer/processors/letter_builder.rb +6 -6
  85. data/lib/rad/profiles/mailer.rb +2 -2
  86. data/lib/rad/profiles/web.rb +13 -13
  87. data/lib/rad/remote/processors/remote_caller.rb +10 -10
  88. data/lib/rad/remote/processors/remote_logger.rb +1 -1
  89. data/lib/rad/router/_abstract_router.rb +9 -9
  90. data/lib/rad/router/_alias_router.rb +34 -34
  91. data/lib/rad/router/_basic_router.rb +12 -12
  92. data/lib/rad/router/_configurator.rb +6 -6
  93. data/lib/rad/router/_core_routing_helper.rb +4 -4
  94. data/lib/rad/router/_object_router.rb +45 -45
  95. data/lib/rad/router/_require.rb +8 -8
  96. data/lib/rad/router/_restful_router.rb +25 -25
  97. data/lib/rad/router/_router.rb +78 -78
  98. data/lib/rad/router/_simple_router.rb +5 -5
  99. data/lib/rad/router/processors/router.rb +6 -6
  100. data/lib/rad/spec/controller.rb +9 -9
  101. data/lib/rad/spec/environment.rb +7 -7
  102. data/lib/rad/spec/http.rb +2 -2
  103. data/lib/rad/spec/http_controller.rb +22 -22
  104. data/lib/rad/spec/mailer.rb +4 -4
  105. data/lib/rad/spec/remote.rb +1 -1
  106. data/lib/rad/spec/router.rb +4 -4
  107. data/lib/rad/spec/template.rb +2 -2
  108. data/lib/rad/tasks.rb +2 -2
  109. data/lib/rad/template/_context.rb +15 -15
  110. data/lib/rad/template/_relative_path_resolver.rb +1 -1
  111. data/lib/rad/template/_support/tilt.rb +17 -17
  112. data/lib/rad/template/_support/tilt_fixes.rb +3 -3
  113. data/lib/rad/template/_template.rb +47 -47
  114. data/lib/rad/web/_ajax_helper.rb +4 -4
  115. data/lib/rad/web/_controller_miscellaneous_helper.rb +5 -5
  116. data/lib/rad/web/_ensure_no_www.rb +5 -5
  117. data/lib/rad/web/_protect_from_forgery.rb +18 -18
  118. data/lib/rad/web/_require.rb +7 -7
  119. data/lib/rad/web/_router/abstract_routing_helper.rb +4 -4
  120. data/lib/rad/web/_router/controller_routing_helper.rb +15 -15
  121. data/lib/rad/web/_router/view_routing_helper.rb +12 -12
  122. data/readme.md +5 -5
  123. data/spec/controller/abstract_spec.rb +29 -29
  124. data/spec/controller/context_spec.rb +32 -32
  125. data/spec/controller/error_handling_spec.rb +31 -31
  126. data/spec/controller/helper_spec.rb +13 -13
  127. data/spec/controller/http_spec.rb +32 -32
  128. data/spec/controller/render_spec.rb +59 -59
  129. data/spec/conveyors/conveyors_spec.rb +32 -32
  130. data/spec/environment/config_spec.rb +6 -6
  131. data/spec/environment/environment_spec.rb +7 -7
  132. data/spec/environment/minimal_app_spec.rb +4 -4
  133. data/spec/environment/standard_app_spec.rb +10 -10
  134. data/spec/html/basic_html_helper_spec.rb +6 -6
  135. data/spec/html/form_helper_spec.rb +5 -5
  136. data/spec/html/javascript_helper_spec.rb +4 -4
  137. data/spec/html/model_helper_spec.rb +12 -12
  138. data/spec/html/scoped_params_spec.rb +2 -2
  139. data/spec/html/spec_helper.rb +3 -3
  140. data/spec/http/http_spec.rb +9 -9
  141. data/spec/http/miscellaneous_spec.rb +2 -2
  142. data/spec/mailer/mail_controller_spec.rb +23 -23
  143. data/spec/remote/remote_spec.rb +26 -26
  144. data/spec/router/alias_router_spec.rb +22 -22
  145. data/spec/router/basic_router_spec.rb +8 -8
  146. data/spec/router/configurator_spec.rb +4 -4
  147. data/spec/router/integration_spec.rb +17 -17
  148. data/spec/router/object_router_spec.rb +47 -47
  149. data/spec/router/persistent_params_spec.rb +18 -18
  150. data/spec/router/restful_router_spec.rb +39 -39
  151. data/spec/router/router_spec.rb +37 -37
  152. data/spec/router/routing_helper_spec.rb +18 -18
  153. data/spec/support/filters_spec.rb +11 -13
  154. data/spec/template/template_spec.rb +43 -45
  155. data/spec/template/template_spec/views/layout/content_for/content.erb +3 -1
  156. data/spec/template/template_spec/views/layout/content_for/layout.erb +1 -1
  157. data/spec/template/tilt_spec.rb +24 -24
  158. data/spec/web/basic_spec.rb +25 -25
  159. data/spec/web/controller_routing_helper_spec.rb +26 -26
  160. data/spec/web/flash_spec.rb +31 -31
  161. data/spec/web/protect_from_forgery_spec.rb +44 -44
  162. data/spec/web/spec_helper_spec.rb +16 -16
  163. data/spec/web/view_routing_helper_spec.rb +31 -31
  164. metadata +46 -49
  165. data/lib/rad/_support/callbacks.rb +0 -166
  166. data/lib/rad/_support/ruby_ext_with_active_support.rb +0 -4
  167. data/spec/support/callbacks_spec.rb +0 -157
@@ -2,83 +2,83 @@ require 'spec_helper'
2
2
 
3
3
  describe "UrlHelper" do
4
4
  isolate :conveyors, :router, before: :all
5
-
5
+
6
6
  before :all do
7
7
  rad.web
8
-
8
+
9
9
  class ControllerStub
10
10
  inherit Rad::ControllerRoutingHelper, Rad::ControllerMiscellaneousHelper
11
-
11
+
12
12
  def url_for *args
13
13
  args.first
14
- end
14
+ end
15
15
  end
16
16
  end
17
-
17
+
18
18
  after :all do
19
19
  remove_constants :ControllerStub
20
20
  end
21
-
22
- before do
21
+
22
+ before do
23
23
  @c = ControllerStub.new
24
24
  end
25
-
25
+
26
26
  def stub_workspace
27
27
  @response = Rad::Http::Response.new
28
28
  @params = Rad::Conveyors::Params.new
29
-
30
- @workspace = Object.new
29
+
30
+ @workspace = Object.new
31
31
  @workspace.stub(:params).and_return(@params)
32
32
  @workspace.stub(:response).and_return(@response)
33
-
33
+
34
34
  @c.stub(:workspace).and_return(@workspace)
35
35
  end
36
-
36
+
37
37
  def within_request &block
38
38
  @response.body = catch(:halt){block.call}
39
39
  end
40
-
40
+
41
41
  describe "redirect_to" do
42
42
  before do
43
43
  stub_workspace
44
44
  end
45
-
46
- it "html format" do
45
+
46
+ it "html format" do
47
47
  @params.format = 'html'
48
-
48
+
49
49
  within_request{@c.redirect_to('/some_book')}
50
50
  @response.status.should == 302
51
51
  @response.headers['Location'].should == "/some_book"
52
52
  @response.body.should =~ /You are being/
53
53
  end
54
-
55
- it "full url, special case (from error)" do
54
+
55
+ it "full url, special case (from error)" do
56
56
  @params.format = 'html'
57
-
57
+
58
58
  within_request{@c.redirect_to('http://localhost/some_book')}
59
59
  @response.status.should == 302
60
60
  @response.headers['Location'].should == "http://localhost/some_book"
61
61
  @response.body.should =~ /You are being/
62
62
  end
63
-
63
+
64
64
  it "js format" do
65
65
  @params.format = 'js'
66
-
66
+
67
67
  within_request{@c.redirect_to('/some_book')}
68
68
  @response.status.should == 200
69
69
  @response.headers['Location'].should be_blank
70
70
  @response.body_as_string.should == "window.location = '/some_book';"
71
71
  end
72
- end
73
-
72
+ end
73
+
74
74
  describe "reload_page" do
75
75
  before do
76
76
  stub_workspace
77
77
  end
78
-
79
- it "basic" do
78
+
79
+ it "basic" do
80
80
  @params.format = 'js'
81
-
81
+
82
82
  within_request{@c.reload_page}
83
83
  @response.status.should == 200
84
84
  @response.body_as_string.should =~ /reload/
@@ -3,13 +3,13 @@ require 'html/spec_helper'
3
3
 
4
4
  describe "Flash" do
5
5
  with_prepare_params
6
-
6
+
7
7
  isolate :conveyors, :router, before: :all
8
-
8
+
9
9
  before :all do
10
10
  rad.mode = :development, true
11
11
  rad.web
12
-
12
+
13
13
  class MockFlashContext < Rad::MockTemplateContext
14
14
  include Rad::Html::FlashHelper, Rad::ControllerRoutingHelper
15
15
 
@@ -23,7 +23,7 @@ describe "Flash" do
23
23
  block = workspace.check_flash.request
24
24
  catch :halt do
25
25
  block.call context if block
26
- end
26
+ end
27
27
  workspace.request_done = true
28
28
 
29
29
  next_processor.call
@@ -40,11 +40,11 @@ describe "Flash" do
40
40
 
41
41
  block = workspace.check_flash.after_request
42
42
  block.call workspace if block
43
- workspace.after_request_done = true
43
+ workspace.after_request_done = true
44
44
  end
45
45
  end
46
-
47
-
46
+
47
+
48
48
  rad.conveyors.web do |web|
49
49
  web.use Rad::Http::Processors::PrepareParams
50
50
  web.use FlashTestHelper
@@ -52,19 +52,19 @@ describe "Flash" do
52
52
  web.use FlashTestRenderCaller
53
53
  end
54
54
  end
55
-
55
+
56
56
  after :all do
57
57
  rad.mode = :test, true
58
-
58
+
59
59
  remove_constants %w(
60
60
  MockFlashContext
61
61
  FlashTestRenderCaller
62
62
  FlashTestHelper
63
63
  )
64
64
  end
65
-
66
- def check_flash opt
67
- workspace = nil
65
+
66
+ def check_flash opt
67
+ workspace = nil
68
68
  result = rad.http.call(Rad::Http::Request.stub_environment, check_flash: opt.to_openobject) do |c|
69
69
  c.call
70
70
  workspace = rad.workspace
@@ -72,14 +72,14 @@ describe "Flash" do
72
72
 
73
73
  workspace.before_request_done.should be_true
74
74
  workspace.request_done.should be_true
75
- workspace.after_request_done.should be_true
75
+ workspace.after_request_done.should be_true
76
76
  workspace
77
77
  end
78
-
78
+
79
79
  it "flash should be extracted from session if there's any" do
80
80
  check_flash(
81
- before_request: lambda{|workspace|
82
- workspace.params.format = 'html'
81
+ before_request: lambda{|workspace|
82
+ workspace.params.format = 'html'
83
83
  workspace.request.session['flash'] = {info: 'Ok'}.to_json
84
84
  },
85
85
  request: lambda{|context|
@@ -89,7 +89,7 @@ describe "Flash" do
89
89
  workspace.request.session['flash'].should be_nil
90
90
  }
91
91
  )
92
-
92
+
93
93
  check_flash(
94
94
  before_request: lambda{|workspace|
95
95
  workspace.params.format = 'html'
@@ -99,7 +99,7 @@ describe "Flash" do
99
99
  }
100
100
  )
101
101
  end
102
-
102
+
103
103
  it "flash should be seen in the same request" do
104
104
  check_flash(
105
105
  before_request: lambda{|workspace|
@@ -114,7 +114,7 @@ describe "Flash" do
114
114
  }
115
115
  )
116
116
  end
117
-
117
+
118
118
  it "flash with :redirect should be saved for next request in session" do
119
119
  check_flash(
120
120
  before_request: lambda{|workspace|
@@ -131,12 +131,12 @@ describe "Flash" do
131
131
  }
132
132
  )
133
133
  end
134
-
134
+
135
135
  it "AJAX ('js' format) flash should be displayed in the same request" do
136
136
  check_flash(
137
137
  before_request: lambda{|workspace|
138
138
  workspace.params.format = 'js'
139
- },
139
+ },
140
140
  request: lambda{|context|
141
141
  context.flash.info = "Ok"
142
142
  context.flash.info.should == "Ok"
@@ -146,12 +146,12 @@ describe "Flash" do
146
146
  }
147
147
  )
148
148
  end
149
-
149
+
150
150
  it "flash with AJAX redirect ('js' format) should be saved for next request in session" do
151
151
  check_flash(
152
152
  before_request: lambda{|workspace|
153
153
  workspace.params.format = 'js'
154
- },
154
+ },
155
155
  request: lambda{|context|
156
156
  context.flash.info = "Ok"
157
157
  context.flash.info.should == "Ok"
@@ -163,7 +163,7 @@ describe "Flash" do
163
163
  }
164
164
  )
165
165
  end
166
-
166
+
167
167
  it "multiple messages with non-AJAX request" do
168
168
  check_flash(
169
169
  before_request: lambda{|workspace|
@@ -172,14 +172,14 @@ describe "Flash" do
172
172
  request: lambda{|context|
173
173
  context.flash.error = "Error"
174
174
  context.flash.error.should == "Error"
175
-
175
+
176
176
  context.flash.info.should == 'Ok'
177
177
  },
178
178
  after_request: lambda{|workspace|
179
179
  workspace.request.session['flash'].should be_nil
180
180
  }
181
181
  )
182
-
182
+
183
183
  check_flash(
184
184
  before_request: lambda{|workspace|
185
185
  workspace.params.format = 'js'
@@ -190,7 +190,7 @@ describe "Flash" do
190
190
  context.flash.error.should == "Error"
191
191
  context.redirect_to '/'
192
192
  context.flash.error.should be_nil
193
-
193
+
194
194
  context.flash.info.should == 'Ok'
195
195
  },
196
196
  after_request: lambda{|workspace|
@@ -198,17 +198,17 @@ describe "Flash" do
198
198
  }
199
199
  )
200
200
  end
201
-
201
+
202
202
  it "multiple messages with AJAX request" do
203
203
  check_flash(
204
204
  before_request: lambda{|workspace|
205
205
  workspace.params.format = 'js'
206
- workspace.request.session['flash'] = {info: 'Ok'}.to_json
206
+ workspace.request.session['flash'] = {info: 'Ok'}.to_json
207
207
  },
208
208
  request: lambda{|context|
209
209
  context.flash.error = "Error"
210
210
  context.flash.error.should == "Error"
211
-
211
+
212
212
  context.flash.info.should == 'Ok'
213
213
  },
214
214
  after_request: lambda{|workspace|
@@ -216,5 +216,5 @@ describe "Flash" do
216
216
  }
217
217
  )
218
218
  end
219
-
219
+
220
220
  end
@@ -1,13 +1,13 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Forgery protection" do
3
+ describe "Forgery protection" do
4
4
  with_prepare_params
5
-
5
+
6
6
  isolate :conveyors, :router, before: :all
7
7
 
8
8
  before :all do
9
9
  rad.web
10
-
10
+
11
11
  class ForgerySpecHelper < Rad::Conveyors::Processor
12
12
  def call
13
13
  block = workspace.check_forgery.before_request
@@ -18,34 +18,34 @@ describe "Forgery protection" do
18
18
 
19
19
  block = workspace.check_forgery.after_request
20
20
  block.call workspace if block
21
- workspace.after_request_done = true
21
+ workspace.after_request_done = true
22
22
  end
23
- end
23
+ end
24
24
 
25
25
  class ::TheController
26
26
  inherit Rad::Controller::Http
27
-
27
+
28
28
  protect_from_forgery_without_test only: :protected_method
29
-
29
+
30
30
  def protected_method
31
31
  render inline: 'protected result'
32
32
  end
33
-
33
+
34
34
  def method_without_protection
35
35
  render inline: 'result'
36
36
  end
37
-
37
+
38
38
  def dumb_method; end
39
39
  end
40
40
  end
41
-
42
- after :all do
41
+
42
+ after :all do
43
43
  remove_constants %w(TheController ForgerySpecHelper)
44
44
  end
45
-
45
+
46
46
  before do
47
47
  rad.http.stub(:session).and_return({'key' => 'session_id'})
48
-
48
+
49
49
  rad.delete :conveyors
50
50
  rad.conveyors.web do |web|
51
51
  web.use Rad::Http::Processors::PrepareParams
@@ -55,24 +55,24 @@ describe "Forgery protection" do
55
55
  web.use Rad::Controller::Processors::ControllerCaller
56
56
  end
57
57
  end
58
-
59
- def check_forgery opt
60
- workspace = nil
61
-
58
+
59
+ def check_forgery opt
60
+ workspace = nil
61
+
62
62
  result = rad.http.call(Rad::Http::Request.stub_environment, check_forgery: opt.to_openobject) do |c|
63
63
  c.call
64
64
  workspace = rad[:workspace]
65
65
  end
66
-
66
+
67
67
  workspace.before_request_done.should be_true
68
68
  workspace.after_request_done.should be_true
69
69
  workspace
70
70
  end
71
-
71
+
72
72
  it "should set :authenticity_token only for :get and 'html' request" do
73
73
  check_forgery(
74
74
  before_request: lambda{|workspace|
75
- workspace.env['REQUEST_METHOD'] = 'GET'
75
+ workspace.env['REQUEST_METHOD'] = 'GET'
76
76
  workspace.env['CONTENT_TYPE'] = 'text/html'
77
77
  workspace.class = TheController
78
78
  workspace.method_name = :dumb_method
@@ -81,11 +81,11 @@ describe "Forgery protection" do
81
81
  workspace.request.session['authenticity_token'].should_not be_blank
82
82
  }
83
83
  )
84
-
84
+
85
85
  # post
86
86
  check_forgery(
87
- before_request: lambda{|workspace|
88
- workspace.env['REQUEST_METHOD'] = 'POST'
87
+ before_request: lambda{|workspace|
88
+ workspace.env['REQUEST_METHOD'] = 'POST'
89
89
  workspace.env['CONTENT_TYPE'] = 'text/html'
90
90
  workspace.class = TheController
91
91
  workspace.method_name = :dumb_method
@@ -95,88 +95,88 @@ describe "Forgery protection" do
95
95
  }
96
96
  )
97
97
  end
98
-
98
+
99
99
  it "should check any non :get request with browser's formats for :authenticity_token" do
100
100
  lambda{
101
101
  check_forgery(
102
- before_request: lambda{|workspace|
103
- workspace.env['REQUEST_METHOD'] = 'POST'
102
+ before_request: lambda{|workspace|
103
+ workspace.env['REQUEST_METHOD'] = 'POST'
104
104
  workspace.env['CONTENT_TYPE'] = 'text/html'
105
105
  workspace.class = TheController
106
- workspace.method_name = 'protected_method'
106
+ workspace.method_name = :protected_method
107
107
  }
108
108
  )
109
109
  }.should raise_error(/invalid authenticity token/)
110
110
  end
111
-
111
+
112
112
  it "should pass request with correct authenticity_token" do
113
113
  check_forgery(
114
114
  before_request: lambda{|workspace|
115
- workspace.env['REQUEST_METHOD'] = 'POST'
115
+ workspace.env['REQUEST_METHOD'] = 'POST'
116
116
  workspace.env['CONTENT_TYPE'] = 'text/html'
117
117
  workspace.request.session['authenticity_token'] = 'secure token'
118
118
  workspace.params['authenticity_token'] = 'secure token'
119
119
  workspace.class = TheController
120
- workspace.method_name = 'protected_method'
120
+ workspace.method_name = :protected_method
121
121
  },
122
122
  after_request: lambda{|workspace|
123
123
  workspace.content.should == "protected result"
124
124
  }
125
125
  )
126
126
  end
127
-
127
+
128
128
  it "should not check request with non-browser content type" do
129
129
  check_forgery(
130
130
  before_request: lambda{|workspace|
131
- workspace.env['REQUEST_METHOD'] = 'POST'
131
+ workspace.env['REQUEST_METHOD'] = 'POST'
132
132
  workspace.env['CONTENT_TYPE'] = 'non-browser-format'
133
133
  workspace.class = TheController
134
- workspace.method_name = 'protected_method'
134
+ workspace.method_name = :protected_method
135
135
  },
136
136
  after_request: lambda{|workspace|
137
137
  workspace.content.should == "protected result"
138
138
  }
139
139
  )
140
140
  end
141
-
141
+
142
142
  # it "should not check request with non-browser format" do
143
143
  # check_forgery(
144
144
  # before_request: lambda{|workspace|
145
- # workspace.env['REQUEST_METHOD'] = 'POST'
145
+ # workspace.env['REQUEST_METHOD'] = 'POST'
146
146
  # workspace.env['CONTENT_TYPE'] = 'text/html'
147
147
  # workspace.params['format'] = 'json'
148
148
  # workspace.class = TheController
149
- # workspace.method_name = 'protected_method'
149
+ # workspace.method_name = :protected_method
150
150
  # },
151
151
  # after_request: lambda{|workspace|
152
152
  # workspace.content.should == "protected result"
153
153
  # }
154
154
  # )
155
155
  # end
156
-
156
+
157
157
  it "should not protect non protected methods" do
158
158
  check_forgery(
159
- before_request: lambda{|workspace|
160
- workspace.env['REQUEST_METHOD'] = 'POST'
159
+ before_request: lambda{|workspace|
160
+ workspace.env['REQUEST_METHOD'] = 'POST'
161
161
  workspace.env['CONTENT_TYPE'] = 'text/html'
162
162
  workspace.class = TheController
163
- workspace.method_name = 'method_without_protection'
163
+ workspace.method_name = :method_without_protection
164
164
  },
165
165
  after_request: lambda{|workspace|
166
166
  workspace.content.should == "result"
167
167
  }
168
- )
168
+ )
169
169
  end
170
-
170
+
171
171
  # it "OUTDATED should use :session_authenticity_token from params (for flash support)" do
172
172
  # check_forgery(
173
173
  # before_request: lambda{|workspace|
174
- # workspace.env['REQUEST_METHOD'] = 'POST'
174
+ # workspace.env['REQUEST_METHOD'] = 'POST'
175
175
  # workspace.params.format = 'text/html'
176
176
  # # workspace.params['session_authenticity_token'] = 'secure token'
177
177
  # workspace.params['authenticity_token'] = 'secure token'
178
178
  # workspace.class = TheController
179
- # workspace.method_name = 'protected_method'
179
+ # workspace.method_name = :protected_method
180
180
  # },
181
181
  # after_request: lambda{|workspace|
182
182
  # workspace.content.should == "protected result"