actionpack 1.10.1 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ *1.10.2* (October 26th, 2005)
2
+
3
+ * Reset template variables after using render_to_string [skaes@web.de]
4
+
5
+ * Expose the session model backing CGI::Session
6
+
7
+ * Abbreviate RAILS_ROOT in traces
8
+
9
+
1
10
  *1.10.1* (October 19th, 2005)
2
11
 
3
12
  * Update error trace templates [Nicholas Seckar]
@@ -4,6 +4,7 @@ require 'action_controller/routing'
4
4
  require 'action_controller/code_generation'
5
5
  require 'action_controller/url_rewriter'
6
6
  require 'drb'
7
+ require 'set'
7
8
 
8
9
  module ActionController #:nodoc:
9
10
  class ActionControllerError < StandardError #:nodoc:
@@ -622,6 +623,8 @@ module ActionController #:nodoc:
622
623
  def render_to_string(options = nil) #:doc:
623
624
  result = render(options)
624
625
  erase_render_results
626
+ @variables_added = nil
627
+ @template.instance_variable_set("@assigns_added", nil)
625
628
  result
626
629
  end
627
630
 
@@ -846,8 +849,7 @@ module ActionController #:nodoc:
846
849
  end
847
850
 
848
851
  def self.action_methods
849
- #puts "action method: #{public_instance_methods.inspect}"
850
- @action_methods ||= (public_instance_methods - hidden_actions).inject({}) { |h, k| h[k] = true; h }
852
+ @action_methods ||= Set.new(public_instance_methods - hidden_actions)
851
853
  end
852
854
 
853
855
  def add_variables_to_assigns
@@ -50,9 +50,13 @@ module ActionController #:nodoc:
50
50
 
51
51
  private
52
52
  def component_response(options, reuse_response = true)
53
- c = component_class(options)
54
- c.after_filter {|c| flash.keep }
55
- c.process(request_for_component(options), reuse_response ? @response : response_for_component)
53
+ begin
54
+ ActionController::Flash::FlashHash.avoid_sweep = true
55
+ Thread.current[:p] = component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component)
56
+ ensure
57
+ ActionController::Flash::FlashHash.avoid_sweep = false
58
+ end
59
+ Thread.current[:p]
56
60
  end
57
61
 
58
62
  def component_class(options)
@@ -43,6 +43,9 @@ module ActionController #:nodoc:
43
43
  end
44
44
 
45
45
  class FlashHash < Hash
46
+ @@avoid_sweep = false
47
+ cattr_accessor :avoid_sweep
48
+
46
49
  def initialize #:nodoc:
47
50
  super
48
51
  @used = {}
@@ -99,6 +102,7 @@ module ActionController #:nodoc:
99
102
  #
100
103
  # This method is called automatically by filters, so you generally don't need to care about it.
101
104
  def sweep #:nodoc:
105
+ return if @@avoid_sweep
102
106
  keys.each do |k|
103
107
  unless @used[k]
104
108
  use(k)
@@ -5,6 +5,16 @@ require 'base64'
5
5
 
6
6
  class CGI
7
7
  class Session
8
+ # Return this session's underlying Session model. Useful for the DB-backed session stores.
9
+ def model
10
+ @dbman.model rescue nil
11
+ end
12
+
13
+ # Proxy missing methods to the underlying Session model.
14
+ def method_missing(method, *args, &block)
15
+ if model then model.send(method, *args, &block) else super end
16
+ end
17
+
8
18
  # A session store backed by an Active Record class.
9
19
  #
10
20
  # A default class is provided, but any object duck-typing to an Active
@@ -277,6 +287,11 @@ class CGI
277
287
  end
278
288
  end
279
289
 
290
+ # Access the underlying session model.
291
+ def model
292
+ @session
293
+ end
294
+
280
295
  # Restore session state. The session model handles unmarshaling.
281
296
  def restore
282
297
  if @session
@@ -4,9 +4,14 @@
4
4
  ["Framework Trace", @exception.framework_backtrace],
5
5
  ["Full Trace", @exception.clean_backtrace]
6
6
  ]
