From 6de3f1fb4e3160d0ab8f986ebe9287ce1a19aab0 Mon Sep 17 00:00:00 2001 From: Ilya Zayats Date: Sat, 26 Feb 2011 07:49:50 +0300 Subject: added information about TEST_DIR env variable --- railties/guides/source/contributing_to_ruby_on_rails.textile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 1977f8d0ce..e00b26f948 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -101,6 +101,14 @@ $ cd actionpack $ rake test +If you want to run tests from the specific directory use the +TEST_DIR+ environment variable. For example, this will run tests inside +railties/test/generators+ directory only: + + +$ cd railties +$ TEST_DIR=generators rake test + + + h4. Warnings The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings. -- cgit v1.2.3 From 8270dcd12e2892147002b23e80e3a25ab45a1e25 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 12:59:27 -0500 Subject: Correct example that did not do what it claimed. Rework explanation. --- .../lib/active_support/core_ext/hash/reverse_merge.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index a82cdfc360..87a7bebd7b 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -6,14 +6,14 @@ class Hash # options.reverse_merge! :size => 25, :velocity => 10 # end # - # Using merge, the above example would look as follows: + # The default :size and :velocity are only set if the +options+ hash passed in doesn't already + # have the respective key. + # + # As contrast, using Ruby's built in merge would require writing the following: # # def setup(options = {}) - # { :size => 25, :velocity => 10 }.merge(options) + # options = { :size => 25, :velocity => 10 }.merge(options) # end - # - # The default :size and :velocity are only set if the +options+ hash passed in doesn't already - # have the respective key. def reverse_merge(other_hash) other_hash.merge(self) end -- cgit v1.2.3 From e331ec0952bb199345d2f77a089abf9cd4f44240 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 13:28:40 -0500 Subject: Warn people that these methods are deprecated. --- railties/guides/source/active_support_core_extensions.textile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 788c243d2a..4074eac7e7 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1045,6 +1045,8 @@ NOTE: Defined in +active_support/core_ext/class/attribute_accessors.rb+. h4. Class Inheritable Attributes +WARNING: Class Inheritable Attributes are deprecated. It's recommended that you use +Class#class_attribute+ instead. + Class variables are shared down the inheritance tree. Class instance variables are not shared, but they are not inherited either. The macros +class_inheritable_reader+, +class_inheritable_writer+, and +class_inheritable_accessor+ provide accessors for class-level data which is inherited but not shared with children: -- cgit v1.2.3 From e872a8f2a5c2f9127b9b15a60ba37d5a21e9f6cb Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 13:36:47 -0500 Subject: Example descriptions and their examples were flipped. Fix. --- activesupport/lib/active_support/core_ext/string/filters.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index e15a1df9c9..d478ee0ef6 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -25,13 +25,13 @@ class String # "Once upon a time in a world far far away".truncate(27) # # => "Once upon a time in a wo..." # - # The last characters will be replaced with the :omission string (defaults to "...") - # for a total length not exceeding :length: + # Pass a :separator to truncate +text+ at a natural break: # # "Once upon a time in a world far far away".truncate(27, :separator => ' ') # # => "Once upon a time in a..." # - # Pass a :separator to truncate +text+ at a natural break: + # The last characters will be replaced with the :omission string (defaults to "...") + # for a total length not exceeding :length: # # "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)") # # => "And they f... (continued)" -- cgit v1.2.3 From 8f13a166ceda779357d1c356776a11086f7ee146 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 14:29:22 -0500 Subject: Clarify comment by removing french reference ('a la'). Should improve readability for non-native english speakers. --- activesupport/lib/active_support/core_ext/enumerable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 6ecedc26ef..6d7f771b5d 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -94,7 +94,7 @@ module Enumerable end # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. - # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26. + # Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26. def many?(&block) size = block_given? ? select(&block).size : self.size size > 1 -- cgit v1.2.3 From 72ae724485cb092870dc9914a4f95aa6fbeda7fa Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 27 Feb 2011 02:14:30 +0530 Subject: use resources in place of map.resources --- railties/guides/source/generators.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 41a96b487d..fc7b1216d5 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -345,7 +345,7 @@ $ rails generate scaffold Comment body:text invoke shoulda create test/unit/comment_test.rb create test/fixtures/comments.yml - route map.resources :comments + route resources :comments invoke scaffold_controller create app/controllers/comments_controller.rb invoke erb -- cgit v1.2.3 From 9b35eeec6271d341f6fbc64b3515516905d9883e Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 19:07:35 -0500 Subject: Clean up wording. --- railties/guides/source/active_support_core_extensions.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 4074eac7e7..7becefee09 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -2011,7 +2011,7 @@ That syntactic sugar is used a lot in Rails to avoid positional arguments where If a method expects a variable number of arguments and uses * in its declaration, however, such an options hash ends up being an item of the array of arguments, where it loses its role. -In those cases, you may give an options hash a distinguished treatment with +extract_options!+. That method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise returns an empty hash. +In those cases, you may give an options hash a distinguished treatment with +extract_options!+. This method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise it returns an empty hash. Let's see for example the definition of the +caches_action+ controller macro: -- cgit v1.2.3 From 6ff10c17aa6955c1e7c6b3ce17f01f80649abf2b Mon Sep 17 00:00:00 2001 From: Rodrigo Navarro Date: Sun, 27 Feb 2011 10:03:50 -0800 Subject: Pointing out that dynamic_form plugin must be installed to be able to use error_messages and error_messages_for view helpers. --- .../source/active_record_validations_callbacks.textile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 5dc6ef3774..58a184a48e 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -738,7 +738,20 @@ person.errors.size # => 0 h3. Displaying Validation Errors in the View -Rails provides built-in helpers to display the error messages of your models in your view templates. +Rails maintains an official plugin that provides helpers to display the error messages of your models in your view templates. You can install it as a plugin or as a Gem. + +h4. Installing as a plugin + +$ rails plugin install git://github.com/rails/dynamic_form.git + + +h4 Installing as a Gem +Add this line on your Gemfile: + +gem "dynamic_form" + + +Now you will have access to these two methods in your view templates: h4. +error_messages+ and +error_messages_for+ -- cgit v1.2.3 From 9bbbae06c57da6a25c70e54877c4867310131db9 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sun, 27 Feb 2011 16:45:57 -0500 Subject: Fix incorrect word. --- activesupport/lib/active_support/log_subscriber/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 52a64383a2..3227600078 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -27,7 +27,7 @@ module ActiveSupport # up the queue, subscriptions and turning colors in logs off. # # The messages are available in the @logger instance, which is a logger with limited - # powers (it actually do not send anything to your output), and you can collect them + # powers (it actually does not send anything to your output), and you can collect them # doing @logger.logged(level), where level is the level used in logging, like info, # debug, warn and so on. # -- cgit v1.2.3 From b95f8be594d64509bb251ecd8315474fab368073 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sun, 27 Feb 2011 20:22:55 -0500 Subject: Fix incorrect example. --- activesupport/lib/active_support/ordered_options.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 124e1a74f8..f4c27ac935 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -2,13 +2,13 @@ require 'active_support/ordered_hash' # Usually key value pairs are handled something like this: # -# h = ActiveSupport::OrderedOptions.new +# h = {} # h[:boy] = 'John' # h[:girl] = 'Mary' # h[:boy] # => 'John' # h[:girl] # => 'Mary' # -# Using OrderedOptions above code could be reduced to: +# Using OrderedOptions, the above code could be reduced to: # # h = ActiveSupport::OrderedOptions.new # h.boy = 'John' -- cgit v1.2.3 From 819762c90f9f49e92dd555a89f0e865f9bab9838 Mon Sep 17 00:00:00 2001 From: Lars Smit Date: Mon, 28 Feb 2011 12:17:26 +0100 Subject: Added some new advice on applying patches --- .../guides/source/contributing_to_ruby_on_rails.textile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index e00b26f948..9739da2666 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -351,6 +351,20 @@ $ git format-patch master --stdout > my_new_patch.diff Sanity check the results of this operation: open the diff file in your text editor of choice and make sure that no unintended changes crept in. +You can check your patches by applying your patch to an different dedicated branch: + + +$ git checkout -b testing_branch +$ git apply --check my_new_patch.diff + + +You can make sure your patches don't add any whitespace by applying it yourself using the --whitespace=error-all option. Make sure you are on your dedicated test branche and: + + +$ git apply --whitespace=error-all mynew_patch.diff + + + h4. Create a Lighthouse Ticket Now create a ticket with your patch. Go to the "new ticket":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/new page at Lighthouse. Fill in a reasonable title and description, remember to attach your patch file, and tag the ticket with the ‘patch’ tag and whatever other subject area tags make sense. -- cgit v1.2.3 From 4c9626664f7cf2549939466e9c0e1f5853948111 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Tue, 1 Mar 2011 01:16:30 +0100 Subject: Removed link to un-existing Issues page on Github --- railties/guides/source/layout.html.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index e924f2f6c0..f2681c6461 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -127,9 +127,6 @@ <%= link_to 'Ruby on Rails Guides Guidelines', 'ruby_on_rails_guides_guidelines.html' %> for style and conventions.

-

- Issues may also be reported in <%= link_to 'Github', 'https://github.com/lifo/docrails/issues' %>. -

And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome in the <%= link_to 'rubyonrails-docs mailing list', 'http://groups.google.com/group/rubyonrails-docs' %>.

-- cgit v1.2.3 From 80c0b00ba610384ab2bb8e7966104d22fb8c38e3 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Thu, 3 Mar 2011 01:03:25 +0100 Subject: Correct spelling for Base64 in action_mailer --- actionmailer/lib/action_mailer/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 15b0d01154..16fcf112b7 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -291,7 +291,7 @@ module ActionMailer #:nodoc: # * :authentication - If your mail server requires authentication, you need to specify the # authentication type here. # This is a symbol and one of :plain (will send the password in the clear), :login (will - # send password BASE64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange + # send password Base64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange # information and a cryptographic Message Digest 5 algorithm to hash important information) # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server # and starts to use it. -- cgit v1.2.3 From b4b7171d604702975b5a53afa6bf02baeb17f1b2 Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Thu, 3 Mar 2011 23:20:28 +0530 Subject: Spelling mistake --- railties/README.rdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/railties/README.rdoc b/railties/README.rdoc index 789d5255b7..0457227473 100644 --- a/railties/README.rdoc +++ b/railties/README.rdoc @@ -4,7 +4,7 @@ Railties is responsible to glue all frameworks together. Overall, it: * handles all the bootstrapping process for a Rails application; -* manager rails command line interface; +* manages rails command line interface; * provides Rails generators core; @@ -23,3 +23,4 @@ Documentation can be found at == License Railties is released under the MIT license. + -- cgit v1.2.3 From 3b7cf234179a3ce09f4a7a9412c15fd82cf1e71c Mon Sep 17 00:00:00 2001 From: mjy Date: Thu, 3 Mar 2011 13:28:26 -0500 Subject: fixes a missmatched column in example --- activerecord/lib/active_record/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5c4998806b..e530d2ff87 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -463,7 +463,7 @@ module ActiveRecord #:nodoc: # # # You can use the same string replacement techniques as you can with ActiveRecord#find # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] - # > [#"The Cheap Man Buys Twice"}>, ...] + # > [#"The Cheap Man Buys Twice"}>, ...] def find_by_sql(sql, binds = []) connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) } end -- cgit v1.2.3 From f44e0e82717062b3043a9ce65a8274f338817c83 Mon Sep 17 00:00:00 2001 From: tashian Date: Thu, 3 Mar 2011 15:04:39 -0800 Subject: Properly escaped a + in the dynamic segments TIP --- railties/guides/source/routing.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index d214031b31..c447fd911a 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -391,7 +391,7 @@ NOTE: You can't use +namespace+ or +:module+ with a +:controller+ path segment. match ':controller(/:action(/:id))', :controller => /admin\/[^\/]+/
-TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]+/+ allows anything except a slash. +TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]/+ allows anything except a slash. h4. Static Segments -- cgit v1.2.3 From 108561f1cb73c0f600db6cad10b7cf03bf90f09f Mon Sep 17 00:00:00 2001 From: "Jonathon D. Jones" Date: Thu, 3 Mar 2011 18:10:33 -0500 Subject: Adds link to Object.blank? from Object.present? --- activesupport/lib/active_support/core_ext/object/blank.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 51670b148f..f70853073a 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -13,7 +13,7 @@ class Object respond_to?(:empty?) ? empty? : !self end - # An object is present if it's not blank. + # An object is present if it's not #blank?. def present? !blank? end -- cgit v1.2.3 From fbed63aef056a2fbf9cf1eb846e7f8948001601c Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 22:23:30 -0500 Subject: Active Model typos. --- activemodel/README.rdoc | 2 +- activemodel/test/cases/validations/numericality_validation_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index d9a9bdae3e..b5b5edd52a 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -8,7 +8,7 @@ the Rails framework. Prior to Rails 3.0, if a plugin or gem developer wanted to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects -that did not exacly conform to the Active Record interface. This would result +that did not exactly conform to the Active Record interface. This would result in code duplication and fragile applications that broke on upgrades. Active Model solves this. You can include functionality from the following diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index e1d7d40c47..08f6169ca5 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -14,7 +14,7 @@ class NumericalityValidationTest < ActiveModel::TestCase NIL = [nil] BLANK = ["", " ", " \t \r \n"] - BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits + BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significant digits FLOAT_STRINGS = %w(0.0 +0.0 -0.0 10.0 10.5 -10.5 -0.0001 -090.1 90.1e1 -90.1e5 -90.1e-5 90e-5) INTEGER_STRINGS = %w(0 +0 -0 10 +10 -10 0090 -090) FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS -- cgit v1.2.3 From 103c297ab3e6c32ad965a6f5c35dc28e2f3c2469 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 22:31:00 -0500 Subject: Active Resource typos. --- activeresource/lib/active_resource/base.rb | 4 ++-- activeresource/test/cases/base_test.rb | 2 +- activeresource/test/cases/validations_test.rb | 2 +- activeresource/test/connection_test.rb | 2 +- activeresource/test/fixtures/address.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index daa8962929..160763779e 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -522,9 +522,9 @@ module ActiveResource # # * :key - An OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. # * :cert - An OpenSSL::X509::Certificate object as client certificate - # * :ca_file - Path to a CA certification file in PEM format. The file can contrain several CA certificates. + # * :ca_file - Path to a CA certification file in PEM format. The file can contain several CA certificates. # * :ca_path - Path of a CA certification directory containing certifications in PEM format. - # * :verify_mode - Flags for server the certification verification at begining of SSL/TLS session. (OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable) + # * :verify_mode - Flags for server the certification verification at beginning of SSL/TLS session. (OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable) # * :verify_callback - The verify callback for the server certification verification. # * :verify_depth - The maximum depth for the certificate chain verification. # * :cert_store - OpenSSL::X509::Store to verify peer certificate. diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb index ab801902ac..48dacbdf67 100644 --- a/activeresource/test/cases/base_test.rb +++ b/activeresource/test/cases/base_test.rb @@ -876,7 +876,7 @@ class BaseTest < Test::Unit::TestCase end ######################################################################## - # Tests the more miscelaneous helper methods + # Tests the more miscellaneous helper methods ######################################################################## def test_exists # Class method. diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb index 671d1ea8f0..3b1caecb04 100644 --- a/activeresource/test/cases/validations_test.rb +++ b/activeresource/test/cases/validations_test.rb @@ -3,7 +3,7 @@ require 'fixtures/project' require 'active_support/core_ext/hash/conversions' # The validations are tested thoroughly under ActiveModel::Validations -# This test case simply makes sur that they are all accessible by +# This test case simply makes sure that they are all accessible by # Active Resource objects. class ValidationsTest < ActiveModel::TestCase VALID_PROJECT_HASH = { :name => "My Project", :description => "A project" } diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb index fe80cdf2e5..6e79845aa0 100644 --- a/activeresource/test/connection_test.rb +++ b/activeresource/test/connection_test.rb @@ -44,7 +44,7 @@ class ConnectionTest < Test::Unit::TestCase # 401 is an unauthorized request assert_response_raises ActiveResource::UnauthorizedAccess, 401 - # 403 is a forbidden requst (and authorizing will not help) + # 403 is a forbidden request (and authorizing will not help) assert_response_raises ActiveResource::ForbiddenAccess, 403 # 404 is a missing resource. diff --git a/activeresource/test/fixtures/address.rb b/activeresource/test/fixtures/address.rb index fe921e1595..7a73ecb52a 100644 --- a/activeresource/test/fixtures/address.rb +++ b/activeresource/test/fixtures/address.rb @@ -1,4 +1,4 @@ -# turns everyting into the same object +# turns everything into the same object class AddressXMLFormatter include ActiveResource::Formats::XmlFormat -- cgit v1.2.3 From 80e3beb24b3fa7fad03486bd4f168f45377a8a60 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 23:14:18 -0500 Subject: Active Support typos. --- activesupport/bin/generate_tables | 2 +- activesupport/lib/active_support/core_ext/object/try.rb | 2 +- activesupport/lib/active_support/core_ext/string/multibyte.rb | 2 +- activesupport/lib/active_support/core_ext/string/output_safety.rb | 2 +- activesupport/lib/active_support/dependencies.rb | 2 +- activesupport/lib/active_support/log_subscriber/test_helper.rb | 2 +- activesupport/lib/active_support/multibyte/unicode.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables index 7a4f840226..5fefa429df 100644 --- a/activesupport/bin/generate_tables +++ b/activesupport/bin/generate_tables @@ -45,7 +45,7 @@ module ActiveSupport ([0-9]+); # canonical combining class ([A-Z]+); # bidi class (<([A-Z]*)>)? # decomposition type - ((\ ?[0-9A-F]+)*); # decompomposition mapping + ((\ ?[0-9A-F]+)*); # decomposition mapping ([0-9]*); # decimal digit ([0-9]*); # digit ([^;]*); # numeric diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb index ff812234e3..04619124a1 100644 --- a/activesupport/lib/active_support/core_ext/object/try.rb +++ b/activesupport/lib/active_support/core_ext/object/try.rb @@ -21,7 +21,7 @@ class Object # Person.try(:find, 1) # @people.try(:collect) {|p| p.name} # - # Without a method argument try will yield to the block unless the reciever is nil. + # Without a method argument try will yield to the block unless the receiver is nil. # @person.try { |p| "#{p.first_name} #{p.last_name}" } #-- # +try+ behaves like +Object#send+, unless called on +NilClass+. diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 0b974f5e0a..41de4d6435 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -9,7 +9,7 @@ class String # # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy - # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string. + # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string. # # name = 'Claus Müller' # name.reverse # => "rell??M sualC" diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index c930abc003..addd4dab95 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -24,7 +24,7 @@ class ERB end end - # Aliasing twice issues a warning "dicarding old...". Remove first to avoid it. + # Aliasing twice issues a warning "discarding old...". Remove first to avoid it. remove_method(:h) alias h html_escape diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index dab6fdbac6..daa98162d0 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -515,7 +515,7 @@ module ActiveSupport #:nodoc: # to its class/module if it implements +before_remove_const+. # # The callback implementation should be restricted to cleaning up caches, etc. - # as the enviroment will be in an inconsistent state, e.g. other constants + # as the environment will be in an inconsistent state, e.g. other constants # may have already been unloaded and not accessible. def remove_unloadable_constants! autoloaded_constants.each { |const| remove_constant const } diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 3227600078..392e33edbc 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -23,7 +23,7 @@ module ActiveSupport # end # # All you need to do is to ensure that your log subscriber is added to Rails::Subscriber, - # as in the second line of the code above. The test helpers is reponsible for setting + # as in the second line of the code above. The test helpers are responsible for setting # up the queue, subscriptions and turning colors in logs off. # # The messages are available in the @logger instance, which is a logger with limited diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 1139783b65..513f83e445 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -247,7 +247,7 @@ module ActiveSupport if is_unused || is_restricted bytes[i] = tidy_byte(byte) elsif is_cont - # Not expecting contination byte? Clean up. Otherwise, now expect one less. + # Not expecting continuation byte? Clean up. Otherwise, now expect one less. conts_expected == 0 ? bytes[i] = tidy_byte(byte) : conts_expected -= 1 else if conts_expected > 0 -- cgit v1.2.3 From 238e6f0c6e79257f3e522e66dd96f8249d0af0b0 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 23:54:58 -0500 Subject: Active Record typos. --- activerecord/lib/active_record/associations/association.rb | 4 ++-- activerecord/lib/active_record/autosave_association.rb | 2 +- activerecord/lib/active_record/callbacks.rb | 2 +- activerecord/test/cases/base_test.rb | 4 ++-- activerecord/test/cases/identity_map_test.rb | 4 ++-- activerecord/test/cases/migration_test.rb | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 86904ea2bc..81904afe3a 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -7,7 +7,7 @@ module ActiveRecord # This is the root class of all associations ('+ Foo' signifies an included module Foo): # # Association - # SingularAssociaton + # SingularAssociation # HasOneAssociation # HasOneThroughAssociation + ThroughAssociation # BelongsToAssociation @@ -88,7 +88,7 @@ module ActiveRecord # Construct the scope for this association. # - # Note that the association_scope is merged into the targed_scope only when the + # Note that the association_scope is merged into the target_scope only when the # scoped method is called. This is because at that point the call may be surrounded # by scope.scoping { ... } or with_scope { ... } etc, which affects the scope which # actually gets built. diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 748cc99a62..48dbe0838a 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -4,7 +4,7 @@ module ActiveRecord # = Active Record Autosave Association # # +AutosaveAssociation+ is a module that takes care of automatically saving - # associacted records when their parent is saved. In addition to saving, it + # associated records when their parent is saved. In addition to saving, it # also destroys any associated records that were marked for destruction. # (See +mark_for_destruction+ and marked_for_destruction?). # diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index ff4ce1b605..86d58df99b 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -73,7 +73,7 @@ module ActiveRecord # # Now, when Topic#destroy is run only +destroy_author+ is called. When Reply#destroy is # run, both +destroy_author+ and +destroy_readers+ are called. Contrast this to the following situation - # where the +before_destroy+ methis is overriden: + # where the +before_destroy+ method is overridden: # # class Topic < ActiveRecord::Base # def before_destroy() destroy_author end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 0ad20bb9bc..ed59b2105d 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -831,12 +831,12 @@ class BasicsTest < ActiveRecord::TestCase def test_dup_of_saved_object_marks_as_dirty_only_changed_attributes developer = Developer.create! :name => 'Bjorn' - assert !developer.name_changed? # both attributes of saved object should be threated as not changed + assert !developer.name_changed? # both attributes of saved object should be treated as not changed assert !developer.salary_changed? cloned_developer = developer.dup assert cloned_developer.name_changed? # ... but on cloned object should be - assert !cloned_developer.salary_changed? # ... BUT salary has non-nil default which should be threated as not changed on cloned instance + assert !cloned_developer.salary_changed? # ... BUT salary has non-nil default which should be treated as not changed on cloned instance end def test_bignum diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index d98638ab73..399d6c26df 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -295,7 +295,7 @@ class IdentityMapTest < ActiveRecord::TestCase end ############################################################################## - # Behaviour releated to saving failures + # Behaviour related to saving failures ############################################################################## def test_reload_object_if_save_failed @@ -338,7 +338,7 @@ class IdentityMapTest < ActiveRecord::TestCase end ############################################################################## - # Behaviour of readonly, forzen, destroyed + # Behaviour of readonly, frozen, destroyed ############################################################################## def test_find_using_identity_map_respects_readonly_when_loading_associated_object_first diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 9d7c49768b..bf7565a0d0 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -543,7 +543,7 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal "I was born ....", bob.bio assert_equal 18, bob.age - # Test for 30 significent digits (beyond the 16 of float), 10 of them + # Test for 30 significant digits (beyond the 16 of float), 10 of them # after the decimal place. unless current_adapter?(:SQLite3Adapter) @@ -1975,7 +1975,7 @@ if ActiveRecord::Base.connection.supports_migrations? t.integer :age end - # Adding an index fires a query everytime to check if an index already exists or not + # Adding an index fires a query every time to check if an index already exists or not assert_queries(3) do with_bulk_change_table do |t| t.index :username, :unique => true, :name => :awesome_username_index -- cgit v1.2.3 From 12325cf970cc62f7ce3723177da3ee7ba122bedf Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Fri, 4 Mar 2011 00:09:26 -0500 Subject: Action Pack typos. --- actionpack/lib/action_controller/caching/actions.rb | 2 +- actionpack/lib/action_controller/metal/instrumentation.rb | 2 +- actionpack/lib/action_dispatch/routing/mapper.rb | 4 ++-- actionpack/lib/action_view/helpers/date_helper.rb | 4 ++-- actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 +- actionpack/lib/action_view/helpers/number_helper.rb | 6 +++--- actionpack/lib/action_view/helpers/translation_helper.rb | 2 +- actionpack/lib/action_view/locale/en.yml | 2 +- actionpack/lib/action_view/template/handlers/erb.rb | 2 +- actionpack/test/controller/routing_test.rb | 2 +- actionpack/test/template/number_helper_test.rb | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index a4bac3caed..baff6d4be9 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -80,7 +80,7 @@ module ActionController #:nodoc: # header the Content-Type of the cached response could be wrong because # no information about the MIME type is stored in the cache key. So, if # you first ask for MIME type M in the Accept header, a cache entry is - # created, and then perform a second resquest to the same resource asking + # created, and then perform a second request to the same resource asking # for a different MIME type, you'd get the content cached for M. # # The :format parameter is taken into account though. The safest diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb index b08d9a8434..dc3ea939e6 100644 --- a/actionpack/lib/action_controller/metal/instrumentation.rb +++ b/actionpack/lib/action_controller/metal/instrumentation.rb @@ -78,7 +78,7 @@ module ActionController yield end - # Everytime after an action is processed, this method is invoked + # Every time after an action is processed, this method is invoked # with the payload, so you can add more information. # :api: plugin def append_info_to_payload(payload) #:nodoc: diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 589df218a8..1733c8032a 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -700,7 +700,7 @@ module ActionDispatch # Now routes such as +/posts/1+ will no longer be valid, but +/posts/1.1+ will be. # The +id+ parameter must match the constraint passed in for this example. # - # You may use this to also resrict other parameters: + # You may use this to also restrict other parameters: # # resources :posts do # constraints(:post_id => /\d+\.\d+) do @@ -720,7 +720,7 @@ module ActionDispatch # # === Dynamic request matching # - # Requests to routes can be constrained based on specific critera: + # Requests to routes can be constrained based on specific criteria: # # constraints(lambda { |req| req.env["HTTP_USER_AGENT"] =~ /iPhone/ }) do # resources :iphones diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index dc8e4bc316..6cd1565031 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -617,7 +617,7 @@ module ActionView @options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute] # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are - # valid (otherwise it could be 31 and february wouldn't be a valid date) + # valid (otherwise it could be 31 and February wouldn't be a valid date) if @datetime && @options[:discard_day] && !@options[:discard_month] @datetime = @datetime.change(:day => 1) end @@ -644,7 +644,7 @@ module ActionView @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day) # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are - # valid (otherwise it could be 31 and february wouldn't be a valid date) + # valid (otherwise it could be 31 and February wouldn't be a valid date) if @datetime && @options[:discard_day] && !@options[:discard_month] @datetime = @datetime.change(:day => 1) end diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 71f8534cbf..49aa434020 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -592,7 +592,7 @@ module ActionView options.stringify_keys.tap do |html_options| html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart") # The following URL is unescaped, this is just a hash of options, and it is the - # responsability of the caller to escape all the values. + # responsibility of the caller to escape all the values. html_options["action"] = url_for(url_for_options, *parameters_for_url) html_options["accept-charset"] = "UTF-8" html_options["data-remote"] = true if html_options.delete("remote") diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 26f8dce3c3..4e44843c4b 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -369,7 +369,7 @@ module ActionView # See number_to_human_size if you want to print a file size. # # You can also define you own unit-quantifier names if you want to use other decimal units - # (eg.: 1500 becomes "1.5 kilometers", 0.150 becomes "150 mililiters", etc). You may define + # (eg.: 1500 becomes "1.5 kilometers", 0.150 becomes "150 milliliters", etc). You may define # a wide range of unit quantifiers, even fractional ones (centi, deci, mili, etc). # # ==== Options @@ -425,13 +425,13 @@ module ActionView # thousand: # one: "kilometer" # other: "kilometers" - # billion: "gazilion-distance" + # billion: "gazillion-distance" # # Then you could do: # # number_to_human(543934, :units => :distance) # => "544 kilometers" # number_to_human(54393498, :units => :distance) # => "54400 kilometers" - # number_to_human(54393498000, :units => :distance) # => "54.4 gazilion-distance" + # number_to_human(54393498000, :units => :distance) # => "54.4 gazillion-distance" # number_to_human(343, :units => :distance, :precision => 1) # => "300 meters" # number_to_human(1, :units => :distance) # => "1 meter" # number_to_human(0.34, :units => :distance) # => "34 centimeters" diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index e7ec1df2c8..59e6ce878f 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -26,7 +26,7 @@ module ActionView # # E.g. the value returned for a missing translation key :"blog.post.title" will be # Title. - # This way your views will display rather reasonableful strings but it will still + # This way your views will display rather reasonable strings but it will still # be easy to spot missing translations. # # Second, it'll scope the key by the current partial if the key starts diff --git a/actionpack/lib/action_view/locale/en.yml b/actionpack/lib/action_view/locale/en.yml index 9004e52c5b..eb816b9446 100644 --- a/actionpack/lib/action_view/locale/en.yml +++ b/actionpack/lib/action_view/locale/en.yml @@ -5,7 +5,7 @@ format: # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) separator: "." - # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three) + # Delimits thousands (e.g. 1,000,000 is a million) (always in groups of three) delimiter: "," # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00) precision: 3 diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 0803114f44..a36837afc8 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -63,7 +63,7 @@ module ActionView class_attribute :default_format self.default_format = Mime::HTML - # Default implemenation used. + # Default implementation used. class_attribute :erb_implementation self.erb_implementation = Erubis diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 5f6f1b61c0..18cf944f46 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -407,7 +407,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase assert_equal '/page/foo', url_for(rs, { :controller => 'content', :action => 'show_page', :id => 'foo' }) assert_equal({ :controller => "content", :action => 'show_page', :id => 'foo' }, rs.recognize_path("/page/foo")) - token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in russian + token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in Russian token.force_encoding(Encoding::BINARY) if token.respond_to?(:force_encoding) escaped_token = CGI::escape(token) diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index 156b7cb5ff..c1b4bab903 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -140,7 +140,7 @@ class NumberHelperTest < ActionView::TestCase def test_number_with_precision_with_significant_true_and_zero_precision # Zero precision with significant is a mistake (would always return zero), - # so we treat it as if significant was false (increases backwards compatibily for number_to_human_size) + # so we treat it as if significant was false (increases backwards compatibility for number_to_human_size) assert_equal "124", number_with_precision(123.987, :precision => 0, :significant => true) assert_equal "12", number_with_precision(12, :precision => 0, :significant => true ) assert_equal "12", number_with_precision("12.3", :precision => 0, :significant => true ) -- cgit v1.2.3 From c8dae23a2addbbeb8fabf832676b12ef51060b56 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Fri, 4 Mar 2011 00:19:58 -0500 Subject: Railties typos. --- railties/lib/rails/engine.rb | 6 +++--- .../rails/generators/rails/plugin_new/templates/test/test_helper.rb | 2 +- railties/lib/rails/generators/resource_helpers.rb | 2 +- railties/lib/rails/railtie/configuration.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 6e5e842370..4ce874d4b9 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -252,12 +252,12 @@ module Rails # end # # The routes above will automatically point to MyEngine::ApplicationContoller. Furthermore, you don't - # need to use longer url helpers like my_engine_articles_path. Instead, you shuold simply use + # need to use longer url helpers like my_engine_articles_path. Instead, you should simply use # articles_path as you would do with your application. # # To make that behaviour consistent with other parts of the framework, an isolated engine also has influence on # ActiveModel::Naming. When you use a namespaced model, like MyEngine::Article, it will normally - # use the prefix "my_engine". In an isolated engine, the prefix will be ommited in url helpers and + # use the prefix "my_engine". In an isolated engine, the prefix will be omitted in url helpers and # form fields for convenience. # # polymorphic_url(MyEngine::Article.new) #=> "articles_path" @@ -266,7 +266,7 @@ module Rails # text_field :title #=> # end # - # Additionaly isolated engine will set its name according to namespace, so + # Additionally isolated engine will set its name according to namespace, so # MyEngine::Engine.engine_name #=> "my_engine". It will also set MyEngine.table_name_prefix # to "my_engine_", changing MyEngine::Article model to use my_engine_article table. # diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb index 791b901593..dcd3b276e3 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb @@ -1,4 +1,4 @@ -# Configure Rails Envinronment +# Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index d6ccfc496a..de01c858dd 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -53,7 +53,7 @@ module Rails @controller_i18n_scope ||= controller_file_path.gsub('/', '.') end - # Loads the ORM::Generators::ActiveModel class. This class is responsable + # Loads the ORM::Generators::ActiveModel class. This class is responsible # to tell scaffold entities how to generate an specific method for the # ORM. Check Rails::Generators::ActiveModel for more information. def orm_class diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index afeceafb67..e4368866a1 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -18,7 +18,7 @@ module Rails # This allows you to modify application's generators from Railties. # - # Values set on app_generators will become defaults for applicaiton, unless + # Values set on app_generators will become defaults for application, unless # application overwrites them. def app_generators @@app_generators ||= Rails::Configuration::Generators.new -- cgit v1.2.3 From a48f46d4fc6d62138f26d27de060c2f119842969 Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sat, 5 Mar 2011 06:08:21 +0530 Subject: typo changes --- actionmailer/README.rdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index b346bd9e79..805a7a72ad 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -75,7 +75,7 @@ Or you can just chain the methods together like: == Receiving emails To receive emails, you need to implement a public instance method called receive that takes a -tmail object as its single parameter. The Action Mailer framework has a corresponding class method, +email object as its single parameter. The Action Mailer framework has a corresponding class method, which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns into the tmail object and calls the receive instance method. @@ -145,3 +145,4 @@ API documentation is at Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here: * https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets + -- cgit v1.2.3 From 3463247da55e34e8c1eb77cf029cdbbf3def624c Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sat, 5 Mar 2011 06:10:35 +0530 Subject: typo changes --- actionmailer/README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 805a7a72ad..4290cc9bcd 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -77,7 +77,7 @@ Or you can just chain the methods together like: To receive emails, you need to implement a public instance method called receive that takes a email object as its single parameter. The Action Mailer framework has a corresponding class method, which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns -into the tmail object and calls the receive instance method. +into the email object and calls the receive instance method. Example: -- cgit v1.2.3 From 34f5628a072f7afa677d25c9559076d5c21721ce Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sat, 5 Mar 2011 06:19:17 +0530 Subject: commas to set off expressions that interrupt sentence flow --- actionmailer/README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 4290cc9bcd..fb93fd1080 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -104,7 +104,7 @@ trivial case like this: rails runner 'Mailman.receive(STDIN.read)' However, invoking Rails in the runner for each mail to be received is very resource intensive. A single -instance of Rails should be run within a daemon if it is going to be utilized to process more than just +instance of Rails should be run within a daemon, if it is going to be utilized to process more than just a limited number of email. == Configuration -- cgit v1.2.3 From 22faa2c86d07711221732960b1ccf30b176116c5 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 6 Mar 2011 03:29:23 +0900 Subject: wrong SQL statement --- railties/guides/source/active_record_querying.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 64a68f7592..ed3968e226 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -420,7 +420,7 @@ Client.limit(5).offset(30) will return instead a maximum of 5 clients beginning with the 31st. The SQL looks like: -SELECT * FROM clients LIMIT 5, 30 +SELECT * FROM clients LIMIT 5 OFFSET 30 h3. Group -- cgit v1.2.3 From d8462510c5378f9204778ffb9df4fdbece7dccd0 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Sun, 6 Mar 2011 00:27:37 +0100 Subject: Fixed identation in actionmailer base_test --- actionmailer/test/base_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 1b793d255e..6a7931da8c 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -153,8 +153,8 @@ class BaseTest < ActiveSupport::TestCase assert_equal(2, email.parts.length) assert_equal("multipart/related", email.mime_type) assert_equal("multipart/alternative", email.parts[0].mime_type) - assert_equal("text/plain", email.parts[0].parts[0].mime_type) - assert_equal("text/html", email.parts[0].parts[1].mime_type) + assert_equal("text/plain", email.parts[0].parts[0].mime_type) + assert_equal("text/html", email.parts[0].parts[1].mime_type) assert_equal("logo.png", email.parts[1].filename) end -- cgit v1.2.3 From 09d3e89cf0b3e7be03f97739e297fd40ebba1178 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 5 Mar 2011 20:01:06 -0800 Subject: use sort_by instead of sort() --- activesupport/lib/active_support/cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index b4f0c42e37..ddb7a315e2 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -493,7 +493,7 @@ module ActiveSupport key.first.to_param end elsif key.is_a?(Hash) - key = key.to_a.sort{|a,b| a.first.to_s <=> b.first.to_s}.collect{|k,v| "#{k}=#{v}"}.to_param + key = key.to_a.sort_by { |x| x.first.to_s }.collect{|k,v| "#{k}=#{v}"}.to_param else key = key.to_param end -- cgit v1.2.3 From dff73dec223c5d4ffe1178e0e15399f78d962e76 Mon Sep 17 00:00:00 2001 From: Diego Carrion Date: Sun, 6 Mar 2011 00:47:15 -0300 Subject: added failing test for fields_for with a record object that inherits from Hash Signed-off-by: Andrew White --- actionpack/test/template/form_options_helper_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 69b1d4ff7b..93ff7ba0fd 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -1,6 +1,12 @@ require 'abstract_unit' require 'tzinfo' +class Map < Hash + def category + "" + end +end + TZInfo::Timezone.cattr_reader :loaded_zones class FormOptionsHelperTest < ActionView::TestCase @@ -394,6 +400,19 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_fields_for_with_record_inherited_from_hash + map = Map.new + + output_buffer = fields_for :map, map do |f| + concat f.select(:category, %w( abe hest)) + end + + assert_dom_equal( + "", + output_buffer + ) + end + def test_select_under_fields_for_with_index @post = Post.new @post.category = "" -- cgit v1.2.3 From e80db417ed656018d0ad4335260c3a2313142a57 Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sun, 6 Mar 2011 10:53:44 +0530 Subject: styles applied for usage --- actionmailer/lib/rails/generators/mailer/USAGE | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE index a08d459739..99d1ea3885 100644 --- a/actionmailer/lib/rails/generators/mailer/USAGE +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -1,15 +1,16 @@ -Description: +*Description:* Stubs out a new mailer and its views. Pass the mailer name, either CamelCased or under_scored, and an optional list of emails as arguments. This generates a mailer class in app/mailers and invokes your template engine and test framework generators. -Example: - `rails generate mailer Notifications signup forgot_password invoice` +*Example:* + -rails generate mailer Notifications signup forgot_password invoice- creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb Views: app/views/notifications/signup.erb [...] Test: test/functional/notifications_test.rb Fixtures: test/fixtures/notifications/signup [...] + -- cgit v1.2.3 From 0509bf35f1987c1e0b9c3dd1389778f8426180f7 Mon Sep 17 00:00:00 2001 From: Alexander Uvarov Date: Sun, 6 Mar 2011 09:00:22 +0500 Subject: Allow model to be inherited from Hash [#6487 state:resolved] Signed-off-by: Andrew White --- actionpack/lib/action_view/helpers/form_helper.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 669ccd2a2d..6df86ae65a 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -6,6 +6,7 @@ require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/string/output_safety' +require 'active_support/core_ext/array/extract_options' module ActionView # = Action View Form Helpers @@ -880,9 +881,9 @@ module ActionView private - def instantiate_builder(record, record_object = nil, options = nil, &block) - options, record_object = record_object, nil if record_object.is_a?(Hash) - options ||= {} + def instantiate_builder(record, *args, &block) + options = args.extract_options! + record_object = args.shift case record when String, Symbol -- cgit v1.2.3 From 1d4826937e438ebcd6a2f9e29d2e466a43fef7a8 Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sun, 6 Mar 2011 11:38:18 +0530 Subject: style changes --- actionmailer/lib/rails/generators/mailer/USAGE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE index 99d1ea3885..8f4ba5916a 100644 --- a/actionmailer/lib/rails/generators/mailer/USAGE +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -1,12 +1,12 @@ -*Description:* +Description: Stubs out a new mailer and its views. Pass the mailer name, either CamelCased or under_scored, and an optional list of emails as arguments. This generates a mailer class in app/mailers and invokes your template engine and test framework generators. -*Example:* - -rails generate mailer Notifications signup forgot_password invoice- +Example: + rails generate mailer Notifications signup forgot_password invoice creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb -- cgit v1.2.3 From e00867bc437b6a681491ef59e13423051e6d98f0 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 6 Mar 2011 07:08:50 +0000 Subject: Raise ArgumentError if route name is invalid [#6517 state:resolved] --- .../lib/action_dispatch/routing/route_set.rb | 2 ++ actionpack/test/dispatch/routing_test.rb | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index fc86d52a3a..61053d4464 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -1,5 +1,6 @@ require 'rack/mount' require 'forwardable' +require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/to_query' require 'active_support/core_ext/hash/slice' @@ -330,6 +331,7 @@ module ActionDispatch end def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) + raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i) route = Route.new(self, app, conditions, requirements, defaults, name, anchor) @set.add_route(*route) named_routes[name] = route if name diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 1a96587836..5e5758a60e 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2313,6 +2313,38 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_invalid_route_name_raises_error + assert_raise(ArgumentError) do + self.class.stub_controllers do |routes| + routes.draw { get '/products', :to => 'products#index', :as => 'products ' } + end + end + + assert_raise(ArgumentError) do + self.class.stub_controllers do |routes| + routes.draw { get '/products', :to => 'products#index', :as => ' products' } + end + end + + assert_raise(ArgumentError) do + self.class.stub_controllers do |routes| + routes.draw { get '/products', :to => 'products#index', :as => 'products!' } + end + end + + assert_raise(ArgumentError) do + self.class.stub_controllers do |routes| + routes.draw { get '/products', :to => 'products#index', :as => 'products index' } + end + end + + assert_raise(ArgumentError) do + self.class.stub_controllers do |routes| + routes.draw { get '/products', :to => 'products#index', :as => '1products' } + end + end + end + def test_nested_route_in_nested_resource get "/posts/1/comments/2/views" assert_equal "comments#views", @response.body -- cgit v1.2.3 From 2cd3dcabe26530ba73d87383732a35c02ff797f6 Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sun, 6 Mar 2011 12:53:23 +0530 Subject: Revert "style changes" This reverts commit 1d4826937e438ebcd6a2f9e29d2e466a43fef7a8. --- actionmailer/lib/rails/generators/mailer/USAGE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE index 8f4ba5916a..99d1ea3885 100644 --- a/actionmailer/lib/rails/generators/mailer/USAGE +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -1,12 +1,12 @@ -Description: +*Description:* Stubs out a new mailer and its views. Pass the mailer name, either CamelCased or under_scored, and an optional list of emails as arguments. This generates a mailer class in app/mailers and invokes your template engine and test framework generators. -Example: - rails generate mailer Notifications signup forgot_password invoice +*Example:* + -rails generate mailer Notifications signup forgot_password invoice- creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb -- cgit v1.2.3 From ac59a2a1d67aca74895ceddbc709a467c572144b Mon Sep 17 00:00:00 2001 From: JudeArasu Date: Sun, 6 Mar 2011 12:55:56 +0530 Subject: style changes --- actionmailer/lib/rails/generators/mailer/USAGE | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE index 99d1ea3885..448ddbd5df 100644 --- a/actionmailer/lib/rails/generators/mailer/USAGE +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -1,12 +1,14 @@ -*Description:* +Description: +============ Stubs out a new mailer and its views. Pass the mailer name, either CamelCased or under_scored, and an optional list of emails as arguments. This generates a mailer class in app/mailers and invokes your template engine and test framework generators. -*Example:* - -rails generate mailer Notifications signup forgot_password invoice- +Example: +======== + rails generate mailer Notifications signup forgot_password invoice creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb -- cgit v1.2.3 From 9b96de6f3dfa31695c2fc27919e2989a98f6899d Mon Sep 17 00:00:00 2001 From: suchasurge Date: Sun, 6 Mar 2011 10:26:24 +0100 Subject: Some style changes --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- activesupport/lib/active_support/configurable.rb | 6 ++++++ activesupport/lib/active_support/hash_with_indifferent_access.rb | 4 ++-- activesupport/lib/active_support/i18n_railtie.rb | 2 +- activesupport/lib/active_support/message_encryptor.rb | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 8465bc1e10..0e6bc30fa2 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -8,7 +8,7 @@ module ActiveSupport # filter or modify the paths of any lines of the backtrace, you can call BacktraceCleaner#remove_filters! These two methods # will give you a completely untouched backtrace. # - # Example: + # ==== Example: # # bc = BacktraceCleaner.new # bc.add_filter { |line| line.gsub(Rails.root, '') } diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index be19189c04..7bac3dbc91 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -41,6 +41,9 @@ module ActiveSupport # Allows you to add shortcut so that you don't have to refer to attribute through config. # Also look at the example for config to contrast. # + # + # ==== Example + # # class User # include ActiveSupport::Configurable # config_accessor :allowed_access @@ -65,6 +68,9 @@ module ActiveSupport # Reads and writes attributes from a configuration OrderedHash. # + # + # ==== Example + # # require 'active_support/configurable' # # class User diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 6a344867ee..79a0de7940 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -1,7 +1,7 @@ require 'active_support/core_ext/hash/keys' # This class has dubious semantics and we only have it so that -# people can write params[:key] instead of params['key'] +# people can write params[:key] instead of params['key'] # and they get the same value for both keys. module ActiveSupport @@ -109,7 +109,7 @@ module ActiveSupport end # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. - # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. + # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. def reverse_merge(other_hash) super self.class.new_from_hash_copying_default(other_hash) end diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb index 4a9ee5a769..a25e951080 100644 --- a/activesupport/lib/active_support/i18n_railtie.rb +++ b/activesupport/lib/active_support/i18n_railtie.rb @@ -14,7 +14,7 @@ module I18n @reloader ||= ActiveSupport::FileUpdateChecker.new([]){ I18n.reload! } end - # Add I18n::Railtie.reloader to ActionDispatch callbacks. Since, at this + # Add I18n::Railtie.reloader to ActionDispatch callbacks. Since, at this # point, no path was added to the reloader, I18n.reload! is not triggered # on to_prepare callbacks. This will only happen on the config.after_initialize # callback below. diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index d21f90f8b7..4f7cd12d48 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -7,7 +7,7 @@ module ActiveSupport # # The cipher text and initialization vector are base64 encoded and returned to you. # - # This can be used in situations similar to the MessageVerifier, but where you don't + # This can be used in situations similar to the MessageVerifier, but where you don't # want users to be able to determine the value of the payload. class MessageEncryptor class InvalidMessage < StandardError; end -- cgit v1.2.3 From b99fb66fb75bcc6b42869caa28dc79781a1aa9c7 Mon Sep 17 00:00:00 2001 From: suchasurge Date: Sun, 6 Mar 2011 10:44:52 +0100 Subject: more style changes --- activesupport/lib/active_support/log_subscriber.rb | 2 +- activesupport/lib/active_support/message_verifier.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index df335af841..10675edac5 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -21,7 +21,7 @@ module ActiveSupport # ActiveRecord::LogSubscriber.attach_to :active_record # # Since we need to know all instance methods before attaching the log subscriber, - # the line above should be called after your ActiveRecord::LogSubscriber definition. + # the line above should be called after your ActiveRecord::LogSubscriber definition. # # After configured, whenever a "sql.active_record" notification is published, # it will properly dispatch the event (ActiveSupport::Notifications::Event) to diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb index 9a4468f73c..8f3946325a 100644 --- a/activesupport/lib/active_support/message_verifier.rb +++ b/activesupport/lib/active_support/message_verifier.rb @@ -2,7 +2,7 @@ require 'active_support/base64' require 'active_support/core_ext/object/blank' module ActiveSupport - # MessageVerifier makes it easy to generate and verify messages which are signed + # +MessageVerifier+ makes it easy to generate and verify messages which are signed # to prevent tampering. # # This is useful for cases like remember-me tokens and auto-unsubscribe links where the -- cgit v1.2.3 From 31f09f9dbc1b8e598fc82d86b622167bfc01d18a Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 6 Mar 2011 12:49:44 +0000 Subject: Improve testing of cookies in functional tests: - cookies can be set using string or symbol keys - cookies are preserved across calls to get, post, etc. - cookie names and values are escaped - cookies can be cleared using @request.cookies.clear [#6272 state:resolved] --- actionpack/lib/action_controller/test_case.rb | 11 +++- .../lib/action_dispatch/testing/test_process.rb | 2 +- .../lib/action_dispatch/testing/test_request.rb | 7 ++- actionpack/test/dispatch/cookies_test.rb | 65 ++++++++++++++++++++++ actionpack/test/dispatch/test_request_test.rb | 4 +- 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 0f43527a56..bc4f8bb9ce 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -172,6 +172,10 @@ module ActionController end def recycle! + write_cookies! + @env.delete('HTTP_COOKIE') if @cookies.blank? + @env.delete('action_dispatch.cookies') + @cookies = nil @formats = nil @env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ } @env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ } @@ -301,7 +305,11 @@ module ActionController # and cookies, though. For sessions, you just do: # # @request.session[:key] = "value" - # @request.cookies["key"] = "value" + # @request.cookies[:key] = "value" + # + # To clear the cookies for a test just clear the request's cookies hash: + # + # @request.cookies.clear # # == \Testing named routes # @@ -416,6 +424,7 @@ module ActionController @controller.process_with_new_base_test(@request, @response) @assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {} @request.session.delete('flash') if @request.session['flash'].blank? + @request.cookies.merge!(@response.cookies) @response end diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb index 16f3674164..d430691429 100644 --- a/actionpack/lib/action_dispatch/testing/test_process.rb +++ b/actionpack/lib/action_dispatch/testing/test_process.rb @@ -22,7 +22,7 @@ module ActionDispatch end def cookies - HashWithIndifferentAccess.new(@request.cookies.merge(@response.cookies)) + @request.cookies.merge(@response.cookies).with_indifferent_access end def redirect_to_url diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb index cf440a1fad..822adb6a47 100644 --- a/actionpack/lib/action_dispatch/testing/test_request.rb +++ b/actionpack/lib/action_dispatch/testing/test_request.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/object/blank' require 'active_support/core_ext/hash/reverse_merge' +require 'rack/utils' module ActionDispatch class TestRequest < Request @@ -77,10 +78,14 @@ module ActionDispatch private def write_cookies! unless @cookies.blank? - @env['HTTP_COOKIE'] = @cookies.map { |name, value| "#{name}=#{value};" }.join(' ') + @env['HTTP_COOKIE'] = @cookies.map { |name, value| escape_cookie(name, value) }.join('; ') end end + def escape_cookie(name, value) + "#{Rack::Utils.escape(name)}=#{Rack::Utils.escape(value)}" + end + def delete_nil_values! @env.delete_if { |k, v| v.nil? } end diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index 1cfea6aa12..39159fd629 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -124,6 +124,20 @@ class CookiesTest < ActionController::TestCase cookies['user_name'] = "david" head :ok end + + def symbol_key_mock + cookies[:user_name] = "david" if cookies[:user_name] == "andrew" + head :ok + end + + def string_key_mock + cookies['user_name'] = "david" if cookies['user_name'] == "andrew" + head :ok + end + + def noop + head :ok + end end tests TestController @@ -411,6 +425,57 @@ class CookiesTest < ActionController::TestCase end end + def test_setting_request_cookies_is_indifferent_access + @request.cookies.clear + @request.cookies[:user_name] = "andrew" + get :string_key_mock + assert_equal "david", cookies[:user_name] + + @request.cookies.clear + @request.cookies['user_name'] = "andrew" + get :symbol_key_mock + assert_equal "david", cookies['user_name'] + end + + def test_cookies_retained_across_requests + get :symbol_key + assert_equal "user_name=david; path=/", @response.headers["Set-Cookie"] + assert_equal "david", cookies[:user_name] + + get :noop + assert_nil @response.headers["Set-Cookie"] + assert_equal "user_name=david", @request.env['HTTP_COOKIE'] + assert_equal "david", cookies[:user_name] + + get :noop + assert_nil @response.headers["Set-Cookie"] + assert_equal "user_name=david", @request.env['HTTP_COOKIE'] + assert_equal "david", cookies[:user_name] + end + + def test_cookies_can_be_cleared + get :symbol_key + assert_equal "user_name=david; path=/", @response.headers["Set-Cookie"] + assert_equal "david", cookies[:user_name] + + @request.cookies.clear + get :noop + assert_nil @response.headers["Set-Cookie"] + assert_nil @request.env['HTTP_COOKIE'] + assert_nil cookies[:user_name] + + get :symbol_key + assert_equal "user_name=david; path=/", @response.headers["Set-Cookie"] + assert_equal "david", cookies[:user_name] + end + + def test_cookies_are_escaped + @request.cookies[:user_ids] = '1;2' + get :noop + assert_equal "user_ids=1%3B2", @request.env['HTTP_COOKIE'] + assert_equal "1;2", cookies[:user_ids] + end + private def assert_cookie_header(expected) header = @response.headers["Set-Cookie"] diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb index e42ade73d1..81a8c24525 100644 --- a/actionpack/test/dispatch/test_request_test.rb +++ b/actionpack/test/dispatch/test_request_test.rb @@ -36,10 +36,10 @@ class TestRequestTest < ActiveSupport::TestCase req.cookies["user_name"] = "david" assert_equal({"user_name" => "david"}, req.cookies) - assert_equal "user_name=david;", req.env["HTTP_COOKIE"] + assert_equal "user_name=david", req.env["HTTP_COOKIE"] req.cookies["login"] = "XJ-122" assert_equal({"user_name" => "david", "login" => "XJ-122"}, req.cookies) - assert_equal %w(login=XJ-122 user_name=david), req.env["HTTP_COOKIE"].split(/; ?/).sort + assert_equal %w(login=XJ-122 user_name=david), req.env["HTTP_COOKIE"].split(/; /).sort end end -- cgit v1.2.3 From 5e7ce47fb9ab50858fe067a6eb6c0462c5c5681e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 6 Mar 2011 15:23:31 +0000 Subject: Report the correct value of nil.id in the exception message as different ruby implementations may have different values, for example Rubinius returns 53 for nil.id. [#6444 state:resolved] --- activesupport/lib/active_support/whiny_nil.rb | 2 +- activesupport/test/whiny_nil_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/whiny_nil.rb b/activesupport/lib/active_support/whiny_nil.rb index 91ddef2619..bcedbfd57a 100644 --- a/activesupport/lib/active_support/whiny_nil.rb +++ b/activesupport/lib/active_support/whiny_nil.rb @@ -37,7 +37,7 @@ class NilClass # Raises a RuntimeError when you attempt to call +id+ on +nil+. def id - raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller + raise RuntimeError, "Called id for nil, which would mistakenly be #{object_id} -- if you really wanted the id of nil, use object_id", caller end private diff --git a/activesupport/test/whiny_nil_test.rb b/activesupport/test/whiny_nil_test.rb index 4b9f06dead..ec3ca99ee6 100644 --- a/activesupport/test/whiny_nil_test.rb +++ b/activesupport/test/whiny_nil_test.rb @@ -33,9 +33,11 @@ class WhinyNilTest < Test::Unit::TestCase end def test_id + nil.stubs(:object_id).returns(999) nil.id rescue RuntimeError => nme assert_no_match(/nil:NilClass/, nme.message) + assert_match(/999/, nme.message) end def test_no_to_ary_coercion -- cgit v1.2.3 From 8bbc5b4f5fd0ccc0b496cbdb2abb07d24b84aaba Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 6 Mar 2011 17:42:42 +0100 Subject: Revert "Fixed identation in actionmailer base_test" Please excuse the revert. Albeit the commit is totally innocent, docrails has a strong no-code policy we need to enforce. Please feel free to submit the fix as a patch and assign it to me, I'll apply right away. This reverts commit d8462510c5378f9204778ffb9df4fdbece7dccd0. --- actionmailer/test/base_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 6a7931da8c..1b793d255e 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -153,8 +153,8 @@ class BaseTest < ActiveSupport::TestCase assert_equal(2, email.parts.length) assert_equal("multipart/related", email.mime_type) assert_equal("multipart/alternative", email.parts[0].mime_type) - assert_equal("text/plain", email.parts[0].parts[0].mime_type) - assert_equal("text/html", email.parts[0].parts[1].mime_type) + assert_equal("text/plain", email.parts[0].parts[0].mime_type) + assert_equal("text/html", email.parts[0].parts[1].mime_type) assert_equal("logo.png", email.parts[1].filename) end -- cgit v1.2.3 From 6ce844a3c1d9c1de4ae54cbe73e0dbd0acbe688a Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 6 Mar 2011 17:49:39 +0100 Subject: removes Examples headers introduced in 9b96de6 Example headers are discouraged in the API guidelines. Code just flows with the text. They may be good in places where there's a lot of stuff and structure may add clarity --- activesupport/lib/active_support/configurable.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index 7bac3dbc91..8c56a21ef7 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -41,9 +41,6 @@ module ActiveSupport # Allows you to add shortcut so that you don't have to refer to attribute through config. # Also look at the example for config to contrast. # - # - # ==== Example - # # class User # include ActiveSupport::Configurable # config_accessor :allowed_access @@ -67,24 +64,21 @@ module ActiveSupport end # Reads and writes attributes from a configuration OrderedHash. - # # - # ==== Example + # require 'active_support/configurable' # - # require 'active_support/configurable' - # # class User # include ActiveSupport::Configurable - # end + # end # # user = User.new - # + # # user.config.allowed_access = true # user.config.level = 1 # # user.config.allowed_access # => true # user.config.level # => 1 - # + # def config @_config ||= self.class.config.inheritable_copy end -- cgit v1.2.3 From 3a621e7be4d5f592e04e8ee03435936f9e5f1c36 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 6 Mar 2011 20:34:56 +0100 Subject: removes merge conflicts --- .../lib/active_support/core_ext/hash/reverse_merge.rb | 11 ----------- activesupport/lib/active_support/core_ext/object/blank.rb | 4 ---- 2 files changed, 15 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index 63b4ba49e9..01863a162b 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -3,23 +3,12 @@ class Hash # # options = options.reverse_merge(:size => 25, :velocity => 10) # -<<<<<<< HEAD - # The default :size and :velocity are only set if the +options+ hash passed in doesn't already - # have the respective key. - # - # As contrast, using Ruby's built in merge would require writing the following: - # - # def setup(options = {}) - # options = { :size => 25, :velocity => 10 }.merge(options) - # end -======= # is equivalent to # # options = {:size => 25, :velocity => 10}.merge(options) # # This is particularly useful for initializing an options hash # with default values. ->>>>>>> 20768176292cbcb883ab152b4aa9ed8c664771cd def reverse_merge(other_hash) other_hash.merge(self) end diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 7b5832b51a..d0c1ea8326 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -13,11 +13,7 @@ class Object respond_to?(:empty?) ? empty? : !self end -<<<<<<< HEAD - # An object is present if it's not #blank?. -======= # An object is present if it's not blank?. ->>>>>>> 20768176292cbcb883ab152b4aa9ed8c664771cd def present? !blank? end -- cgit v1.2.3 From 7e9d45cc7f76497873720bf4797ddfba126c8cd8 Mon Sep 17 00:00:00 2001 From: Paco Guzman Date: Sun, 6 Mar 2011 22:24:22 +0100 Subject: remove unused assigned variable --- activemodel/lib/active_model/observing.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index af036b560e..ef36f80bec 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -72,7 +72,7 @@ module ActiveModel def instantiate_observer(observer) #:nodoc: # string/symbol if observer.respond_to?(:to_sym) - observer = observer.to_s.camelize.constantize.instance + observer.to_s.camelize.constantize.instance elsif observer.respond_to?(:instance) observer.instance else -- cgit v1.2.3 From c528297d17236e57fa4076272547367870158034 Mon Sep 17 00:00:00 2001 From: Dalibor Nasevic Date: Sun, 6 Mar 2011 20:03:06 +0100 Subject: Fixed indentation in actionmailer base_test [#6538 state:committed] Signed-off-by: Xavier Noria --- actionmailer/test/base_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 1b793d255e..6a7931da8c 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -153,8 +153,8 @@ class BaseTest < ActiveSupport::TestCase assert_equal(2, email.parts.length) assert_equal("multipart/related", email.mime_type) assert_equal("multipart/alternative", email.parts[0].mime_type) - assert_equal("text/plain", email.parts[0].parts[0].mime_type) - assert_equal("text/html", email.parts[0].parts[1].mime_type) + assert_equal("text/plain", email.parts[0].parts[0].mime_type) + assert_equal("text/html", email.parts[0].parts[1].mime_type) assert_equal("logo.png", email.parts[1].filename) end -- cgit v1.2.3 From 532f915037ab65873c433e30399d11f93df9f1f8 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 7 Mar 2011 00:04:06 +0000 Subject: Referencing a table via the ON condition in a join should force that table to be eager-loaded via a JOIN rather than via subsequent queries. --- activerecord/lib/active_record/relation.rb | 13 ++++++++++++- activerecord/test/cases/relations_test.rb | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index f939bedc81..5af20bf38b 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -407,8 +407,19 @@ module ActiveRecord private def references_eager_loaded_tables? + joined_tables = arel.join_sources.map do |join| + if join.is_a?(Arel::Nodes::StringJoin) + tables_in_string(join.left) + else + [join.left.table_name, join.left.table_alias] + end + end + + joined_tables += [table.name, table.table_alias] + # always convert table names to downcase as in Oracle quoted table names are in uppercase - joined_tables = (tables_in_string(arel.join_sql) + [table.name, table.table_alias]).compact.map{ |t| t.downcase }.uniq + joined_tables = joined_tables.flatten.compact.map { |t| t.downcase }.uniq + (tables_in_string(to_sql) - joined_tables).any? end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 37bbb17e74..948fcf7012 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -850,4 +850,19 @@ class RelationTest < ActiveRecord::TestCase def test_primary_key assert_equal "id", Post.scoped.primary_key end + + def test_eager_loading_with_conditions_on_joins + scope = Post.includes(:comments) + + # This references the comments table, and so it should cause the comments to be eager + # loaded via a JOIN, rather than by subsequent queries. + scope = scope.joins( + Post.arel_table.create_join( + Post.arel_table, + Post.arel_table.create_on(Comment.arel_table[:id].eq(3)) + ) + ) + + assert scope.eager_loading? + end end -- cgit v1.2.3 From a032212e7c1da834ae75d85a4f2f1f943bfdc474 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 7 Mar 2011 09:33:19 -0800 Subject: refactor calls to to_param in expand_key method --- activesupport/lib/active_support/cache.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index ddb7a315e2..e2b7b0707b 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -484,19 +484,20 @@ module ActiveSupport # object responds to +cache_key+. Otherwise, to_param method will be # called. If the key is a Hash, then keys will be sorted alphabetically. def expanded_key(key) # :nodoc: - if key.respond_to?(:cache_key) - key = key.cache_key.to_s - elsif key.is_a?(Array) + return key.cache_key.to_s if key.respond_to?(:cache_key) + + case key + when Array if key.size > 1 - key.collect{|element| expanded_key(element)}.to_param + key = key.collect{|element| expanded_key(element)} else - key.first.to_param + key = key.first end - elsif key.is_a?(Hash) - key = key.to_a.sort_by { |x| x.first.to_s }.collect{|k,v| "#{k}=#{v}"}.to_param - else - key = key.to_param + when Hash + key = key.sort_by { |k,_| k.to_s }.collect{|k,v| "#{k}=#{v}"} end + + key.to_param end # Prefix a key with the namespace. Namespace and key will be delimited with a colon. -- cgit v1.2.3 From 5968d7a65886d3450698889f685eccaf54749f43 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 7 Mar 2011 09:36:07 -0800 Subject: do not test explicit equality of predicate methods, they should be allowed to return truthy or falsey objects --- activesupport/lib/active_support/cache.rb | 6 +----- activesupport/test/caching_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index e2b7b0707b..10c457bb1d 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -590,11 +590,7 @@ module ActiveSupport # Check if the entry is expired. The +expires_in+ parameter can override the # value set when the entry was created. def expired? - if @expires_in && @created_at + @expires_in <= Time.now.to_f - true - else - false - end + @expires_in && @created_at + @expires_in <= Time.now.to_f end # Set a new time when the entry will expire. diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 579d5dad24..e5668e29d7 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -679,12 +679,12 @@ class CacheEntryTest < ActiveSupport::TestCase def test_expired entry = ActiveSupport::Cache::Entry.new("value") - assert_equal false, entry.expired? + assert !entry.expired?, 'entry not expired' entry = ActiveSupport::Cache::Entry.new("value", :expires_in => 60) - assert_equal false, entry.expired? + assert !entry.expired?, 'entry not expired' time = Time.now + 61 Time.stubs(:now).returns(time) - assert_equal true, entry.expired? + assert entry.expired?, 'entry is expired' end def test_compress_values -- cgit v1.2.3