Permalink
Browse files

Merge branch 'master' of github.com:lifo/docrails

  • Loading branch information...
2 parents 1c68e55 + 818b366 commit 5debc65c356c619bce20dcc10c0befc7c4204ef5 Neeraj Singh committed Nov 22, 2010
Showing with 2,084 additions and 1,276 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 Gemfile
  3. +34 −22 Rakefile
  4. +5 −2 actionmailer/lib/action_mailer/test_case.rb
  5. +2 −2 actionmailer/lib/action_mailer/version.rb
  6. +2 −0 actionpack/CHANGELOG
  7. +1 −1 actionpack/actionpack.gemspec
  8. +4 −4 actionpack/lib/abstract_controller/rendering.rb
  9. +2 −1 actionpack/lib/action_controller/metal/helpers.rb
  10. +23 −24 actionpack/lib/action_controller/metal/rendering.rb
  11. +3 −1 actionpack/lib/action_controller/railties/paths.rb
  12. +4 −2 actionpack/lib/action_controller/test_case.rb
  13. +2 −2 actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
  14. +8 −2 actionpack/lib/action_dispatch/http/upload.rb
  15. +2 −1 actionpack/lib/action_dispatch/http/url.rb
  16. +16 −13 actionpack/lib/action_dispatch/routing/mapper.rb
  17. +2 −2 actionpack/lib/action_pack/version.rb
  18. +13 −490 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  19. +133 −0 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb
  20. +153 −0 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
  21. +173 −0 actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
  22. +144 −0 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
  23. +2 −2 actionpack/lib/action_view/helpers/form_helper.rb
  24. +2 −2 actionpack/lib/action_view/railtie.rb
  25. +2 −1 actionpack/lib/action_view/template.rb
  26. +0 −8 actionpack/test/abstract_unit.rb
  27. +12 −0 actionpack/test/activerecord/active_record_store_test.rb
  28. +8 −0 actionpack/test/controller/action_pack_assertions_test.rb
  29. +11 −3 actionpack/test/controller/routing_test.rb
  30. +3 −0 actionpack/test/dispatch/request_test.rb
  31. +12 −0 actionpack/test/dispatch/uploaded_file_test.rb
  32. +46 −3 actionpack/test/template/asset_tag_helper_test.rb
  33. +9 −0 actionpack/test/template/render_test.rb
  34. +1 −1 activemodel/activemodel.gemspec
  35. +2 −2 activemodel/lib/active_model/version.rb
  36. +0 −6 activemodel/test/cases/helper.rb
  37. +27 −0 activerecord/CHANGELOG
  38. +21 −5 activerecord/lib/active_record/association_preload.rb
  39. +7 −6 activerecord/lib/active_record/associations.rb
  40. +13 −18 activerecord/lib/active_record/associations/association_collection.rb
  41. +2 −2 activerecord/lib/active_record/associations/association_proxy.rb
  42. +2 −1 activerecord/lib/active_record/attribute_methods/dirty.rb
  43. +4 −2 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  44. +24 −19 activerecord/lib/active_record/base.rb
  45. +5 −0 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  46. +174 −119 activerecord/lib/active_record/migration.rb
  47. +91 −0 activerecord/lib/active_record/migration/command_recorder.rb
  48. +6 −4 activerecord/lib/active_record/named_scope.rb
  49. +9 −4 activerecord/lib/active_record/nested_attributes.rb
  50. +9 −11 activerecord/lib/active_record/reflection.rb
  51. +26 −13 activerecord/lib/active_record/relation/calculations.rb
  52. +5 −0 activerecord/lib/active_record/relation/predicate_builder.rb
  53. +23 −5 activerecord/lib/active_record/relation/query_methods.rb
  54. +4 −5 activerecord/lib/active_record/schema.rb
  55. +5 −3 activerecord/lib/active_record/timestamp.rb
  56. +2 −2 activerecord/lib/active_record/version.rb
  57. +2 −2 activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
  58. +2 −2 activerecord/lib/rails/generators/active_record/model/templates/migration.rb
  59. +2 −2 activerecord/lib/rails/generators/active_record/session_migration/templates/migration.rb
  60. +2 −1 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  61. +52 −0 activerecord/test/cases/associations/eager_test.rb
  62. +21 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  63. +2 −2 activerecord/test/cases/associations/inverse_associations_test.rb
  64. +5 −5 activerecord/test/cases/associations_test.rb
  65. +1 −1 activerecord/test/cases/attribute_methods_test.rb
  66. +2 −4 activerecord/test/cases/autosave_association_test.rb
  67. +10 −2 activerecord/test/cases/base_test.rb
  68. +13 −0 activerecord/test/cases/calculations_test.rb
  69. +1 −1 activerecord/test/cases/finder_test.rb
  70. +3 −3 activerecord/test/cases/fixtures_test.rb
  71. +0 −5 activerecord/test/cases/helper.rb
  72. +57 −0 activerecord/test/cases/invertible_migration_test.rb
  73. +108 −0 activerecord/test/cases/migration/command_recorder_test.rb
  74. +66 −12 activerecord/test/cases/migration_test.rb
  75. +1 −1 activerecord/test/cases/named_scope_test.rb
  76. +1 −2 activerecord/test/cases/persistence_test.rb
  77. +0 −1 activerecord/test/cases/query_cache_test.rb
  78. +0 −2 activerecord/test/cases/relation_scoping_test.rb
  79. +46 −0 activerecord/test/cases/relations_test.rb
  80. +1 −1 activerecord/test/cases/timestamp_test.rb
  81. +1 −1 activerecord/test/cases/transactions_test.rb
  82. +2 −2 activerecord/test/cases/validations/association_validation_test.rb
  83. +2 −2 activerecord/test/cases/validations/uniqueness_validation_test.rb
  84. +5 −3 activeresource/lib/active_resource/base.rb
  85. +2 −2 activeresource/lib/active_resource/version.rb
  86. +3 −3 activeresource/test/cases/base_test.rb
  87. +13 −9 activesupport/lib/active_support/callbacks.rb
  88. +9 −83 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  89. +1 −3 activesupport/lib/active_support/core_ext/object/to_param.rb
  90. +2 −2 activesupport/lib/active_support/core_ext/object/to_query.rb
  91. +12 −10 activesupport/lib/active_support/core_ext/string/output_safety.rb
  92. +0 −1 activesupport/lib/active_support/i18n.rb
  93. +2 −2 activesupport/lib/active_support/version.rb
  94. +1 −2 activesupport/lib/active_support/xml_mini/nokogirisax.rb
  95. +5 −0 activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
  96. +4 −4 activesupport/test/core_ext/object/to_query_test.rb
  97. +0 −69 activesupport/test/core_ext/string_ext_test.rb
  98. +3 −1 railties/CHANGELOG
  99. +1 −1 railties/guides/assets/stylesheets/main.css
  100. +2 −7 railties/guides/rails_guides/helpers.rb
  101. +2 −2 railties/guides/source/3_0_release_notes.textile
  102. +0 −2 railties/guides/source/action_controller_overview.textile
  103. +0 −2 railties/guides/source/action_mailer_basics.textile
  104. +0 −2 railties/guides/source/action_view_overview.textile
  105. +0 −2 railties/guides/source/active_record_querying.textile
  106. +1 −3 railties/guides/source/active_record_validations_callbacks.textile
  107. +0 −2 railties/guides/source/active_support_core_extensions.textile
  108. +0 −2 railties/guides/source/association_basics.textile
  109. +0 −1 railties/guides/source/caching_with_rails.textile
  110. +0 −3 railties/guides/source/command_line.textile
  111. +0 −2 railties/guides/source/configuring.textile
  112. +1 −1 railties/guides/source/contribute.textile
  113. +1 −3 railties/guides/source/contributing_to_rails.textile
  114. +0 −2 railties/guides/source/debugging_rails_applications.textile
  115. +0 −2 railties/guides/source/form_helpers.textile
  116. +2 −4 railties/guides/source/generators.textile
  117. +0 −2 railties/guides/source/getting_started.textile
  118. +0 −5 railties/guides/source/i18n.textile
  119. +7 −7 railties/guides/source/index.html.erb
  120. +5 −5 railties/guides/source/initialization.textile
  121. +25 −0 railties/guides/source/layout.html.erb
  122. +0 −2 railties/guides/source/layouts_and_rendering.textile
  123. +0 −2 railties/guides/source/migrations.textile
  124. +0 −2 railties/guides/source/performance_testing.textile
  125. +0 −2 railties/guides/source/plugins.textile
  126. +0 −2 railties/guides/source/rails_application_templates.textile
  127. +0 −2 railties/guides/source/rails_on_rack.textile
  128. +1 −3 railties/guides/source/routing.textile
  129. +1 −3 railties/guides/source/security.textile
  130. +0 −2 railties/guides/source/testing.textile
  131. +11 −6 railties/lib/rails/commands.rb
  132. +0 −6 railties/lib/rails/commands/plugin_new.rb
  133. +1 −4 railties/lib/rails/engine.rb
  134. +1 −0 railties/lib/rails/generators.rb
  135. +0 −2 railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
  136. +0 −2 railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb
  137. +0 −2 railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
  138. +0 −2 railties/lib/rails/generators/erb/scaffold/templates/new.html.erb
  139. +0 −2 railties/lib/rails/generators/erb/scaffold/templates/show.html.erb
  140. +21 −22 railties/lib/rails/generators/named_base.rb
  141. +7 −0 railties/lib/rails/generators/rails/plugin/plugin_generator.rb
  142. +10 −7 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
  143. +1 −1 ...b/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt
  144. +0 −2 railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb
  145. +0 −11 railties/lib/rails/test_help.rb
  146. +2 −2 railties/lib/rails/version.rb
  147. +5 −0 railties/test/application/generators_test.rb
  148. +60 −0 railties/test/application/initializers/frameworks_test.rb
  149. +16 −0 railties/test/application/rake_test.rb
  150. +6 −6 railties/test/generators/migration_generator_test.rb
  151. +3 −3 railties/test/generators/model_generator_test.rb
  152. +12 −6 railties/test/generators/plugin_generator_test.rb
  153. +6 −1 railties/test/generators/plugin_new_generator_test.rb
  154. +6 −0 railties/test/generators_test.rb
  155. +7 −29 railties/test/railties/engine_test.rb
  156. +0 −11 release.rb
  157. +96 −0 tasks/release.rb
  158. +2 −2 version.rb
