actionpack 3.0.0.rc2 → 3.0.0

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.

@@ -148,29 +148,29 @@ module ActionDispatch
148
148
  def build_named_route_call(records, inflection, options = {})
149
149
  unless records.is_a?(Array)
150
150
  record = extract_record(records)
151
- route = ''
151
+ route = []
152
152
  else
153
153
  record = records.pop
154
- route = records.inject("") do |string, parent|
154
+ route = records.map do |parent|
155
155
  if parent.is_a?(Symbol) || parent.is_a?(String)
156
- string << "#{parent}_"
156
+ parent
157
157
  else
158
- string << ActiveModel::Naming.plural(parent).singularize
159
- string << "_"
158
+ ActiveModel::Naming.plural(parent).singularize
160
159
  end
161
160
  end
162
161
  end
163
162
 
164
163
  if record.is_a?(Symbol) || record.is_a?(String)
165
- route << "#{record}_"
164
+ route << record
166
165
  else
167
166
  route << ActiveModel::Naming.plural(record)
168
- route = route.singularize if inflection == :singular
169
- route << "_"
170
- route << "index_" if ActiveModel::Naming.uncountable?(record) && inflection == :plural
167
+ route = [route.join("_").singularize] if inflection == :singular
168
+ route << "index" if ActiveModel::Naming.uncountable?(record) && inflection == :plural
171
169
  end
172
170
 
173
- action_prefix(options) + route + routing_type(options).to_s
171
+ route << routing_type(options)
172
+
173
+ action_prefix(options) + route.join("_")
174
174
  end
175
175
 
176
176
  def extract_record(record_or_hash_or_array)
@@ -3,7 +3,7 @@ require 'action_controller/vendor/html-scanner'
3
3
  module ActionDispatch
4
4
  module Assertions
5
5
  module DomAssertions
6
- # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
6
+ # \Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
7
7
  #
8
8
  # ==== Examples
9
9
  #
@@ -1,6 +1,6 @@
1
1
  module ActionDispatch
2
2
  module Assertions
3
- # A small suite of assertions that test responses from Rails applications.
3
+ # A small suite of assertions that test responses from \Rails applications.
4
4
  module ResponseAssertions
5
5
  extend ActiveSupport::Concern
6
6
 
@@ -18,8 +18,8 @@ module ActionDispatch
18
18
  # * <tt>:missing</tt> - Status code was 404
19
19
  # * <tt>:error</tt> - Status code was in the 500-599 range
20
20
  #
21
- # You can also pass an explicit status number like assert_response(501)
22
- # or its symbolic equivalent assert_response(:not_implemented).
21
+ # You can also pass an explicit status number like <tt>assert_response(501)</tt>
22
+ # or its symbolic equivalent <tt>assert_response(:not_implemented)</tt>.
23
23
  # See ActionDispatch::StatusCodes for a full list.
24
24
  #
25
25
  # ==== Examples
@@ -45,8 +45,8 @@ module ActionDispatch
45
45
  end
46
46
 
47
47
  # Assert that the redirection options passed in match those of the redirect called in the latest action.
48
- # This match can be partial, such that assert_redirected_to(:controller => "weblog") will also
49
- # match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on.
48
+ # This match can be partial, such that <tt>assert_redirected_to(:controller => "weblog")</tt> will also
49
+ # match the redirection of <tt>redirect_to(:controller => "weblog", :action => "show")</tt> and so on.
50
50
  #
51
51
  # ==== Examples
52
52
  #
@@ -4,10 +4,10 @@ require 'active_support/core_ext/hash/indifferent_access'
4
4
 
5
5
  module ActionDispatch
6
6
  module Assertions
7
- # Suite of assertions to test routes generated by Rails and the handling of requests made to them.
7
+ # Suite of assertions to test routes generated by \Rails and the handling of requests made to them.
8
8
  module RoutingAssertions
9
9
  # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
10
- # match +path+. Basically, it asserts that Rails recognizes the route given by +expected_options+.
10
+ # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
11
11
  #
12
12
  # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
13
13
  # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
@@ -3,8 +3,7 @@ module ActionPack
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "rc2"
7
6
 
8
- STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
9
8
  end
10
9
  end
@@ -106,7 +106,7 @@ module ActionView
106
106
  # <%= javascript_include_tag :defaults %>
107
107
  # <% end %>
108
108
  #
109
- # That will place <script> tags for Prototype, Scriptaculous, and application.js (if it exists)
109
+ # That will place <tt>script</tt> tags for Prototype, Scriptaculous, and application.js (if it exists)
110
110
  # on the page; this technique is useful if you'll only be using these scripts in a few views.
111
111
  #
112
112
  # Note that content_for concatenates the blocks it is given for a particular
@@ -1,6 +1,7 @@
1
- require "date"
1
+ require 'date'
2
2
  require 'action_view/helpers/tag_helper'
3
3
  require 'active_support/core_ext/hash/slice'
4
+ require 'active_support/core_ext/object/with_options'
4
5
 
5
6
  module ActionView
6
7
  module Helpers
@@ -751,10 +752,8 @@ module ActionView
751
752
  # => [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
752
753
  # "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
753
754
  def translated_month_names
754
- begin
755
- key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
756
- I18n.translate(key, :locale => @options[:locale])
757
- end
755
+ key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
756
+ I18n.translate(key, :locale => @options[:locale])
758
757
  end
759
758
 
760
759
  # Lookup month name for number
@@ -781,9 +780,7 @@ module ActionView
781
780
  memoize :date_order
782
781
 
783
782
  def translated_date_order
784
- begin
785
- I18n.translate(:'date.order', :locale => @options[:locale]) || []
786
- end
783
+ I18n.translate(:'date.order', :locale => @options[:locale]) || []
787
784
  end
788
785
 
789
786
  # Build full select tag from date type and options
@@ -837,15 +834,14 @@ module ActionView
837
834
  # prompt_option_tag(:month, :prompt => 'Select month')
838
835
  # => "<option value="">Select month</option>"
839
836
  def prompt_option_tag(type, options)
840
- default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
841
-
842
- case options
843
- when Hash
844
- prompt = default_options.merge(options)[type.to_sym]
845
- when String
846
- prompt = options
847
- else
848
- prompt = I18n.translate(('datetime.prompts.' + type.to_s).to_sym, :locale => @options[:locale])
837
+ prompt = case options
838
+ when Hash
839
+ default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
840
+ default_options.merge!(options)[type.to_sym]
841
+ when String
842
+ options
843
+ else
844
+ I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
849
845
  end
850
846
 
851
847
  prompt ? content_tag(:option, prompt, :value => '') : ''
@@ -624,16 +624,16 @@ module ActionView
624
624
  #
625
625
  # ==== Examples
626
626
  # password_field(:login, :pass, :size => 20)
627
- # # => <input type="text" id="login_pass" name="login[pass]" size="20" value="#{@login.pass}" />
627
+ # # => <input type="password" id="login_pass" name="login[pass]" size="20" value="#{@login.pass}" />
628
628
  #
629
629
  # password_field(:account, :secret, :class => "form_input")
630
- # # => <input type="text" id="account_secret" name="account[secret]" value="#{@account.secret}" class="form_input" />
630
+ # # => <input type="password" id="account_secret" name="account[secret]" value="#{@account.secret}" class="form_input" />
631
631
  #
632
632
  # password_field(:user, :password, :onchange => "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }")
633
- # # => <input type="text" id="user_password" name="user[password]" value="#{@user.password}" onchange = "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }"/>
633
+ # # => <input type="password" id="user_password" name="user[password]" value="#{@user.password}" onchange = "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }"/>
634
634
  #
635
635
  # password_field(:account, :pin, :size => 20, :class => 'form_input')
636
- # # => <input type="text" id="account_pin" name="account[pin]" size="20" value="#{@account.pin}" class="form_input" />
636
+ # # => <input type="password" id="account_pin" name="account[pin]" size="20" value="#{@account.pin}" class="form_input" />
637
637
  #
638
638
  def password_field(object_name, method, options = {})
639
639
  InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("password", options)