7
+ if defined?(RAILS_ROOT)
8
+ traces.each { |name, trace| trace.map! { |p| p.gsub(/^#{RAILS_ROOT}/, '<b>#{RAILS_ROOT}</b>') } }
9
+ end
7
10
  names = traces.collect {|name, trace| name}
8
11
  %>
9
12
 
13
+ <p><code>RAILS_ROOT: <%= RAILS_ROOT %></code></p>
14
+
10
15
  <div id="traces">
11
16
  <% names.each do |name| -%>
12
17
  <%
@@ -2,7 +2,7 @@ module ActionPack
2
2
  module Version #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 10
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/rakefile CHANGED
@@ -62,7 +62,7 @@ spec = Gem::Specification.new do |s|
62
62
  s.has_rdoc = true
63
63
  s.requirements << 'none'
64
64
 
65
- s.add_dependency('activesupport', '= 1.2.1' + PKG_BUILD)
65
+ s.add_dependency('activesupport', '= 1.2.2' + PKG_BUILD)
66
66
 
67
67
  s.require_path = 'lib'
68
68
  s.autorequire = 'action_controller'
@@ -53,7 +53,6 @@ module CommonActiveRecordStoreTests
53
53
  @new_session.close
54
54
  end
55
55
  end
56
-
57
56
  end
58
57
 
59
58
  class ActiveRecordStoreTest < Test::Unit::TestCase
@@ -73,13 +72,17 @@ class ActiveRecordStoreTest < Test::Unit::TestCase
73
72
  @new_session['foo'] = 'bar'
74
73
  end
75
74
 
75
+ def test_model_attribute
76
+ assert_kind_of CGI::Session::ActiveRecordStore::Session, @new_session.model
77
+ assert_equal @new_session.model.data, @new_session.data
78
+ end
79
+
76
80
  def teardown
77
81
  session_class.drop_table!
78
82
  end
79
83
  end
80
84
 
81
85
  class ColumnLimitTest < Test::Unit::TestCase
82
-
83
86
  def setup
84
87
  @session_class = CGI::Session::ActiveRecordStore::Session
85
88
  @session_class.create_table!
@@ -97,10 +100,8 @@ class ColumnLimitTest < Test::Unit::TestCase
97
100
  s.data
98
101
  assert_raises(ActionController::SessionOverflowError) { s.save }
99
102
  end
100
-
101
103
  end
102
104
 
103
-
104
105
  class DeprecatedActiveRecordStoreTest < ActiveRecordStoreTest
105
106
  def setup
106
107
  session_class.connection.execute 'create table old_sessions (id integer primary key, sessid text unique, data text)'
@@ -128,12 +129,17 @@ class SqlBypassActiveRecordStoreTest < ActiveRecordStoreTest
128
129
  end
129
130
  @session_class
130
131
  end
132
+
133
+ def test_model_attribute
134
+ assert_kind_of CGI::Session::ActiveRecordStore::SqlBypass, @new_session.model
135
+ assert_equal @new_session.model.data, @new_session.data
136
+ end
131
137
  end
132
138
 
133
139
 
134
140
  # End of safety net.
135
141
  rescue Object => e
136
- $stderr.puts "Skipping CGI::Session::ActiveRecordStore tests: #{e}"
142
+ $stderr.puts "Skipping CGI::Session::ActiveRecordStore tests: #{e}"
137
143
  #$stderr.puts " #{e.backtrace.join("\n ")}"
138
144
  end
139
145
  end
@@ -67,7 +67,11 @@ class ControllerInstanceTests < Test::Unit::TestCase
67
67
  end
68
68
 
69
69
  def test_action_methods
70
- @empty_controllers.each {|c| assert_equal({}, c.send(:action_methods), "#{c.class.controller_path} should be empty!")}
71
- @non_empty_controllers.each {|c| assert_equal({"public_action"=>true}, c.send(:action_methods), "#{c.class.controller_path} should not be empty!")}
70
+ @empty_controllers.each do |c|
71
+ assert_equal Set.new, c.send(:action_methods), "#{c.class.controller_path} should be empty!"
72
+ end
73
+ @non_empty_controllers.each do |c|
74
+ assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.class.controller_path} should not be empty!"
75
+ end
72
76
  end
73
77
  end
@@ -89,6 +89,10 @@ class TestController < ActionController::Base
89
89
  ActionView::Base.local_assigns_support_string_keys = false
90
90
  end
91
91
 
92
+ def render_to_string_test
93
+ @foo = render_to_string :inline => "this is a test"
94
+ end
95
+
92
96
  def rescue_action(e) raise end
93
97
 
94
98
  private
@@ -209,6 +213,11 @@ class RenderTest < Test::Unit::TestCase
209
213
  assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", process_request.body
210
214
  end
211
215
 
216
+ def test_render_to_string_resets_assigns
217
+ @request.action = "render_to_string_test"
218
+ assert_equal "The value of foo is: ::this is a test::\n", process_request.body
219
+ end
220
+
212
221
  def test_nested_rendering
213
222
  @request.action = "hello_world"
214
223
  assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
@@ -0,0 +1 @@
1
+ The value of foo is: ::<%= @foo %>::
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: actionpack
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.10.1
7
- date: 2005-10-19
6
+ version: 1.10.2
7
+ date: 2005-10-26 00:00:00 +02:00
8
8
  summary: Web-flow and rendering framework putting the VC in MVC.
9
9
  require_paths:
10
10
  - lib
@@ -26,6 +26,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
26
26
  version: 0.0.0
27
27
  version:
28
28
  platform: ruby
29
+ signing_key:
30
+ cert_chain:
29
31
  authors:
30
32
  - David Heinemeier Hansson
31
33
  files:
@@ -216,6 +218,7 @@ files:
216
218
  - test/fixtures/test/hello_xml_world.rxml
217
219
  - test/fixtures/test/list.rhtml
218
220
  - test/fixtures/test/potential_conflicts.rhtml
221
+ - test/fixtures/test/render_to_string_test.rhtml
219
222
  - test/fixtures/test/update_element_with_capture.rhtml
220
223
  - test/template/active_record_helper_test.rb
221
224
  - test/template/asset_tag_helper_test.rb
@@ -263,5 +266,5 @@ dependencies:
263
266
  -
264
267
  - "="
265
268
  - !ruby/object:Gem::Version
266
- version: 1.2.1
269
+ version: 1.2.2
267
270
  version: