Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update rails

  • Loading branch information...
commit 1e18650d32d2196e6d8e328858e822fd23a2812e 1 parent cb34329
@binarylogic authored
Showing with 960 additions and 635 deletions.
  1. 0  vendor/rails/REVISION_ea8077c6427d208188f9cd11f88ebdc8f60dec28
  2. +81 −0 vendor/rails/Rakefile
  3. +6 −6 vendor/rails/actionpack/lib/action_controller/base.rb
  4. +4 −6 vendor/rails/actionpack/lib/action_controller/integration.rb
  5. +11 −30 vendor/rails/actionpack/lib/action_controller/response.rb
  6. +2 −4 vendor/rails/actionpack/lib/action_controller/test_process.rb
  7. +0 −6 vendor/rails/actionpack/lib/action_view/base.rb
  8. +0 −8 vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb
  9. +14 −21 vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
  10. +3 −3 vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb
  11. +1 −1  vendor/rails/actionpack/lib/action_view/paths.rb
  12. +33 −22 vendor/rails/actionpack/lib/action_view/template.rb
  13. +1 −1  vendor/rails/actionpack/test/controller/rack_test.rb
  14. +230 −218 vendor/rails/actionpack/test/controller/request_test.rb
  15. +2 −2 vendor/rails/actionpack/test/controller/send_file_test.rb
  16. +21 −0 vendor/rails/actionpack/test/controller/session/cookie_store_test.rb
  17. +0 −12 vendor/rails/actionpack/test/controller/test_test.rb
  18. +0 −22 vendor/rails/actionpack/test/template/body_parts_test.rb
  19. +0 −35 vendor/rails/actionpack/test/template/output_buffer_test.rb
  20. +0 −32 vendor/rails/actionpack/test/template/template_test.rb
  21. +10 −13 vendor/rails/activerecord/lib/active_record/base.rb
  22. +7 −7 vendor/rails/activeresource/README
  23. +10 −10 vendor/rails/activeresource/lib/active_resource/base.rb
  24. +11 −11 vendor/rails/activeresource/lib/active_resource/connection.rb
  25. +8 −9 vendor/rails/activeresource/lib/active_resource/validations.rb
  26. +0 −5 vendor/rails/activesupport/CHANGELOG
  27. +11 −3 vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
  28. +0 −12 vendor/rails/activesupport/test/core_ext/duration_test.rb
  29. +16 −57 vendor/rails/activesupport/test/core_ext/time_ext_test.rb
  30. +14 −0 vendor/rails/pushgems.rb
  31. +0 −2  vendor/rails/railties/CHANGELOG
  32. +0 −1  vendor/rails/railties/Rakefile
  33. BIN  vendor/rails/railties/guides/images/fxn.jpg
  34. +0 −1  vendor/rails/railties/guides/rails_guides.rb
  35. +0 −34 vendor/rails/railties/guides/rails_guides/generator.rb
  36. +0 −29 vendor/rails/railties/guides/rails_guides/levenshtein.rb
  37. +1 −0  vendor/rails/railties/guides/source/active_record_querying.textile
  38. +1 −1  vendor/rails/railties/guides/source/form_helpers.textile
  39. +1 −1  vendor/rails/railties/guides/source/layouts_and_rendering.textile
  40. +436 −10 vendor/rails/railties/lib/commands/plugin.rb
  41. +25 −0 vendor/rails/release.rb
View
0  vendor/rails/REVISION_ea8077c6427d208188f9cd11f88ebdc8f60dec28
No changes.
View
81 vendor/rails/Rakefile
@@ -0,0 +1,81 @@
+require 'rake'
+require 'rake/rdoctask'
+require 'rake/contrib/sshpublisher'
+
+env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']
+
+PROJECTS = %w(activesupport actionpack actionmailer activeresource activerecord railties)
+
+Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
+ require version_path
+end
+
+desc 'Run all tests by default'
+task :default => :test
+
+%w(test rdoc pgem package release).each do |task_name|
+ desc "Run #{task_name} task for all projects"
+ task task_name do
+ PROJECTS.each do |project|
+ system %(cd #{project} && #{env} #{$0} #{task_name})
+ end
+ end
+end
+
+
+desc "Generate documentation for the Rails framework"
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'doc/rdoc'
+ rdoc.title = "Ruby on Rails Documentation"
+
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.options << '-A cattr_accessor=object'
+ rdoc.options << '--charset' << 'utf-8'
+
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : './doc/template/horo'
+
+ rdoc.rdoc_files.include('railties/CHANGELOG')
+ rdoc.rdoc_files.include('railties/MIT-LICENSE')
+ rdoc.rdoc_files.include('railties/README')
+ rdoc.rdoc_files.include('railties/lib/{*.rb,commands/*.rb,rails/*.rb,rails_generator/*.rb}')
+
+ rdoc.rdoc_files.include('activerecord/README')
+ rdoc.rdoc_files.include('activerecord/CHANGELOG')
+ rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
+ rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')
+
+ rdoc.rdoc_files.include('activeresource/README')
+ rdoc.rdoc_files.include('activeresource/CHANGELOG')
+ rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
+ rdoc.rdoc_files.include('activeresource/lib/active_resource/*')
+
+ rdoc.rdoc_files.include('actionpack/README')
+ rdoc.rdoc_files.include('actionpack/CHANGELOG')
+ rdoc.rdoc_files.include('actionpack/lib/action_controller/**/*.rb')
+ rdoc.rdoc_files.include('actionpack/lib/action_view/**/*.rb')
+ rdoc.rdoc_files.exclude('actionpack/lib/action_controller/vendor/*')
+
+ rdoc.rdoc_files.include('actionmailer/README')
+ rdoc.rdoc_files.include('actionmailer/CHANGELOG')
+ rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
+ rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')
+
+ rdoc.rdoc_files.include('activesupport/README')
+ rdoc.rdoc_files.include('activesupport/CHANGELOG')
+ rdoc.rdoc_files.include('activesupport/lib/active_support/**/*.rb')
+ rdoc.rdoc_files.exclude('activesupport/lib/active_support/vendor/*')
+end
+
+# Enhance rdoc task to copy referenced images also
+task :rdoc do
+ FileUtils.mkdir_p "doc/rdoc/files/examples/"
+ FileUtils.copy "activerecord/examples/associations.png", "doc/rdoc/files/examples/associations.png"
+end
+
+desc "Publish API docs for Rails as a whole and for each component"
+task :pdoc => :rdoc do
+ Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/api", "doc/rdoc").upload
+ PROJECTS.each do |project|
+ system %(cd #{project} && #{env} #{$0} pdoc)
+ end
+end
View
12 vendor/rails/actionpack/lib/action_controller/base.rb
@@ -984,7 +984,6 @@ def render(options = nil, extra_options = {}, &block) #:doc:
# of sending it as the response body to the browser.
def render_to_string(options = nil, &block) #:doc:
render(options, &block)
- response.body
ensure
response.content_type = nil
erase_render_results
@@ -1021,7 +1020,7 @@ def head(*args)
# Clears the rendered results, allowing for another render to be performed.
def erase_render_results #:nodoc:
- response.body = []
+ response.body = nil
@performed_render = false
end
@@ -1248,12 +1247,13 @@ def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
response.status = interpret_status(status || DEFAULT_RENDER_STATUS_CODE)
if append_response
- response.body_parts << text.to_s
+ response.body ||= ''
+ response.body << text.to_s
else
response.body = case text
- when Proc then text
- when nil then [" "] # Safari doesn't pass the headers of the return if the response is zero length
- else [text.to_s]
+ when Proc then text
+ when nil then " " # Safari doesn't pass the headers of the return if the response is zero length
+ else text.to_s
end
end
end
View
10 vendor/rails/actionpack/lib/action_controller/integration.rb
@@ -332,13 +332,11 @@ def process(method, path, parameters = nil, headers = nil)
@cookies[name] = value
end
+ @body = ""
if body.is_a?(String)
- @body_parts = [body]
- @body = body
+ @body << body
else
- @body_parts = []
- body.each { |part| @body_parts << part.to_s }
- @body = @body_parts.join
+ body.each { |part| @body << part }
end
if @controller = ActionController::Base.last_instantiation
@@ -351,7 +349,7 @@ def process(method, path, parameters = nil, headers = nil)
@response = Response.new
@response.status = status.to_s
@response.headers.replace(@headers)
- @response.body = @body_parts
+ @response.body = @body
end
# Decorate the response with the standard behavior of the
View
41 vendor/rails/actionpack/lib/action_controller/response.rb
@@ -40,28 +40,14 @@ class Response < Rack::Response
delegate :default_charset, :to => 'ActionController::Base'
def initialize
- super
+ @status = 200
@header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS)
- @session, @assigns = [], []
- end
- def body
- str = ''
- each { |part| str << part.to_s }
- str
- end
+ @writer = lambda { |x| @body << x }
+ @block = nil
- def body=(body)
- @body =
- if body.is_a?(String)
- [body]
- else
- body
- end
- end
-
- def body_parts
- @body
+ @body = "",
+ @session, @assigns = [], []
end
def location; headers['Location'] end
@@ -166,7 +152,7 @@ def each(&callback)
@writer = lambda { |x| callback.call(x) }
@body.call(self, self)
elsif @body.is_a?(String)
- callback.call(@body)
+ @body.each_line(&callback)
else
@body.each(&callback)
end
@@ -176,8 +162,7 @@ def each(&callback)
end
def write(str)
- str = str.to_s
- @writer.call str
+ @writer.call str.to_s
str
end
@@ -201,7 +186,7 @@ def handle_conditional_get!
if request && request.etag_matches?(etag)
self.status = '304 Not Modified'
- self.body = []
+ self.body = ''
end
set_conditional_cache_control!
@@ -210,11 +195,7 @@ def handle_conditional_get!
def nonempty_ok_response?
ok = !status || status.to_s[0..2] == '200'
- ok && string_body?
- end
-
- def string_body?
- !body_parts.respond_to?(:call) && body_parts.any? && body_parts.all? { |part| part.is_a?(String) }
+ ok && body.is_a?(String) && !body.empty?
end
def set_conditional_cache_control!
@@ -235,8 +216,8 @@ def set_content_length!
headers.delete('Content-Length')
elsif length = headers['Content-Length']
headers['Content-Length'] = length.to_s
- elsif string_body? && (!status || status.to_s[0..2] != '304')
- headers["Content-Length"] = Rack::Utils.bytesize(body).to_s
+ elsif !body.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
+ headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
end
end
View
6 vendor/rails/actionpack/lib/action_controller/test_process.rb
@@ -13,7 +13,6 @@ def initialize(env = {})
@query_parameters = {}
@session = TestSession.new
- @session_options ||= {}
initialize_default_values
initialize_containers
@@ -111,7 +110,6 @@ def assign_parameters(controller_path, action, parameters)
end
def recycle!
- @env["action_controller.request.request_parameters"] = {}
self.query_parameters = {}
self.path_parameters = {}
@headers, @request_method, @accepts, @content_type = nil, nil, nil, nil
@@ -260,11 +258,11 @@ def cookies
# Returns binary content (downloadable file), converted to a String
def binary_content
- raise "Response body is not a Proc: #{body_parts.inspect}" unless body_parts.kind_of?(Proc)
+ raise "Response body is not a Proc: #{body.inspect}" unless body.kind_of?(Proc)
require 'stringio'
sio = StringIO.new
- body_parts.call(self, sio)
+ body.call(self, sio)
sio.rewind
sio.read
View
6 vendor/rails/actionpack/lib/action_view/base.rb
@@ -303,12 +303,6 @@ def with_template(current_template)
self.template = last_template
end
- def punctuate_body!(part)
- flush_output_buffer
- response.body_parts << part
- nil
- end
-
private
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
View
8 vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -131,14 +131,6 @@ def with_output_buffer(buf = '') #:nodoc:
ensure
self.output_buffer = old_buffer
end
-
- # Add the output buffer to the response body and start a new one.
- def flush_output_buffer #:nodoc:
- if output_buffer && output_buffer != ''
- response.body_parts << output_buffer
- self.output_buffer = ''
- end
- end
end
end
end
View
35 vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
@@ -628,7 +628,7 @@ def text_area(object_name, method, options = {})
#
# The HTML specification says unchecked check boxes are not successful, and
# thus web browsers do not send them. Unfortunately this introduces a gotcha:
- # if an +Invoice+ model has a +paid+ flag, and in the form that edits a paid
+ # if an Invoice model has a +paid+ flag, and in the form that edits a paid
# invoice the user unchecks its check box, no +paid+ parameter is sent. So,
# any mass-assignment idiom like
#
@@ -636,15 +636,12 @@ def text_area(object_name, method, options = {})
#
# wouldn't update the flag.
#
- # To prevent this the helper generates an auxiliary hidden field before
- # the very check box. The hidden field has the same name and its
- # attributes mimick an unchecked check box.
- #
- # This way, the client either sends only the hidden field (representing
- # the check box is unchecked), or both fields. Since the HTML specification
- # says key/value pairs have to be sent in the same order they appear in the
- # form, and parameters extraction gets the last occurrence of any repeated
- # key in the query string, that works for ordinary forms.
+ # To prevent this the helper generates a hidden field with the same name as
+ # the checkbox after the very check box. So, the client either sends only the
+ # hidden field (representing the check box is unchecked), or both fields.
+ # Since the HTML specification says key/value pairs have to be sent in the
+ # same order they appear in the form and Rails parameters extraction always
+ # gets the first occurrence of any given key, that works in ordinary forms.
#
# Unfortunately that workaround does not work when the check box goes
# within an array-like parameter, as in
@@ -655,26 +652,22 @@ def text_area(object_name, method, options = {})
# <% end %>
#
# because parameter name repetition is precisely what Rails seeks to distinguish
- # the elements of the array. For each item with a checked check box you
- # get an extra ghost item with only that attribute, assigned to "0".
- #
- # In that case it is preferable to either use +check_box_tag+ or to use
- # hashes instead of arrays.
+ # the elements of the array.
#
# ==== Examples
# # Let's say that @post.validated? is 1:
# check_box("post", "validated")
- # # => <input name="post[validated]" type="hidden" value="0" />
- # # <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
+ # # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
+ # # <input name="post[validated]" type="hidden" value="0" />
#
# # Let's say that @puppy.gooddog is "no":
# check_box("puppy", "gooddog", {}, "yes", "no")
- # # => <input name="puppy[gooddog]" type="hidden" value="no" />
- # # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
+ # # => <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
+ # # <input name="puppy[gooddog]" type="hidden" value="no" />
#
# check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
- # # => <input name="eula[accepted]" type="hidden" value="no" />
- # # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
+ # # => <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
+ # # <input name="eula[accepted]" type="hidden" value="no" />
#
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
InstanceTag.new(object_name, method, self, options.delete(:object)).to_check_box_tag(options, checked_value, unchecked_value)
View
6 vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb
@@ -324,7 +324,7 @@ def simple_format(text, html_options={})
# Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option
# will limit what should be linked. You can add HTML attributes to the links using
- # <tt>:html</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
+ # <tt>:href_options</tt>. Possible values for <tt>:link</tt> are <tt>:all</tt> (default),
# <tt>:email_addresses</tt>, and <tt>:urls</tt>. If a block is given, each URL and
# e-mail address is yielded and the result is used as the link text.
#
@@ -341,7 +341,7 @@ def simple_format(text, html_options={})
# # => "Visit http://www.loudthinking.com/ or e-mail <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
#
# post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
- # auto_link(post_body, :html => { :target => '_blank' }) do |text|
+ # auto_link(post_body, :href_options => { :target => '_blank' }) do |text|
# truncate(text, 15)
# end
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>.
@@ -359,7 +359,7 @@ def simple_format(text, html_options={})
# auto_link(post_body, :all, :target => "_blank") # => Once upon\na time
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
# Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
- def auto_link(text, *args, &block)#link = :all, html = {}, &block)
+ def auto_link(text, *args, &block)#link = :all, href_options = {}, &block)
return '' if text.blank?
options = args.size == 2 ? {} : args.extract_options! # this is necessary because the old auto_link API has a Hash as its last parameter
View
2  vendor/rails/actionpack/lib/action_view/paths.rb
@@ -61,7 +61,7 @@ def find_template(original_template_path, format = nil, html_fallback = true)
end
end
- return Template.new(original_template_path) if File.file?(original_template_path)
+ return Template.new(original_template_path, original_template_path.to_s =~ /\A\// ? "" : ".") if File.file?(original_template_path)
raise MissingTemplate.new(self, original_template_path, format)
end
View
55 vendor/rails/actionpack/lib/action_view/template.rb
@@ -107,8 +107,9 @@ def self.exempt_from_layout(*extensions)
attr_accessor :locale, :name, :format, :extension
delegate :to_s, :to => :path
- def initialize(template_path, load_path = nil)
- @template_path, @load_path = template_path.dup, load_path
+ def initialize(template_path, load_path)
+ @template_path = template_path.dup
+ @load_path, @filename = load_path, File.join(load_path, template_path)
@base_path, @name, @locale, @format, @extension = split(template_path)
@base_path.to_s.gsub!(/\/$/, '') # Push to split method
@@ -179,12 +180,6 @@ def exempt_from_layout?
@@exempt_from_layout.any? { |exempted| path =~ exempted }
end
- def filename
- # no load_path means this is an "absolute pathed" template
- load_path ? File.join(load_path, template_path) : template_path
- end
- memoize :filename
-
def source
File.read(filename)
end
@@ -217,30 +212,46 @@ def valid_extension?(extension)
end
def valid_locale?(locale)
- locale && I18n.available_locales.include?(locale.to_sym)
+ I18n.available_locales.include?(locale.to_sym)
end
# Returns file split into an array
# [base_path, name, locale, format, extension]
def split(file)
if m = file.to_s.match(/^(.*\/)?([^\.]+)\.(.*)$/)
- [m[1], m[2], *parse_extensions(m[3])]
+ base_path = m[1]
+ name = m[2]
+ extensions = m[3]
+ else
+ return
end
- end
-
- # returns parsed extensions as an array
- # [locale, format, extension]
- def parse_extensions(extensions)
- exts = extensions.split(".")
- if extension = valid_extension?(exts.last) && exts.pop || nil
- locale = valid_locale?(exts.first) && exts.shift || nil
- format = exts.join('.') if exts.any? # join('.') is needed for multipart templates
- else # no extension, just format
- format = exts.last
+ locale = nil
+ format = nil
+ extension = nil
+
+ if m = extensions.split(".")
+ if valid_locale?(m[0]) && m[1] && valid_extension?(m[2]) # All three
+ locale = m[0]
+ format = m[1]
+ extension = m[2]
+ elsif m[0] && m[1] && valid_extension?(m[2]) # Multipart formats
+ format = "#{m[0]}.#{m[1]}"
+ extension = m[2]
+ elsif valid_locale?(m[0]) && valid_extension?(m[1]) # locale and extension
+ locale = m[0]
+ extension = m[1]
+ elsif valid_extension?(m[1]) # format and extension
+ format = m[0]
+ extension = m[1]
+ elsif valid_extension?(m[0]) # Just extension
+ extension = m[0]
+ else # No extension
+ format = m[0]
+ end
end
- [locale, format, extension]
+ [base_path, name, locale, format, extension]
end
end
end
View
2  vendor/rails/actionpack/test/controller/rack_test.rb
@@ -258,7 +258,7 @@ def test_streaming_block
}, headers)
parts = []
- body.each { |part| parts << part.to_s }
+ body.each { |part| parts << part }
assert_equal ["0", "1", "2", "3", "4"], parts
end
end
View
448 vendor/rails/actionpack/test/controller/request_test.rb
@@ -3,6 +3,7 @@
class RequestTest < ActiveSupport::TestCase
def setup
ActionController::Base.relative_url_root = nil
+ @request = ActionController::TestRequest.new
end
def teardown
@@ -10,52 +11,60 @@ def teardown
end
def test_remote_ip
- request = stub_request 'REMOTE_ADDR' => '1.2.3.4'
- assert_equal '1.2.3.4', request.remote_ip
+ assert_equal '0.0.0.0', @request.remote_ip
- request = stub_request 'REMOTE_ADDR' => '1.2.3.4,3.4.5.6'
- assert_equal '1.2.3.4', request.remote_ip
+ @request.remote_addr = '1.2.3.4'
+ assert_equal '1.2.3.4', @request.remote_ip
- request = stub_request 'REMOTE_ADDR' => '1.2.3.4',
- 'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
- assert_equal '1.2.3.4', request.remote_ip
+ @request.remote_addr = '1.2.3.4,3.4.5.6'
+ assert_equal '1.2.3.4', @request.remote_ip
- request = stub_request 'REMOTE_ADDR' => '127.0.0.1',
- 'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.env['HTTP_CLIENT_IP'] = '2.3.4.5'
+ assert_equal '1.2.3.4', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => 'unknown,3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.remote_addr = '192.168.0.1'
+ assert_equal '2.3.4.5', @request.remote_ip
+ @request.env.delete 'HTTP_CLIENT_IP'
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '172.16.0.1,3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.remote_addr = '1.2.3.4'
+ @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6'
+ assert_equal '1.2.3.4', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '192.168.0.1,3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.remote_addr = '127.0.0.1'
+ @request.env['HTTP_X_FORWARDED_FOR'] = '3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '10.0.0.1,3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '10.0.0.1, 10.0.0.1, 3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = '172.16.0.1,3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '127.0.0.1,3.4.5.6'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = '192.168.0.1,3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => 'unknown,192.168.0.1'
- assert_equal 'unknown', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1,3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4'
- assert_equal '3.4.5.6', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = '10.0.0.1, 10.0.0.1, 3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '1.1.1.1',
- 'HTTP_CLIENT_IP' => '2.2.2.2'
+ @request.env['HTTP_X_FORWARDED_FOR'] = '127.0.0.1,3.4.5.6'
+ assert_equal '3.4.5.6', @request.remote_ip
+
+ @request.env['HTTP_X_FORWARDED_FOR'] = 'unknown,192.168.0.1'
+ assert_equal 'unknown', @request.remote_ip
+
+ @request.env['HTTP_X_FORWARDED_FOR'] = '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4'
+ assert_equal '3.4.5.6', @request.remote_ip
+
+ @request.env['HTTP_CLIENT_IP'] = '8.8.8.8'
e = assert_raise(ActionController::ActionControllerError) {
- request.remote_ip
+ @request.remote_ip
}
assert_match /IP spoofing attack/, e.message
- assert_match /HTTP_X_FORWARDED_FOR="1.1.1.1"/, e.message
- assert_match /HTTP_CLIENT_IP="2.2.2.2"/, e.message
+ assert_match /HTTP_X_FORWARDED_FOR="9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4"/, e.message
+ assert_match /HTTP_CLIENT_IP="8.8.8.8"/, e.message
# turn IP Spoofing detection off.
# This is useful for sites that are aimed at non-IP clients. The typical
@@ -63,333 +72,336 @@ def test_remote_ip
# leap of faith to assume that their proxies are ever going to set the
# HTTP_CLIENT_IP/HTTP_X_FORWARDED_FOR headers properly.
ActionController::Base.ip_spoofing_check = false
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '1.1.1.1',
- 'HTTP_CLIENT_IP' => '2.2.2.2'
- assert_equal '2.2.2.2', request.remote_ip
+ assert_equal('8.8.8.8', @request.remote_ip)
ActionController::Base.ip_spoofing_check = true
- request = stub_request 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, 9.9.9.9'
- assert_equal '9.9.9.9', request.remote_ip
+ @request.env['HTTP_X_FORWARDED_FOR'] = '8.8.8.8, 9.9.9.9'
+ assert_equal '8.8.8.8', @request.remote_ip
+
+ @request.env.delete 'HTTP_CLIENT_IP'
+ @request.env.delete 'HTTP_X_FORWARDED_FOR'
end
def test_domains
- request = stub_request 'HTTP_HOST' => 'www.rubyonrails.org'
- assert_equal "rubyonrails.org", request.domain
+ @request.host = "www.rubyonrails.org"
+ assert_equal "rubyonrails.org", @request.domain
+
+ @request.host = "www.rubyonrails.co.uk"
+ assert_equal "rubyonrails.co.uk", @request.domain(2)
- request = stub_request 'HTTP_HOST' => "www.rubyonrails.co.uk"
- assert_equal "rubyonrails.co.uk", request.domain(2)
+ @request.host = "192.168.1.200"
+ assert_nil @request.domain
- request = stub_request 'HTTP_HOST' => "192.168.1.200"
- assert_nil request.domain
+ @request.host = "foo.192.168.1.200"
+ assert_nil @request.domain
- request = stub_request 'HTTP_HOST' => "foo.192.168.1.200"
- assert_nil request.domain
+ @request.host = "192.168.1.200.com"
+ assert_equal "200.com", @request.domain
- request = stub_request 'HTTP_HOST' => "192.168.1.200.com"
- assert_equal "200.com", request.domain
+ @request.host = nil
+ assert_nil @request.domain
end
def test_subdomains
- request = stub_request 'HTTP_HOST' => "www.rubyonrails.org"
- assert_equal %w( www ), request.subdomains
+ @request.host = "www.rubyonrails.org"
+ assert_equal %w( www ), @request.subdomains
- request = stub_request 'HTTP_HOST' => "www.rubyonrails.co.uk"
- assert_equal %w( www ), request.subdomains(2)
+ @request.host = "www.rubyonrails.co.uk"
+ assert_equal %w( www ), @request.subdomains(2)
- request = stub_request 'HTTP_HOST' => "dev.www.rubyonrails.co.uk"
- assert_equal %w( dev www ), request.subdomains(2)
+ @request.host = "dev.www.rubyonrails.co.uk"
+ assert_equal %w( dev www ), @request.subdomains(2)
- request = stub_request 'HTTP_HOST' => "foobar.foobar.com"
- assert_equal %w( foobar ), request.subdomains
+ @request.host = "foobar.foobar.com"
+ assert_equal %w( foobar ), @request.subdomains
- request = stub_request 'HTTP_HOST' => "192.168.1.200"
- assert_equal [], request.subdomains
+ @request.host = "192.168.1.200"
+ assert_equal [], @request.subdomains
- request = stub_request 'HTTP_HOST' => "foo.192.168.1.200"
- assert_equal [], request.subdomains
+ @request.host = "foo.192.168.1.200"
+ assert_equal [], @request.subdomains
- request = stub_request 'HTTP_HOST' => "192.168.1.200.com"
- assert_equal %w( 192 168 1 ), request.subdomains
+ @request.host = "192.168.1.200.com"
+ assert_equal %w( 192 168 1 ), @request.subdomains
- request = stub_request 'HTTP_HOST' => nil
- assert_equal [], request.subdomains
+ @request.host = nil
+ assert_equal [], @request.subdomains
end
def test_port_string
- request = stub_request 'HTTP_HOST' => 'www.example.org:80'
- assert_equal "", request.port_string
+ @request.port = 80
+ assert_equal "", @request.port_string
- request = stub_request 'HTTP_HOST' => 'www.example.org:8080'
- assert_equal ":8080", request.port_string
+ @request.port = 8080
+ assert_equal ":8080", @request.port_string
end
def test_request_uri
- request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri?mapped=1"
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ @request.env['SERVER_SOFTWARE'] = 'Apache 42.342.3432'
- request = stub_request 'REQUEST_URI' => "http://www.rubyonrails.org/path/of/some/uri"
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri?mapped=1"
+ assert_equal "/path/of/some/uri?mapped=1", @request.request_uri
+ assert_equal "/path/of/some/uri", @request.path
- request = stub_request 'REQUEST_URI' => "/path/of/some/uri"
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri"
+ assert_equal "/path/of/some/uri", @request.request_uri
+ assert_equal "/path/of/some/uri", @request.path
- request = stub_request 'REQUEST_URI' => "/"
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
+ @request.set_REQUEST_URI "/path/of/some/uri"
+ assert_equal "/path/of/some/uri", @request.request_uri
+ assert_equal "/path/of/some/uri", @request.path
- request = stub_request 'REQUEST_URI' => "/?m=b"
- assert_equal "/?m=b", request.request_uri
- assert_equal "/", request.path
+ @request.set_REQUEST_URI "/"
+ assert_equal "/", @request.request_uri
+ assert_equal "/", @request.path
- request = stub_request 'REQUEST_URI' => "/", 'SCRIPT_NAME' => '/dispatch.cgi'
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
+ @request.set_REQUEST_URI "/?m=b"
+ assert_equal "/?m=b", @request.request_uri
+ assert_equal "/", @request.path
+
+ @request.set_REQUEST_URI "/"
+ @request.env['SCRIPT_NAME'] = "/dispatch.cgi"
+ assert_equal "/", @request.request_uri
+ assert_equal "/", @request.path
ActionController::Base.relative_url_root = "/hieraki"
- request = stub_request 'REQUEST_URI' => "/hieraki/", 'SCRIPT_NAME' => "/hieraki/dispatch.cgi"
- assert_equal "/hieraki/", request.request_uri
- assert_equal "/", request.path
+ @request.set_REQUEST_URI "/hieraki/"
+ @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi"
+ assert_equal "/hieraki/", @request.request_uri
+ assert_equal "/", @request.path
ActionController::Base.relative_url_root = nil
ActionController::Base.relative_url_root = "/collaboration/hieraki"
- request = stub_request 'REQUEST_URI' => "/collaboration/hieraki/books/edit/2",
- 'SCRIPT_NAME' => "/collaboration/hieraki/dispatch.cgi"
- assert_equal "/collaboration/hieraki/books/edit/2", request.request_uri
- assert_equal "/books/edit/2", request.path
+ @request.set_REQUEST_URI "/collaboration/hieraki/books/edit/2"
+ @request.env['SCRIPT_NAME'] = "/collaboration/hieraki/dispatch.cgi"
+ assert_equal "/collaboration/hieraki/books/edit/2", @request.request_uri
+ assert_equal "/books/edit/2", @request.path
ActionController::Base.relative_url_root = nil
# The following tests are for when REQUEST_URI is not supplied (as in IIS)
- request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1",
- 'SCRIPT_NAME' => nil,
- 'REQUEST_URI' => nil
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ @request.env['PATH_INFO'] = "/path/of/some/uri?mapped=1"
+ @request.env['SCRIPT_NAME'] = nil #"/path/dispatch.rb"
+ @request.set_REQUEST_URI nil
+ assert_equal "/path/of/some/uri?mapped=1", @request.request_uri
+ assert_equal "/path/of/some/uri", @request.path
ActionController::Base.relative_url_root = '/path'
- request = stub_request 'PATH_INFO' => "/path/of/some/uri?mapped=1",
- 'SCRIPT_NAME' => "/path/dispatch.rb",
- 'REQUEST_URI' => nil
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/of/some/uri", request.path
+ @request.env['PATH_INFO'] = "/path/of/some/uri?mapped=1"
+ @request.env['SCRIPT_NAME'] = "/path/dispatch.rb"
+ @request.set_REQUEST_URI nil
+ assert_equal "/path/of/some/uri?mapped=1", @request.request_uri
+ assert_equal "/of/some/uri", @request.path
ActionController::Base.relative_url_root = nil
- request = stub_request 'PATH_INFO' => "/path/of/some/uri",
- 'SCRIPT_NAME' => nil,
- 'REQUEST_URI' => nil
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ @request.env['PATH_INFO'] = "/path/of/some/uri"
+ @request.env['SCRIPT_NAME'] = nil
+ @request.set_REQUEST_URI nil
+ assert_equal "/path/of/some/uri", @request.request_uri
+ assert_equal "/path/of/some/uri", @request.path
- request = stub_request 'PATH_INFO' => '/', 'REQUEST_URI' => nil
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
+ @request.env['PATH_INFO'] = "/"
+ @request.set_REQUEST_URI nil
+ assert_equal "/", @request.request_uri
+ assert_equal "/", @request.path
- request = stub_request 'PATH_INFO' => '/?m=b', 'REQUEST_URI' => nil
- assert_equal "/?m=b", request.request_uri
- assert_equal "/", request.path
+ @request.env['PATH_INFO'] = "/?m=b"
+ @request.set_REQUEST_URI nil
+ assert_equal "/?m=b", @request.request_uri
+ assert_equal "/", @request.path
- request = stub_request 'PATH_INFO' => "/",
- 'SCRIPT_NAME' => "/dispatch.cgi",
- 'REQUEST_URI' => nil
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
+ @request.env['PATH_INFO'] = "/"
+ @request.env['SCRIPT_NAME'] = "/dispatch.cgi"
+ @request.set_REQUEST_URI nil
+ assert_equal "/", @request.request_uri
+ assert_equal "/", @request.path
ActionController::Base.relative_url_root = '/hieraki'
- request = stub_request 'PATH_INFO' => "/hieraki/",
- 'SCRIPT_NAME' => "/hieraki/dispatch.cgi",
- 'REQUEST_URI' => nil
- assert_equal "/hieraki/", request.request_uri
- assert_equal "/", request.path
+ @request.env['PATH_INFO'] = "/hieraki/"
+ @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi"
+ @request.set_REQUEST_URI nil
+ assert_equal "/hieraki/", @request.request_uri
+ assert_equal "/", @request.path
ActionController::Base.relative_url_root = nil
- request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi'
+ @request.set_REQUEST_URI '/hieraki/dispatch.cgi'
ActionController::Base.relative_url_root = '/hieraki'
- assert_equal "/dispatch.cgi", request.path
+ assert_equal "/dispatch.cgi", @request.path
ActionController::Base.relative_url_root = nil
- request = stub_request 'REQUEST_URI' => '/hieraki/dispatch.cgi'
+ @request.set_REQUEST_URI '/hieraki/dispatch.cgi'
ActionController::Base.relative_url_root = '/foo'
- assert_equal "/hieraki/dispatch.cgi", request.path
+ assert_equal "/hieraki/dispatch.cgi", @request.path
ActionController::Base.relative_url_root = nil
# This test ensures that Rails uses REQUEST_URI over PATH_INFO
ActionController::Base.relative_url_root = nil
- request = stub_request 'REQUEST_URI' => "/some/path",
- 'PATH_INFO' => "/another/path",
- 'SCRIPT_NAME' => "/dispatch.cgi"
- assert_equal "/some/path", request.request_uri
- assert_equal "/some/path", request.path
+ @request.env['REQUEST_URI'] = "/some/path"
+ @request.env['PATH_INFO'] = "/another/path"
+ @request.env['SCRIPT_NAME'] = "/dispatch.cgi"
+ assert_equal "/some/path", @request.request_uri
+ assert_equal "/some/path", @request.path
end
def test_host_with_default_port
- request = stub_request 'HTTP_HOST' => 'rubyonrails.org:80'
- assert_equal "rubyonrails.org", request.host_with_port
+ @request.host = "rubyonrails.org"
+ @request.port = 80
+ assert_equal "rubyonrails.org", @request.host_with_port
end
def test_host_with_non_default_port
- request = stub_request 'HTTP_HOST' => 'rubyonrails.org:81'
- assert_equal "rubyonrails.org:81", request.host_with_port
+ @request.host = "rubyonrails.org"
+ @request.port = 81
+ assert_equal "rubyonrails.org:81", @request.host_with_port
end
def test_server_software
- request = stub_request
- assert_equal nil, request.server_software
+ assert_equal nil, @request.server_software
- request = stub_request 'SERVER_SOFTWARE' => 'Apache3.422'
- assert_equal 'apache', request.server_software
+ @request.env['SERVER_SOFTWARE'] = 'Apache3.422'
+ assert_equal 'apache', @request.server_software
- request = stub_request 'SERVER_SOFTWARE' => 'lighttpd(1.1.4)'
- assert_equal 'lighttpd', request.server_software
+ @request.env['SERVER_SOFTWARE'] = 'lighttpd(1.1.4)'
+ assert_equal 'lighttpd', @request.server_software
end
def test_xml_http_request
- request = stub_request
-
- assert !request.xml_http_request?
- assert !request.xhr?
+ assert !@request.xml_http_request?
+ assert !@request.xhr?
- request = stub_request 'HTTP_X_REQUESTED_WITH' => 'DefinitelyNotAjax1.0'
- assert !request.xml_http_request?
- assert !request.xhr?
+ @request.env['HTTP_X_REQUESTED_WITH'] = "DefinitelyNotAjax1.0"
+ assert !@request.xml_http_request?
+ assert !@request.xhr?
- request = stub_request 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'
- assert request.xml_http_request?
- assert request.xhr?
+ @request.env['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"
+ assert @request.xml_http_request?
+ assert @request.xhr?
end
def test_reports_ssl
- request = stub_request
- assert !request.ssl?
-
- request = stub_request 'HTTPS' => 'on'
- assert request.ssl?
+ assert !@request.ssl?
+ @request.env['HTTPS'] = 'on'
+ assert @request.ssl?
end
def test_reports_ssl_when_proxied_via_lighttpd
- request = stub_request
- assert !request.ssl?
-
- request = stub_request 'HTTP_X_FORWARDED_PROTO' => 'https'
- assert request.ssl?
+ assert !@request.ssl?
+ @request.env['HTTP_X_FORWARDED_PROTO'] = 'https'
+ assert @request.ssl?
end
def test_symbolized_request_methods
[:get, :post, :put, :delete].each do |method|
- request = stub_request 'REQUEST_METHOD' => method.to_s.upcase
- assert_equal method, request.method
+ self.request_method = method
+ assert_equal method, @request.method
end
end
def test_invalid_http_method_raises_exception
assert_raise(ActionController::UnknownHttpMethod) do
- request = stub_request 'REQUEST_METHOD' => 'RANDOM_METHOD'
- request.request_method
+ self.request_method = :random_method
+ @request.request_method
end
end
def test_allow_method_hacking_on_post
[:get, :head, :options, :put, :post, :delete].each do |method|
- request = stub_request 'REQUEST_METHOD' => method.to_s.upcase
- assert_equal(method == :head ? :get : method, request.method)
+ self.request_method = method
+ assert_equal(method == :head ? :get : method, @request.method)
+ end
+ end
+
+ def test_invalid_method_hacking_on_post_raises_exception
+ assert_raise(ActionController::UnknownHttpMethod) do
+ self.request_method = :_random_method
+ @request.request_method
end
end
def test_restrict_method_hacking
+ @request.instance_eval { @parameters = { :_method => 'put' } }
[:get, :put, :delete].each do |method|
- request = stub_request 'REQUEST_METHOD' => method.to_s.upcase,
- 'action_controller.request.request_parameters' => { :_method => 'put' }
- assert_equal method, request.method
+ self.request_method = method
+ assert_equal method, @request.method
end
end
def test_head_masquerading_as_get
- request = stub_request 'REQUEST_METHOD' => 'HEAD'
- assert_equal :get, request.method
- assert request.get?
- assert request.head?
+ self.request_method = :head
+ assert_equal :get, @request.method
+ assert @request.get?
+ assert @request.head?
end
def test_xml_format
- request = stub_request
- request.expects(:parameters).at_least_once.returns({ :format => 'xml' })
- assert_equal Mime::XML, request.format
+ @request.instance_eval { @parameters = { :format => 'xml' } }
+ assert_equal Mime::XML, @request.format
end
def test_xhtml_format
- request = stub_request
- request.expects(:parameters).at_least_once.returns({ :format => 'xhtml' })
- assert_equal Mime::HTML, request.format
+ @request.instance_eval { @parameters = { :format => 'xhtml' } }
+ assert_equal Mime::HTML, @request.format
end
def test_txt_format
- request = stub_request
- request.expects(:parameters).at_least_once.returns({ :format => 'txt' })
- assert_equal Mime::TEXT, request.format
+ @request.instance_eval { @parameters = { :format => 'txt' } }
+ assert_equal Mime::TEXT, @request.format
end
- def test_xml_http_request
+ def test_nil_format
ActionController::Base.use_accept_header, old =
false, ActionController::Base.use_accept_header
- request = stub_request 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'
- request.expects(:parameters).at_least_once.returns({})
- assert request.xhr?
- assert_equal Mime::JS, request.format
+ @request.instance_eval { @parameters = {} }
+ @request.env["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
+ assert @request.xhr?
+ assert_equal Mime::JS, @request.format
+
ensure
ActionController::Base.use_accept_header = old
end
def test_content_type
- request = stub_request 'CONTENT_TYPE' => 'text/html'
- assert_equal Mime::HTML, request.content_type
+ @request.env["CONTENT_TYPE"] = "text/html"
+ assert_equal Mime::HTML, @request.content_type
end
- def test_can_override_format_with_parameter
- request = stub_request
- request.expects(:parameters).at_least_once.returns({ :format => :txt })
- assert !request.format.xml?
-
- request = stub_request
- request.expects(:parameters).at_least_once.returns({ :format => :xml })
- assert request.format.xml?
+ def test_format_assignment_should_set_format
+ @request.instance_eval { self.format = :txt }
+ assert !@request.format.xml?
+ @request.instance_eval { self.format = :xml }
+ assert @request.format.xml?
end
def test_content_no_type
- request = stub_request
- assert_equal nil, request.content_type
+ assert_equal nil, @request.content_type
end
def test_content_type_xml
- request = stub_request 'CONTENT_TYPE' => 'application/xml'
- assert_equal Mime::XML, request.content_type
+ @request.env["CONTENT_TYPE"] = "application/xml"
+ assert_equal Mime::XML, @request.content_type
end
def test_content_type_with_charset
- request = stub_request 'CONTENT_TYPE' => 'application/xml; charset=UTF-8'
- assert_equal Mime::XML, request.content_type
+ @request.env["CONTENT_TYPE"] = "application/xml; charset=UTF-8"
+ assert_equal Mime::XML, @request.content_type
end
def test_user_agent
- request = stub_request 'HTTP_USER_AGENT' => 'TestAgent'
- assert_equal 'TestAgent', request.user_agent
+ assert_not_nil @request.user_agent
end
def test_parameters
- request = stub_request
- request.stubs(:request_parameters).returns({ "foo" => 1 })
- request.stubs(:query_parameters).returns({ "bar" => 2 })
+ @request.stubs(:request_parameters).returns({ "foo" => 1 })
+ @request.stubs(:query_parameters).returns({ "bar" => 2 })
- assert_equal({"foo" => 1, "bar" => 2}, request.parameters)
- assert_equal({"foo" => 1}, request.request_parameters)
- assert_equal({"bar" => 2}, request.query_parameters)
- end
-
-protected
-
- def stub_request(env={})
- ActionController::Request.new(env)
+ assert_equal({"foo" => 1, "bar" => 2}, @request.parameters)
+ assert_equal({"foo" => 1}, @request.request_parameters)
+ assert_equal({"bar" => 2}, @request.query_parameters)
end
+ protected
+ def request_method=(method)
+ @request.env['REQUEST_METHOD'] = method.to_s.upcase
+ @request.request_method = nil # Reset the ivar cache
+ end
end
View
4 vendor/rails/actionpack/test/controller/send_file_test.rb
@@ -44,12 +44,12 @@ def test_file_stream
response = nil
assert_nothing_raised { response = process('file') }
assert_not_nil response
- assert_kind_of Proc, response.body_parts
+ assert_kind_of Proc, response.body
require 'stringio'
output = StringIO.new
output.binmode
- assert_nothing_raised { response.body_parts.call(response, output) }
+ assert_nothing_raised { response.body.call(response, output) }
assert_equal file_data, output.string
end
View
21 vendor/rails/actionpack/test/controller/session/cookie_store_test.rb
@@ -193,6 +193,27 @@ def test_persistent_session_id
end
end
+ def test_session_store_with_expire_after
+ app = ActionController::Session::CookieStore.new(DispatcherApp, :key => SessionKey, :secret => SessionSecret, :expire_after => 5.hours)
+ @integration_session = open_session(app)
+
+ with_test_route_set do
+ # First request accesses the session
+ cookies[SessionKey] = SignedBar
+
+ get '/set_session_value'
+ assert_response :success
+ cookie = headers['Set-Cookie']
+
+ # Second request does not access the session so the
+ # expires header should not be changed
+ get '/no_session_access'
+ assert_response :success
+ assert_equal cookie, headers['Set-Cookie'],
+ "#{unmarshal_session(cookie).inspect} expected but was #{unmarshal_session(headers['Set-Cookie']).inspect}"
+ end
+ end
+
private
def with_test_route_set
with_routing do |set|
View
12 vendor/rails/actionpack/test/controller/test_test.rb
@@ -130,10 +130,6 @@ def teardown
ActionController::Routing::Routes.reload
end
- def test_test_request_has_session_options_initialized
- assert @request.session_options
- end
-
def test_raw_post_handling
params = {:page => {:name => 'page name'}, 'some key' => 123}
post :render_raw_post, params.dup
@@ -519,14 +515,6 @@ def test_header_properly_reset_after_get_request
assert_nil @request.instance_variable_get("@request_method")
end
- def test_params_reset_after_post_request
- post :no_op, :foo => "bar"
- assert_equal "bar", @request.params[:foo]
- @request.recycle!
- post :no_op
- assert @request.params[:foo].blank?
- end
-
%w(controller response request).each do |variable|
%w(get post put delete head process).each do |method|
define_method("test_#{variable}_missing_for_#{method}_raises_error") do
View
22 vendor/rails/actionpack/test/template/body_parts_test.rb
@@ -1,22 +0,0 @@
-require 'abstract_unit'
-
-class BodyPartsTest < ActionController::TestCase
- RENDERINGS = [Object.new, Object.new, Object.new]
-
- class TestController < ActionController::Base
- def index
- RENDERINGS.each do |rendering|
- response.template.punctuate_body! rendering
- end
- @performed_render = true
- end
- end
-
- tests TestController
-
- def test_body_parts
- get :index
- assert_equal RENDERINGS, @response.body_parts
- assert_equal RENDERINGS.join, @response.body
- end
-end
View
35 vendor/rails/actionpack/test/template/output_buffer_test.rb
@@ -1,35 +0,0 @@
-require 'abstract_unit'
-
-class OutputBufferTest < ActionController::TestCase
- class TestController < ActionController::Base
- def index
- render :text => 'foo'
- end
- end
-
- tests TestController
-
- def test_flush_output_buffer
- # Start with the default body parts
- get :index
- assert_equal ['foo'], @response.body_parts
- assert_nil @response.template.output_buffer
-
- # Nil output buffer is skipped
- @response.template.flush_output_buffer
- assert_nil @response.template.output_buffer
- assert_equal ['foo'], @response.body_parts
-
- # Empty output buffer is skipped
- @response.template.output_buffer = ''
- @response.template.flush_output_buffer
- assert_equal '', @response.template.output_buffer
- assert_equal ['foo'], @response.body_parts
-
- # Flushing appends the output buffer to the body parts
- @response.template.output_buffer = 'bar'
- @response.template.flush_output_buffer
- assert_equal '', @response.template.output_buffer
- assert_equal ['foo', 'bar'], @response.body_parts
- end
-end
View
32 vendor/rails/actionpack/test/template/template_test.rb
@@ -1,32 +0,0 @@
-require 'abstract_unit'
-
-class TemplateTest < Test::Unit::TestCase
- def test_template_path_parsing
- with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t|
- t.assert_parses_template_path 'abc.en.html.erb', :locale => 'en'
- t.assert_parses_template_path 'abc.en.plain.html.erb', :locale => 'en', :format => 'plain.html'
- t.assert_parses_template_path 'abc.html.erb'
- t.assert_parses_template_path 'abc.plain.html.erb', :format => 'plain.html'
- t.assert_parses_template_path 'abc.erb', :format => nil
- t.assert_parses_template_path 'abc.html', :extension => nil
-
- t.assert_parses_template_path '_abc.html.erb', :name => '_abc'
-
- t.assert_parses_template_path 'test/abc.html.erb', :base_path => 'test'
- t.assert_parses_template_path './test/abc.html.erb', :base_path => './test'
- t.assert_parses_template_path '../test/abc.html.erb', :base_path => '../test'
-
- t.assert_parses_template_path 'abc', :extension => nil, :format => nil, :name => nil
- t.assert_parses_template_path 'abc.xxx', :extension => nil, :format => 'xxx', :name => 'abc'
- t.assert_parses_template_path 'abc.html.xxx', :extension => nil, :format => 'xxx', :name => 'abc'
- end
- end
-
- private
- def assert_parses_template_path(path, parse_results)
- template = ActionView::Template.new(path, '')
- parse_results.each_pair do |k, v|
- assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) }
- end
- end
-end
View
23 vendor/rails/activerecord/lib/active_record/base.rb
@@ -810,28 +810,25 @@ def destroy(id)
# Updates all records with details given if they match a set of conditions supplied, limits and order can
# also be supplied. This method constructs a single SQL UPDATE statement and sends it straight to the
- # database. It does not instantiate the involved models and it does not trigger Active Record callbacks
- # or validations.
+ # database. It does not instantiate the involved models and it does not trigger Active Record callbacks.
#
# ==== Parameters
#
- # * +updates+ - A string, array, or hash representing the SET part of an SQL statement.
- # * +conditions+ - A string, array, or hash representing the WHERE part of an SQL statement. See conditions in the intro.
+ # * +updates+ - A string of column and value pairs that will be set on any records that match conditions. This creates the SET clause of the generated SQL.
+ # * +conditions+ - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro for more info.
# * +options+ - Additional options are <tt>:limit</tt> and <tt>:order</tt>, see the examples for usage.
#
# ==== Examples
#
- # # Update all customers with the given attributes
- # Customer.update_all :wants_email => true
+ # # Update all billing objects with the 3 different attributes given
+ # Billing.update_all( "category = 'authorized', approved = 1, author = 'David'" )
#
- # # Update all books with 'Rails' in their title
- # Book.update_all "author = 'David'", "title LIKE '%Rails%'"
+ # # Update records that match our conditions
+ # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" )
#
- # # Update all avatars migrated more than a week ago
- # Avatar.update_all ['migrated_at = ?, Time.now.utc], ['migrated_at > ?', 1.week.ago]
- #
- # # Update all books that match our conditions, but limit it to 5 ordered by date
- # Book.update_all "author = 'David'", "title LIKE '%Rails%'", :order => 'created_at', :limit => 5
+ # # Update records that match our conditions but limit it to 5 ordered by date
+ # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'",
+ # :order => 'created_at', :limit => 5 )
def update_all(updates, conditions = nil, options = {})
sql = "UPDATE #{quoted_table_name} SET #{sanitize_sql_for_assignment(updates)} "
View
14 vendor/rails/activeresource/README
@@ -1,7 +1,7 @@
= Active Resource
Active Resource (ARes) connects business objects and Representational State Transfer (REST)
-web services. It implements object-relational mapping for REST web services to provide transparent
+web services. It implements object-relational mapping for REST webservices to provide transparent
proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing
in ActionController::Resources).
@@ -22,14 +22,14 @@ received and serialized into a usable Ruby object.
=== Configuration and Usage
-Putting Active Resource to use is very similar to Active Record. It's as simple as creating a model class
+Putting ActiveResource to use is very similar to ActiveRecord. It's as simple as creating a model class
that inherits from ActiveResource::Base and providing a <tt>site</tt> class variable to it:
class Person < ActiveResource::Base
self.site = "http://api.people.com:3000/"
end
-Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes
+Now the Person class is REST enabled and can invoke REST services very similarly to how ActiveRecord invokes
lifecycle methods that operate against a persistent store.
# Find a person with id = 1
@@ -42,7 +42,7 @@ records. But rather than dealing directly with a database record, you're dealin
==== Protocol
Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing
-built into Action Controller but will also work with any other REST service that properly implements the protocol.
+built into ActionController but will also work with any other REST service that properly implements the protocol.
REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification:
* GET requests are used for finding and retrieving resources.
@@ -55,8 +55,8 @@ for more general information on REST web services, see the article here[http://e
==== Find
-Find requests use the GET method and expect the XML form of whatever resource/resources is/are being requested. So,
-for a request for a single element, the XML of that item is expected in response:
+GET Http requests expect the XML form of whatever resource/resources is/are being requested. So,
+for a request for a single element - the XML of that item is expected in response:
# Expects a response of
#
@@ -101,7 +101,7 @@ Collections can also be requested in a similar fashion
==== Create
-Creating a new resource submits the XML form of the resource as the body of the request and expects
+Creating a new resource submits the xml form of the resource as the body of the request and expects
a 'Location' header in the response with the RESTful URL location of the newly created resource. The
id of the newly created resource is parsed out of the Location response header and automatically set
as the id of the ARes object.
View
20 vendor/rails/activeresource/lib/active_resource/base.rb
@@ -19,7 +19,7 @@ module ActiveResource
# end
#
# Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and
- # you can now use Active Resource's lifecycle methods to manipulate resources. In the case where you already have
+ # you can now use Active Resource's lifecycles methods to manipulate resources. In the case where you already have
# an existing model with the same name as the desired RESTful resource you can set the +element_name+ value.
#
# class PersonResource < ActiveResource::Base
@@ -112,7 +112,6 @@ module ActiveResource
#
# Note: Some values cannot be provided in the URL passed to site. e.g. email addresses
# as usernames. In those situations you should use the separate user and password option.
- #
# == Errors & Validation
#
# Error handling and validation is handled in much the same manner as you're used to seeing in
@@ -157,7 +156,7 @@ module ActiveResource
#
# === Validation errors
#
- # Active Resource supports validations on resources and will return errors if any of these validations fail
+ # Active Resource supports validations on resources and will return errors if any these validations fail
# (e.g., "First name can not be blank" and so on). These types of errors are denoted in the response by
# a response code of <tt>422</tt> and an XML representation of the validation errors. The save operation will
# then fail (with a <tt>false</tt> return value) and the validation errors can be accessed on the resource in question.
@@ -414,7 +413,7 @@ def element_path(id, prefix_options = {}, query_options = nil)
# will split from the +prefix_options+.
#
# ==== Options
- # * +prefix_options+ - A hash to add a prefix to the request for nested URLs (e.g., <tt>:account_id => 19</tt>
+ # * +prefix_options+ - A hash to add a prefix to the request for nested URL's (e.g., <tt>:account_id => 19</tt>
# would yield a URL like <tt>/accounts/19/purchases.xml</tt>).
# * +query_options+ - A hash to add items to the query string for the request.
#
@@ -692,7 +691,7 @@ def clone
end
- # Returns +true+ if this object hasn't yet been saved, otherwise, returns +false+.
+ # A method to determine if the resource a \new object (i.e., it has not been POSTed to the remote service yet).
#
# ==== Examples
# not_new = Computer.create(:brand => 'Apple', :make => 'MacBook', :vendor => 'MacMall')
@@ -761,7 +760,7 @@ def hash
id.hash
end
- # Duplicates the current resource without saving it.
+ # Duplicate the current resource without saving it.
#
# ==== Examples
# my_invoice = Invoice.create(:customer => 'That Company')
@@ -780,8 +779,8 @@ def dup
end
end
- # Saves (+POST+) or \updates (+PUT+) a resource. Delegates to +create+ if the object is \new,
- # +update+ if it exists. If the response to the \save includes a body, it will be assumed that this body
+ # A method to \save (+POST+) or \update (+PUT+) a resource. It delegates to +create+ if a \new object,
+ # +update+ if it is existing. If the response to the \save includes a body, it will be assumed that this body
# is XML for the final object as it looked after the \save (which would include attributes like +created_at+
# that weren't part of the original submit).
#
@@ -833,7 +832,7 @@ def exists?
!new? && self.class.exists?(to_param, :params => prefix_options)
end
- # Converts the resource to an XML string representation.
+ # A method to convert the the resource to an XML string.
#
# ==== Options
# The +options+ parameter is handed off to the +to_xml+ method on each
@@ -862,7 +861,8 @@ def to_xml(options={})
attributes.to_xml({:root => self.class.element_name}.merge(options))
end
- # Converts the resource to a JSON string representation.
+ # Returns a JSON string representing the model. Some configuration is
+ # available through +options+.
#
# ==== Options
# The +options+ are passed to the +to_json+ method on each
View
22 vendor/rails/activeresource/lib/active_resource/connection.rb
@@ -95,46 +95,46 @@ def site=(site)
@password = URI.decode(@site.password) if @site.password
end
- # Sets the user for remote service.
+ # Set user for remote service.
def user=(user)
@user = user
end
- # Sets the password for remote service.
+ # Set password for remote service.
def password=(password)
@password = password
end
- # Sets the number of seconds after which HTTP requests to the remote service should time out.
+ # Set the number of seconds after which HTTP requests to the remote service should time out.
def timeout=(timeout)
@timeout = timeout
end
- # Executes a GET request.
+ # Execute a GET request.
# Used to get (find) resources.
def get(path, headers = {})
format.decode(request(:get, path, build_request_headers(headers, :get)).body)
end
- # Executes a DELETE request (see HTTP protocol documentation if unfamiliar).
+ # Execute a DELETE request (see HTTP protocol documentation if unfamiliar).
# Used to delete resources.
def delete(path, headers = {})
request(:delete, path, build_request_headers(headers, :delete))
end
- # Executes a PUT request (see HTTP protocol documentation if unfamiliar).
+ # Execute a PUT request (see HTTP protocol documentation if unfamiliar).
# Used to update resources.
def put(path, body = '', headers = {})
request(:put, path, body.to_s, build_request_headers(headers, :put))
end
- # Executes a POST request.
+ # Execute a POST request.
# Used to create new resources.
def post(path, body = '', headers = {})
request(:post, path, body.to_s, build_request_headers(headers, :post))
end
- # Executes a HEAD request.
+ # Execute a HEAD request.
# Used to obtain meta-information about resources, such as whether they exist and their size (via response headers).
def head(path, headers = {})
request(:head, path, build_request_headers(headers))
@@ -142,7 +142,7 @@ def head(path, headers = {})
private
- # Makes a request to the remote service.
+ # Makes request to remote service.
def request(method, path, *arguments)
logger.info "#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}" if logger
result = nil
@@ -153,7 +153,7 @@ def request(method, path, *arguments)
raise TimeoutError.new(e.message)
end
- # Handles response and error codes from the remote service.
+ # Handles response and error codes from remote service.
def handle_response(response)
case response.code.to_i
when 301,302
@@ -183,7 +183,7 @@ def handle_response(response)
end
end
- # Creates new Net::HTTP instance for communication with the
+ # Creates new Net::HTTP instance for communication with
# remote service and resources.
def http
http = Net::HTTP.new(@site.host, @site.port)
View
17 vendor/rails/activeresource/lib/active_resource/validations.rb
@@ -3,7 +3,7 @@ class ResourceInvalid < ClientError #:nodoc:
end
# Active Resource validation is reported to and from this object, which is used by Base#save
- # to determine whether the object is in a valid state to be saved. See usage example in Validations.
+ # to determine whether the object in a valid state to be saved. See usage example in Validations.
class Errors
include Enumerable
attr_reader :errors
@@ -14,10 +14,7 @@ def initialize(base) # :nodoc:
@base, @errors = base, {}
end
- # Adds an error to the base object instead of any particular attribute. This is used
- # to report errors that don't tie to any specific attribute, but rather to the object
- # as a whole. These error messages don't get prepended with any field name when iterating
- # with +each_full+, so they should be complete sentences.
+ # Add an error to the base Active Resource object rather than an attribute.
#
# ==== Examples
# my_folder = Folder.find(1)
@@ -71,9 +68,9 @@ def invalid?(attribute)
!@errors[attribute.to_s].nil?
end
- # Returns +nil+ if no errors are associated with the specified +attribute+.
- # Returns the error message if one error is associated with the specified +attribute+.
- # Returns an array of error messages if more than one error is associated with the specified +attribute+.
+ # A method to return the errors associated with +attribute+, which returns nil, if no errors are
+ # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+,
+ # or an array of error messages if more than one error is associated with the specified +attribute+.
#
# ==== Examples
# my_person = Person.new(params[:person])
@@ -95,7 +92,9 @@ def on(attribute)
alias :[] :on
- # Returns errors assigned to the base object through +add_to_base+ according to the normal rules of <tt>on(attribute)</tt>.
+ # A method to return errors assigned to +base+ object through add_to_base, which returns nil, if no errors are
+ # associated with the specified +attribute+, the error message if one error is associated with the specified +attribute+,
+ # or an array of error messages if more than one error is associated with the specified +attribute+.
#
# ==== Examples
# my_account = Account.find(1)
View
5 vendor/rails/activesupport/CHANGELOG
@@ -1,8 +1,3 @@
-*Edge
-
-* Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day #2066 [Michael Curtis]
-
-
*2.3.2 [Final] (March 15, 2009)*
* XmlMini supports LibXML and Nokogiri backends. #2084, #2190 [Bart ten Brinke, Aaron Patterson]
View
14 vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -116,14 +116,22 @@ def advance(options)
seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance)
end
- # Returns a new Time representing the time a number of seconds ago
+ # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension
def ago(seconds)
self.since(-seconds)
end
- # Returns a new Time representing the time a number of seconds since the instance time
+ # Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around
+ # the Numeric extension.
def since(seconds)
- self + seconds
+ f = seconds.since(self)
+ if ActiveSupport::Duration === seconds
+ f
+ else
+ initial_dst = self.dst? ? 1 : 0
+ final_dst = f.dst? ? 1 : 0
+ (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f
+ end
rescue
self.to_datetime.since(seconds)
end
View
12 vendor/rails/activesupport/test/core_ext/duration_test.rb
@@ -109,18 +109,6 @@ def test_since_and_ago_anchored_to_time_zone_now_when_time_zone_default_set
ensure
Time.zone_default = nil
end
-
- def test_adding_hours_across_dst_boundary
- with_env_tz 'CET' do
- assert_equal Time.local(2009,3,29,0,0,0) + 24.hours, Time.local(2009,3,30,1,0,0)
- end
- end
-
- def test_adding_day_across_dst_boundary
- with_env_tz 'CET' do
- assert_equal Time.local(2009,3,29,0,0,0) + 1.day, Time.local(2009,3,30,0,0,0)
- end
- end
protected
def with_env_tz(new_tz = 'US/Eastern')
View
73 vendor/rails/activesupport/test/core_ext/time_ext_test.rb
@@ -183,46 +183,26 @@ def test_ago
def test_daylight_savings_time_crossings_backward_start
with_env_tz 'US/Eastern' do
# dt: US: 2005 April 3rd 4:18am
- assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(24.hours), 'dt-24.hours=>st'
- assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400), 'dt-86400=>st'
- assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st'
-
- assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(24.hours), 'st-24.hours=>st'
- assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400), 'st-86400=>st'
- assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st'
+ assert_equal Time.local(2005,4,2,4,18,0), Time.local(2005,4,3,4,18,0).ago(86400), 'dt-1.day=>st'
+ assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400), 'st-1.day=>st'
end
with_env_tz 'NZ' do
# dt: New Zealand: 2006 October 1st 4:18am
- assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(24.hours), 'dt-24.hours=>st'
- assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st'
- assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400), 'dt-86400=>st'
-
- assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400), 'st-86400=>st'
- assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(24.hours), 'st-24.hours=>st'
- assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st'
+ assert_equal Time.local(2006,9,30,4,18,0), Time.local(2006,10,1,4,18,0).ago(86400), 'dt-1.day=>st'
+ assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400), 'st-1.day=>st'
end
end
def test_daylight_savings_time_crossings_backward_end
with_env_tz 'US/Eastern' do
# st: US: 2005 October 30th 4:03am
- assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(24.hours), 'st-24.hours=>dt'
- assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400), 'st-86400=>dt'
- assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt'
-
- assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(24.hours), 'dt-24.hours=>dt'
- assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400), 'dt-86400=>dt'
- assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt'
+ assert_equal Time.local(2005,10,29,4,3), Time.local(2005,10,30,4,3,0).ago(86400), 'st-1.day=>dt'
+ assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400), 'dt-1.day=>dt'
end
with_env_tz 'NZ' do
# st: New Zealand: 2006 March 19th 4:03am
- assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(24.hours), 'st-24.hours=>dt'
- assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400), 'st-86400=>dt'
- assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt'
-
- assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(24.hours), 'dt-24.hours=>dt'
- assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400), 'dt-86400=>dt'
- assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt'
+ assert_equal Time.local(2006,3,18,4,3), Time.local(2006,3,19,4,3,0).ago(86400), 'st-1.day=>dt'
+ assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400), 'dt-1.day=>dt'
end
end
@@ -251,7 +231,6 @@ def test_daylight_savings_time_crossings_backward_end_1day
assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(1.day), 'dt-1.day=>dt'
end
end
-
def test_since
assert_equal Time.local(2005,2,22,10,10,11), Time.local(2005,2,22,10,10,10).since(1)
assert_equal Time.local(2005,2,22,11,10,10), Time.local(2005,2,22,10,10,10).since(3600)
@@ -264,23 +243,13 @@ def test_since
def test_daylight_savings_time_crossings_forward_start
with_env_tz 'US/Eastern' do
# st: US: 2005 April 2nd 7:27pm
- assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(24.hours), 'st+24.hours=>dt'
- assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400), 'st+86400=>dt'
- assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt'
-
- assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(24.hours), 'dt+24.hoursy=>dt'
- assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400), 'dt+86400=>dt'
- assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt'
+ assert_equal Time.local(2005,4,3,19,27,0), Time.local(2005,4,2,19,27,0).since(86400), 'st+1.day=>dt'
+ assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400), 'dt+1.day=>dt'
end
with_env_tz 'NZ' do
# st: New Zealand: 2006 September 30th 7:27pm
- assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(24.hours), 'st+24.hours=>dt'
- assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400), 'st+86400=>dt'
- assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt'
-
- assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(24.hours), 'dt+24.hours=>dt'
- assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400), 'dt+86400=>dt'
- assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt'
+ assert_equal Time.local(2006,10,1,19,27,0), Time.local(2006,9,30,19,27,0).since(86400), 'st+1.day=>dt'
+ assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400), 'dt+1.day=>dt'
end
end
@@ -326,23 +295,13 @@ def test_daylight_savings_time_crossings_backward_start_yesterday
def test_daylight_savings_time_crossings_forward_end
with_env_tz 'US/Eastern' do
# dt: US: 2005 October 30th 12:45am
- assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(24.hours), 'dt+24.hours=>st'
- assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400), 'dt+86400=>st'
- assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400.seconds), 'dt+86400.seconds=>st'
-
- assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(24.hours), 'st+24.hours=>st'
- assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400), 'st+86400=>st'
- assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400.seconds), 'st+86400.seconds=>st'
+ assert_equal Time.local(2005,10,31,0,45,0), Time.local(2005,10,30,0,45,0).since(86400), 'dt+1.day=>st'
+ assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400), 'st+1.day=>st'
end
with_env_tz 'NZ' do
# dt: New Zealand: 2006 March 19th 1:45am
- assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(24.hours), 'dt+24.hours=>st'
- assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400), 'dt+86400=>st'
- assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400.seconds), 'dt+86400.seconds=>st'
-
- assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(24.hours), 'st+24.hours=>st'
- assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400), 'st+86400=>st'
- assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400.seconds), 'st+86400.seconds=>st'
+ assert_equal Time.local(2006,3,20,1,45,0), Time.local(2006,3,19,1,45,0).since(86400), 'dt+1.day=>st'
+ assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400), 'st+1.day=>st'
end
end
View
14 vendor/rails/pushgems.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+
+unless ARGV.first == "no_build"
+ build_number = Time.now.strftime("%Y%m%d%H%M%S").to_i
+end
+
+%w( activeresource actionmailer actionpack activerecord railties activesupport ).each do |pkg|
+ puts "Pushing: #{pkg} (#{build_number})"
+ if build_number
+ `cd #{pkg} && rm -rf pkg && PKG_BUILD=#{build_number} rake pgem && cd ..`
+ else
+ `cd #{pkg} && rm -rf pkg && rake pgem && cd ..`
+ end
+end
View
2  vendor/rails/railties/CHANGELOG
@@ -1,7 +1,5 @@
*2.3.2 [Final] (March 15, 2009)*
-* Remove outdated script/plugin options [Pratik Naik]
-
* Allow metal to live in plugins #2045 [Matthew Rudy]
* Added metal [Josh Peek]
View
1  vendor/rails/railties/Rakefile
@@ -247,7 +247,6 @@ end
desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"'
task :guides do
- ENV["WARN_BROKEN_LINKS"] = "1" # authors can't disable this
ruby "guides/rails_guides.rb"
end
View
BIN  vendor/rails/railties/guides/images/fxn.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1  vendor/rails/railties/guides/rails_guides.rb
@@ -33,7 +33,6 @@ module RailsGuides
autoload :Indexer, "rails_guides/indexer"
autoload :Helpers, "rails_guides/helpers"
autoload :TextileExtensions, "rails_guides/textile_extensions"
- autoload :Levenshtein, "rails_guides/levenshtein"
end
RedCloth.send(:include, RailsGuides::TextileExtensions)