@@ -1006,9 +1006,14 @@ module ActionView
1006
1006
 
1007
1007
  def value_before_type_cast(object, method_name)
1008
1008
  unless object.nil?
1009
- object.respond_to?(method_name) ?
1010
- object.send(method_name) :
1011
- object.send(method_name + "_before_type_cast")
1009
+ if object.respond_to?(method_name)
1010
+ object.send(method_name)
1011
+ # FIXME: this is AR dependent
1012
+ elsif object.respond_to?(method_name + "_before_type_cast")
1013
+ object.send(method_name + "_before_type_cast")
1014
+ else
1015
+ raise NoMethodError, "Model #{object.class} does not respond to #{method_name}"
1016
+ end
1012
1017
  end
1013
1018
  end
1014
1019
 
@@ -367,8 +367,8 @@ module ActionView
367
367
  # "Go Back" link instead of a link to the comments page, we could do something like this...
368
368
  #
369
369
  # <%=
370
- # link_to_unless_current("Comment", { :controller => 'comments', :action => 'new}) do
371
- # link_to("Go back", { :controller => 'posts', :action => 'index' })
370
+ # link_to_unless_current("Comment", { :controller => "comments", :action => "new" }) do
371
+ # link_to("Go back", { :controller => "posts", :action => "index" })
372
372
  # end
373
373
  # %>
374
374
  def link_to_unless_current(name, options = {}, html_options = {}, &block)
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/array/wrap'
2
2
  require 'active_support/core_ext/object/blank'
3
+ require 'active_support/core_ext/object/try'
3
4
  require 'active_support/core_ext/kernel/singleton_class'
4
5
 
5
6
  module ActionView
@@ -113,12 +114,11 @@ module ActionView
113
114
  @identifier = identifier
114
115
  @handler = handler
115
116
  @original_encoding = nil
116
-
117
- @virtual_path = details[:virtual_path]
118
- @method_names = {}
117
+ @method_names = {}
119
118
 
120
119
  format = details[:format] || :html
121
120
  @formats = Array.wrap(format).map(&:to_sym)
121
+ @virtual_path = details[:virtual_path].try(:sub, ".#{format}", "")
122
122
  end
123
123
 
124
124
  def render(view, locals, &block)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940607
5
- prerelease: true
4
+ hash: 7
5
+ prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
- - rc2
11
- version: 3.0.0.rc2
10
+ version: 3.0.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - David Heinemeier Hansson
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-08-23 00:00:00 -05:00
18
+ date: 2010-08-29 00:00:00 -05:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -27,13 +26,12 @@ dependencies:
27
26
  requirements:
28
27
  - - "="
29
28
  - !ruby/object:Gem::Version
30
- hash: 977940607
29
+ hash: 7
31
30
  segments:
32
31
  - 3
33
32
  - 0
34
33
  - 0
35
- - rc2
36
- version: 3.0.0.rc2
34
+ version: 3.0.0
37
35
  type: :runtime
38
36
  version_requirements: *id001
39
37
  - !ruby/object:Gem::Dependency
@@ -44,13 +42,12 @@ dependencies:
44
42
  requirements:
45
43
  - - "="
46
44
  - !ruby/object:Gem::Version
47
- hash: 977940607
45
+ hash: 7
48
46
  segments:
49
47
  - 3
50
48
  - 0
51
49
  - 0
52
- - rc2
53
- version: 3.0.0.rc2
50
+ version: 3.0.0
54
51
  type: :runtime
55
52
  version_requirements: *id002
56
53
  - !ruby/object:Gem::Dependency
@@ -361,14 +358,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
361
358
  required_rubygems_version: !ruby/object:Gem::Requirement
362
359
  none: false
363
360
  requirements:
364
- - - ">"
361
+ - - ">="
365
362
  - !ruby/object:Gem::Version
366
- hash: 25
363
+ hash: 3
367
364
  segments:
368
- - 1
369
- - 3
370
- - 1
371
- version: 1.3.1
365
+ - 0
366
+ version: "0"
372
367
  requirements:
373
368
  - none
374
369
  rubyforge_project: actionpack