mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make all AP tests pass for Ruby 1.9.1.
This commit is contained in:
parent
f10631e13d
commit
839362fa07
4 changed files with 19 additions and 17 deletions
|
@ -13,18 +13,21 @@ module ActionView
|
|||
mattr_accessor :registered_details
|
||||
self.registered_details = []
|
||||
|
||||
def self.register_detail(name, options = {})
|
||||
def self.register_detail(name, options = {}, &block)
|
||||
self.registered_details << name
|
||||
|
||||
Setters.send :define_method, :"#{name}=" do |value|
|
||||
value = Array(value.presence || yield)
|
||||
value |= [nil] unless options[:allow_nil] == false
|
||||
Setters.send :define_method, :"_#{name}_defaults", &block
|
||||
Setters.module_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{name}=(value)
|
||||
value = Array(value.presence || _#{name}_defaults)
|
||||
#{"value << nil unless value.include?(nil)" unless options[:allow_nil] == false}
|
||||
|
||||
unless value == @details[name]
|
||||
@details_key, @details = nil, @details.merge(name => value)
|
||||
@details.freeze
|
||||
unless value == @details[:#{name}]
|
||||
@details_key, @details = nil, @details.merge(:#{name} => value)
|
||||
@details.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
|
||||
# Holds raw setters for the registered details.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
class TestRoutingMount < ActionDispatch::IntegrationTest
|
||||
SprocketsApp = lambda { |env|
|
||||
[200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]]
|
||||
}
|
||||
|
||||
Router = ActionDispatch::Routing::RouteSet.new
|
||||
Router.draw do
|
||||
SprocketsApp = lambda { |env|
|
||||
[200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]]
|
||||
}
|
||||
|
||||
mount SprocketsApp, :at => "/sprockets"
|
||||
mount SprocketsApp => "/shorthand"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module ActionView #:nodoc:
|
|||
def query(partial, path, exts)
|
||||
query = Regexp.escape(path)
|
||||
exts.each do |ext|
|
||||
query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')'
|
||||
query << '(' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')'
|
||||
end
|
||||
|
||||
templates = []
|
||||
|
@ -21,7 +21,8 @@ module ActionView #:nodoc:
|
|||
templates << Template.new(source, path, handler,
|
||||
:partial => partial, :virtual_path => path, :format => format)
|
||||
end
|
||||
templates.sort_by {|t| -t.formats.size }
|
||||
|
||||
templates.sort_by {|t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -33,9 +33,7 @@ class LookupContextTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "does not allow details to be modified in place" do
|
||||
assert_raise TypeError do
|
||||
@lookup_context.details.clear
|
||||
end
|
||||
assert @lookup_context.details.frozen?
|
||||
end
|
||||
|
||||
test "allows me to update an specific detail" do
|
||||
|
|
Loading…
Reference in a new issue