View
@@ -13,6 +13,7 @@ activesupport/doc
activemodel/test/fixtures/fixture_database.sqlite3
actionpack/test/tmp
activesupport/test/fixtures/isolation_test
+dist
railties/test/500.html
railties/test/fixtures/tmp
railties/test/initializer/root/log
View
@@ -39,7 +39,7 @@ end
platforms :ruby do
gem 'json'
gem 'yajl-ruby'
- gem "nokogiri", ">= 1.4.3.1"
+ gem "nokogiri", ">= 1.4.4"
# AR
gem "sqlite3-ruby", "~> 1.3.1", :require => 'sqlite3'
View
@@ -3,7 +3,16 @@ require 'rdoc'
require 'rake'
require 'rdoc/task'
-require 'rake/gempackagetask'
+require 'net/http'
+
+$:.unshift File.expand_path('..', __FILE__)
+require "tasks/release"
+
+desc "Build gem files for all projects"
+task :build => "all:build"
+
+desc "Release all gems to gemcutter and create a tag"
+task :release => "all:release"
# RDoc skips some files in the Rails tree due to its binary? predicate. This is a quick
# hack for edge docs, until we decide which is the correct way to address this issue.
@@ -54,27 +63,6 @@ task :smoke do
system %(cd activerecord && #{$0} sqlite3:isolated_test)
end
-spec = eval(File.read('rails.gemspec'))
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.gem_spec = spec
-end
-
-desc "Release all gems to gemcutter. Package rails, package & push components, then push rails"
-task :release => :release_projects do
- require 'rake/gemcutter'
- Rake::Gemcutter::Tasks.new(spec).define
- Rake::Task['gem:push'].invoke
-end
-
-desc "Release all components to gemcutter."
-task :release_projects => :package do
- errors = []
- PROJECTS.each do |project|
- system(%(cd #{project} && #{$0} release)) || errors << project
- end
- fail("Errors in #{errors.join(', ')}") unless errors.empty?
-end
-
desc "Install gems for all projects."
task :install => :gem do
version = File.read("RAILS_VERSION").strip
@@ -172,3 +160,27 @@ task :update_versions do
end
end
end
+
+#
+# We have a webhook configured in Github that gets invoked after pushes.
+# This hook triggers the following tasks:
+#
+# * updates the local checkout
+# * updates Rails Contributors
+# * generates and publishes edge docs
+# * if there's a new stable tag, generates and publishes stable docs
+#
+# Everything is automated and you do NOT need to run this task normally.
+#
+# We publish a new version by tagging, and pushing a tag does not trigger
+# that webhook. Stable docs would be updated by any subsequent regular
+# push, but if you want that to happen right away just run this.
+#
+desc 'Publishes docs, run this AFTER a new stable tag has been pushed'
+task :publish_docs do
+ Net::HTTP.new('rails-hooks.hashref.com').start do |http|
+ request = Net::HTTP::Post.new('/rails-master-hook')
+ response = http.request(request)
+ puts response.body
+ end
+end
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionMailer
class NonInferrableMailerError < ::StandardError
def initialize(name)
@@ -15,11 +17,11 @@ module Behavior
module ClassMethods
def tests(mailer)
- write_inheritable_attribute(:mailer_class, mailer)
+ self._mailer_class = mailer
end
def mailer_class
- if mailer = read_inheritable_attribute(:mailer_class)
+ if mailer = self._mailer_class
mailer
else
tests determine_default_mailer(name)
@@ -65,6 +67,7 @@ def read_fixture(action)
end
included do
+ class_attribute :_mailer_class
setup :initialize_test_deliveries
setup :set_expected_mail
end
@@ -3,8 +3,8 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 1
TINY = 0
- BUILD = "beta"
+ PRE = "beta"
- STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
end
View
@@ -1,5 +1,7 @@
*Rails 3.1.0 (unreleased)*
+* Added config.action_controller.include_all_helpers. By default 'helper :all' is done in ActionController::Base, which includes all the helpers by default. Setting include_all_helpers to false will result in including only application_helper and helper corresponding to controller (like foo_helper for foo_controller). [Piotr Sarnacki]
+
* Added a convenience idiom to generate HTML5 data-* attributes in tag helpers from a :data hash of options:
tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago IL)})
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 0.5.3')
- s.add_dependency('builder', '~> 2.1.2')
+ s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.4.2')
s.add_dependency('rack', '~> 1.2.1')
s.add_dependency('rack-test', '~> 0.5.6')
@@ -119,7 +119,7 @@ def _prefix
controller_path
end
- private
+ private
# This method should return a hash with assigns.
# You can overwrite this configuration per controller.
@@ -128,7 +128,7 @@ def view_assigns
hash = {}
variables = instance_variable_names
variables -= protected_instance_variables if respond_to?(:protected_instance_variables)
- variables.each { |name| hash[name.to_s[1..-1]] = instance_variable_get(name) }
+ variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
hash
end
@@ -138,13 +138,13 @@ def _normalize_args(action=nil, options={})
case action
when NilClass
when Hash
- options, action = action, nil
+ options = action
when String, Symbol
action = action.to_s
key = action.include?(?/) ? :file : :action
options[key] = action
else
- options.merge!(:partial => action)
+ options[:partial] = action
end
options
@@ -53,8 +53,9 @@ module Helpers
include AbstractController::Helpers
included do
- config_accessor :helpers_path
+ config_accessor :helpers_path, :include_all_helpers
self.helpers_path ||= []
+ self.include_all_helpers = true
end
module ClassMethods
@@ -20,36 +20,35 @@ def render(*args) #:nodoc:
private
- # Normalize arguments by catching blocks and setting them on :update.
- def _normalize_args(action=nil, options={}, &blk) #:nodoc:
- options = super
- options[:update] = blk if block_given?
- options
- end
-
- # Normalize both text and status options.
- def _normalize_options(options) #:nodoc:
- if options.key?(:text) && options[:text].respond_to?(:to_text)
- options[:text] = options[:text].to_text
- end
+ # Normalize arguments by catching blocks and setting them on :update.
+ def _normalize_args(action=nil, options={}, &blk) #:nodoc:
+ options = super
+ options[:update] = blk if block_given?
+ options
+ end
- if options[:status]
- options[:status] = Rack::Utils.status_code(options[:status])
- end
+ # Normalize both text and status options.
+ def _normalize_options(options) #:nodoc:
+ if options.key?(:text) && options[:text].respond_to?(:to_text)
+ options[:text] = options[:text].to_text
+ end
- super
+ if options[:status]
+ options[:status] = Rack::Utils.status_code(options[:status])
end
- # Process controller specific options, as status, content-type and location.
- def _process_options(options) #:nodoc:
- status, content_type, location = options.values_at(:status, :content_type, :location)
+ super
+ end
- self.status = status if status
- self.content_type = content_type if content_type
- self.headers["Location"] = url_for(location) if location
+ # Process controller specific options, as status, content-type and location.
+ def _process_options(options) #:nodoc:
+ status, content_type, location = options.values_at(:status, :content_type, :location)
- super
- end
+ self.status = status if status
+ self.content_type = content_type if content_type
+ self.headers["Location"] = url_for(location) if location
+ super
+ end
end
end
@@ -13,7 +13,9 @@ def self.with(app)
end
klass.helpers_path = paths
- klass.helper :all if klass.superclass == ActionController::Base
+ if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
+ klass.helper :all
+ end
end
end
end
@@ -1,6 +1,7 @@
require 'rack/session/abstract/id'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/to_query'
+require 'active_support/core_ext/class/attribute'
module ActionController
module TemplateAssertions
@@ -325,11 +326,11 @@ def tests(controller_class)
def controller_class=(new_class)
prepare_controller_class(new_class) if new_class
- write_inheritable_attribute(:controller_class, new_class)
+ self._controller_class = new_class
end
def controller_class
- if current_controller_class = read_inheritable_attribute(:controller_class)
+ if current_controller_class = self._controller_class
current_controller_class
else
self.controller_class = determine_default_controller_class(name)
@@ -442,6 +443,7 @@ def rescue_action_in_public!
included do
include ActionController::TemplateAssertions
include ActionDispatch::Assertions
+ class_attribute :_controller_class
setup :setup_controller_request_and_response
end
@@ -1,5 +1,5 @@
require 'set'
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
module HTML
class Sanitizer
@@ -60,7 +60,7 @@ def process_node(node, result, options)
class WhiteListSanitizer < Sanitizer
[:protocol_separator, :uri_attributes, :allowed_attributes, :allowed_tags, :allowed_protocols, :bad_tags,
:allowed_css_properties, :allowed_css_keywords, :shorthand_css_properties].each do |attr|
- class_inheritable_accessor attr, :instance_writer => false
+ class_attribute attr, :instance_writer => false
end
# A regular expression of the valid characters used to separate protocols like
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/object/blank'
-
module ActionDispatch
module Http
class UploadedFile
@@ -13,6 +11,14 @@ def initialize(hash)
raise(ArgumentError, ':tempfile is required') unless @tempfile
end
+ def open
+ @tempfile.open
+ end
+
+ def path
+ @tempfile.path
+ end
+
def read(*args)
@tempfile.read(*args)
end
@@ -2,6 +2,7 @@ module ActionDispatch
module Http
module URL
mattr_accessor :tld_length
+ self.tld_length = 1
# Returns the complete URL used for this request.
def url
@@ -67,7 +68,7 @@ def server_port
# Returns the \domain part of a \host, such as "rubyonrails.org" in "www.rubyonrails.org". You can specify
# a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".
- def domain(tld_length = 1)
+ def domain(tld_length = @@tld_length)
return nil unless named_host?(host)
host.split('.').last(1 + tld_length).join('.')
@@ -66,6 +66,18 @@ def normalize_options!
end
@options.merge!(default_controller_and_action(to_shorthand))
+
+ requirements.each do |name, requirement|
+ # segment_keys.include?(k.to_s) || k == :controller
+ next unless Regexp === requirement && !constraints[name]
+
+ if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
+ raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
+ end
+ if requirement.multiline?
+ raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
+ end
+ end
end
# match "account/overview"
@@ -113,15 +125,6 @@ def requirements
@requirements ||= (@options[:constraints].is_a?(Hash) ? @options[:constraints] : {}).tap do |requirements|
requirements.reverse_merge!(@scope[:constraints]) if @scope[:constraints]
@options.each { |k, v| requirements[k] = v if v.is_a?(Regexp) }
-
- requirements.each do |_, requirement|
- if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
- raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
- end
- if requirement.multiline?
- raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
- end
- end
end
end
@@ -164,10 +167,10 @@ def default_controller_and_action(to_shorthand=nil)
raise ArgumentError, "missing :action"
end
- { :controller => controller, :action => action }.tap do |hash|
- hash.delete(:controller) if hash[:controller].blank?
- hash.delete(:action) if hash[:action].blank?
- end
+ hash = {}
+ hash[:controller] = controller unless controller.blank?
+ hash[:action] = action unless action.blank?
+ hash
end
end
Oops, something went wrong.

0 comments on commit 5debc65

Please sign in to comment.