aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile3
-rwxr-xr-xRakefile2
-rw-r--r--actionmailer/MIT-LICENSE2
-rw-r--r--actionmailer/lib/action_mailer.rb2
-rw-r--r--actionpack/MIT-LICENSE2
-rw-r--r--actionpack/lib/action_controller/metal/http_authentication.rb10
-rw-r--r--actionpack/lib/action_controller/test_case.rb61
-rw-r--r--actionpack/lib/action_dispatch.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb2
-rw-r--r--actionpack/lib/action_pack.rb2
-rw-r--r--actionpack/lib/action_view.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/renderer/streaming_template_renderer.rb5
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb2
-rw-r--r--actionpack/test/controller/http_basic_authentication_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_streaming_test.rb2
-rw-r--r--actionpack/test/controller/test_case_test.rb (renamed from actionpack/test/controller/test_test.rb)38
-rw-r--r--actionpack/test/dispatch/request/xml_params_parsing_test.rb8
-rw-r--r--actionpack/test/template/streaming_render_test.rb2
-rw-r--r--activemodel/MIT-LICENSE2
-rw-r--r--activemodel/lib/active_model.rb2
-rw-r--r--activemodel/lib/active_model/mass_assignment_security/permission_set.rb2
-rw-r--r--activerecord/CHANGELOG.md3
-rw-r--r--activerecord/MIT-LICENSE2
-rw-r--r--activerecord/lib/active_record.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb140
-rw-r--r--activerecord/lib/active_record/connection_adapters/connection_specification.rb6
-rw-r--r--activerecord/lib/active_record/fixtures.rb69
-rw-r--r--activerecord/lib/active_record/railties/databases.rake2
-rw-r--r--activerecord/lib/active_record/session_store.rb8
-rw-r--r--activerecord/test/cases/connection_adapters/connection_specification_test.rb12
-rw-r--r--activerecord/test/cases/connection_pool_test.rb83
-rw-r--r--activerecord/test/cases/fixtures_test.rb33
-rw-r--r--activerecord/test/cases/reaper_test.rb81
-rw-r--r--activerecord/test/fixtures/admin/randomly_named_a9.yml7
-rw-r--r--activerecord/test/fixtures/admin/randomly_named_b0.yml7
-rw-r--r--activerecord/test/fixtures/randomly_named_a9.yml7
-rw-r--r--activerecord/test/models/admin/randomly_named_c1.rb3
-rw-r--r--activerecord/test/models/randomly_named_c1.rb3
-rw-r--r--activerecord/test/schema/schema.rb5
-rw-r--r--activeresource/MIT-LICENSE2
-rw-r--r--activeresource/lib/active_resource.rb2
-rw-r--r--activeresource/test/cases/authorization_test.rb16
-rw-r--r--activesupport/MIT-LICENSE2
-rw-r--r--activesupport/lib/active_support.rb3
-rw-r--r--activesupport/lib/active_support/base64.rb18
-rw-r--r--activesupport/lib/active_support/callbacks.rb19
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/kernel/debugger.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/range/include_range.rb4
-rw-r--r--activesupport/lib/active_support/duration.rb1
-rw-r--r--activesupport/lib/active_support/json/encoding.rb4
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb6
-rw-r--r--activesupport/lib/active_support/message_verifier.rb6
-rw-r--r--activesupport/lib/active_support/test_case.rb12
-rw-r--r--activesupport/lib/active_support/xml_mini.rb9
-rw-r--r--activesupport/test/core_ext/base64_ext_test.rb10
-rw-r--r--activesupport/test/core_ext/range_ext_test.rb4
-rw-r--r--activesupport/test/json/encoding_test.rb4
-rw-r--r--activesupport/test/message_encryptor_test.rb6
-rw-r--r--railties/CHANGELOG.md6
-rw-r--r--railties/MIT-LICENSE2
-rw-r--r--railties/guides/code/getting_started/README.rdoc10
-rw-r--r--railties/guides/code/getting_started/config/application.rb4
-rw-r--r--railties/guides/rails_guides/helpers.rb12
-rw-r--r--railties/guides/source/3_2_release_notes.textile2
-rw-r--r--railties/guides/source/api_documentation_guidelines.textile7
-rw-r--r--railties/guides/source/asset_pipeline.textile28
-rw-r--r--railties/guides/source/command_line.textile16
-rw-r--r--railties/guides/source/configuring.textile10
-rw-r--r--railties/guides/source/documents.yaml2
-rw-r--r--railties/guides/source/generators.textile16
-rw-r--r--railties/guides/source/getting_started.textile8
-rw-r--r--railties/guides/source/layout.html.erb55
-rw-r--r--railties/guides/source/plugins.textile35
-rw-r--r--railties/guides/source/rails_application_templates.textile27
-rw-r--r--railties/guides/source/testing.textile1
-rw-r--r--railties/lib/rails/application.rb5
-rw-r--r--railties/lib/rails/application/bootstrap.rb2
-rw-r--r--railties/lib/rails/application/configuration.rb2
-rw-r--r--railties/lib/rails/application/railties.rb2
-rw-r--r--railties/lib/rails/commands.rb2
-rw-r--r--railties/lib/rails/commands/plugin.rb544
-rw-r--r--railties/lib/rails/engine/configuration.rb2
-rw-r--r--railties/lib/rails/engine/railties.rb9
-rw-r--r--railties/lib/rails/generators.rb11
-rw-r--r--railties/lib/rails/generators/actions.rb34
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb5
-rw-r--r--railties/lib/rails/generators/rails/app/templates/README10
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb4
-rw-r--r--railties/lib/rails/plugin.rb91
-rw-r--r--railties/lib/rails/rack/debugger.rb2
-rw-r--r--railties/lib/rails/railtie.rb8
-rw-r--r--railties/lib/rails/tasks/documentation.rake40
-rw-r--r--railties/lib/rails/test_unit/testing.rake12
-rw-r--r--railties/test/application/paths_test.rb1
-rw-r--r--railties/test/generators/actions_test.rb37
-rw-r--r--railties/test/generators/app_generator_test.rb1
-rw-r--r--railties/test/isolation/abstract_unit.rb14
-rw-r--r--railties/test/railties/engine_test.rb40
-rw-r--r--railties/test/railties/plugin_ordering_test.rb76
-rw-r--r--railties/test/railties/plugin_test.rb123
-rw-r--r--railties/test/railties/shared_tests.rb13
104 files changed, 597 insertions, 1500 deletions
diff --git a/Gemfile b/Gemfile
index 1284c60531..76be75e872 100644
--- a/Gemfile
+++ b/Gemfile
@@ -43,7 +43,8 @@ platforms :mri_18 do
end
# Add your own local bundler stuff
-instance_eval File.read '.Gemfile' if File.exists? '.Gemfile'
+local_gemfile = File.dirname(__FILE__) + "/.Gemfile"
+instance_eval File.read local_gemfile if File.exists? local_gemfile
platforms :mri do
group :test do
diff --git a/Rakefile b/Rakefile
index 831187d5f5..03b8a952c3 100755
--- a/Rakefile
+++ b/Rakefile
@@ -94,7 +94,7 @@ RDoc::Task.new do |rdoc|
rdoc.options << '-f' << 'sdoc'
rdoc.options << '-T' << 'rails'
- rdoc.options << '-c' << 'utf-8'
+ rdoc.options << '-e' << 'UTF-8'
rdoc.options << '-g' # SDoc flag, link methods to GitHub
rdoc.options << '-m' << RDOC_MAIN
diff --git a/actionmailer/MIT-LICENSE b/actionmailer/MIT-LICENSE
index 7ad1051066..810daf856c 100644
--- a/actionmailer/MIT-LICENSE
+++ b/actionmailer/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2011 David Heinemeier Hansson
+Copyright (c) 2004-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb
index 2ac4f3f681..1045dd58ef 100644
--- a/actionmailer/lib/action_mailer.rb
+++ b/actionmailer/lib/action_mailer.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/actionpack/MIT-LICENSE b/actionpack/MIT-LICENSE
index 7ad1051066..810daf856c 100644
--- a/actionpack/MIT-LICENSE
+++ b/actionpack/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2011 David Heinemeier Hansson
+Copyright (c) 2004-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb
index 594ba7a7b8..4972c6bede 100644
--- a/actionpack/lib/action_controller/metal/http_authentication.rb
+++ b/actionpack/lib/action_controller/metal/http_authentication.rb
@@ -1,4 +1,4 @@
-require 'active_support/base64'
+require 'base64'
require 'active_support/core_ext/object/blank'
module ActionController
@@ -141,11 +141,11 @@ module ActionController
end
def decode_credentials(request)
- ActiveSupport::Base64.decode64(request.authorization.split(' ', 2).last || '')
+ ::Base64.decode64(request.authorization.split(' ', 2).last || '')
end
def encode_credentials(user_name, password)
- "Basic #{ActiveSupport::Base64.strict_encode64("#{user_name}:#{password}")}"
+ "Basic #{::Base64.strict_encode64("#{user_name}:#{password}")}"
end
def authentication_request(controller, realm)
@@ -289,7 +289,7 @@ module ActionController
t = time.to_i
hashed = [t, secret_key]
digest = ::Digest::MD5.hexdigest(hashed.join(":"))
- ActiveSupport::Base64.strict_encode64("#{t}:#{digest}")
+ ::Base64.strict_encode64("#{t}:#{digest}")
end
# Might want a shorter timeout depending on whether the request
@@ -298,7 +298,7 @@ module ActionController
# allow a user to use new nonce without prompting user again for their
# username and password.
def validate_nonce(secret_key, request, value, seconds_to_timeout=5*60)
- t = ActiveSupport::Base64.decode64(value).split(":").first.to_i
+ t = ::Base64.decode64(value).split(":").first.to_i
nonce(secret_key, t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout
end
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 7470897659..ac2e0fcb83 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -252,6 +252,12 @@ module ActionController
# end
# end
#
+ # You can also send a real document in the simulated HTTP request.
+ #
+ # def test_create
+ # json = {:book => { :title => "Love Hina" }}.to_json
+ # post :create, json
+ #
# == Special instance variables
#
# ActionController::TestCase will also automatically provide the following instance
@@ -376,23 +382,23 @@ module ActionController
end
# Executes a request simulating GET HTTP method and set/volley the response
- def get(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "GET")
+ def get(action, *args)
+ process(action, "GET", *args)
end
# Executes a request simulating POST HTTP method and set/volley the response
- def post(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "POST")
+ def post(action, *args)
+ process(action, "POST", *args)
end
# Executes a request simulating PUT HTTP method and set/volley the response
- def put(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "PUT")
+ def put(action, *args)
+ process(action, "PUT", *args)
end
# Executes a request simulating DELETE HTTP method and set/volley the response
- def delete(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "DELETE")
+ def delete(action, *args)
+ process(action, "DELETE", *args)
end
# Executes a request simulating HEAD HTTP method and set/volley the response
@@ -423,19 +429,20 @@ module ActionController
end
end
- def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
+ def process(action, http_method = 'GET', *args)
+ check_required_ivars
+ http_method, args = handle_old_process_api(http_method, args)
+
+ if args.first.is_a?(String)
+ @request.env['RAW_POST_DATA'] = args.shift
+ end
+
+ parameters, session, flash = args
+
# Ensure that numbers and symbols passed as params are converted to
# proper params, as is the case when engaging rack.
parameters = paramify_values(parameters)
- # Sanity check for required instance variables so we can give an
- # understandable error message.
- %w(@routes @controller @request @response).each do |iv_name|
- if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
- raise "#{iv_name} is nil: make sure you set it in your test's setup method."
- end
- end
-
@request.recycle!
@response.recycle!
@controller.response_body = nil
@@ -496,6 +503,26 @@ module ActionController
end
private
+ def check_required_ivars
+ # Sanity check for required instance variables so we can give an
+ # understandable error message.
+ %w(@routes @controller @request @response).each do |iv_name|
+ if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
+ raise "#{iv_name} is nil: make sure you set it in your test's setup method."
+ end
+ end
+ end
+
+ def handle_old_process_api(http_method, args)
+ # 4.0: Remove this method.
+ if http_method.is_a?(Hash)
+ ActiveSupport::Deprecation.warn("TestCase#process now expects the HTTP method as second argument: process(action, http_method, params, session, flash)")
+ args.unshift(http_method)
+ http_method = args.last.is_a?(String) ? args.last : "GET"
+ end
+
+ [http_method, args]
+ end
def build_request_uri(action, parameters)
unless @request.env["PATH_INFO"]
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb
index 070ffbdceb..a9542a7d1b 100644
--- a/actionpack/lib/action_dispatch.rb
+++ b/actionpack/lib/action_dispatch.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index c60e26983d..10b3e212e6 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -276,7 +276,7 @@ module ActionDispatch
@prepend.each { |blk| eval_block(blk) }
end
- def install_helpers(destinations = [ActionController::Base, ActionView::Base])
+ def install_helpers(destinations)
destinations.each { |d| d.module_eval { include Helpers } }
named_routes.install(destinations)
end
diff --git a/actionpack/lib/action_pack.rb b/actionpack/lib/action_pack.rb
index 914b13dbfb..39c7faf740 100644
--- a/actionpack/lib/action_pack.rb
+++ b/actionpack/lib/action_pack.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index c24109a547..349a3fcc6e 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 5a301ca9b1..d46ee4faef 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1270,7 +1270,7 @@ module ActionView
@multipart = nil
end
- (field_helpers - %w(label check_box radio_button fields_for hidden_field file_field)).each do |selector|
+ (field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{selector}(method, options = {}) # def text_field(method, options = {})
@template.send( # @template.send(
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index bb753ae27a..e3ad96ec1b 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -47,7 +47,7 @@ module ActionView
# <% end -%>
# # => <form action="/posts" method="post"><div><input type="submit" name="submit" value="Save" /></div></form>
#
- # <%= form_tag('/posts', :remote => true) %>
+ # <%= form_tag('/posts', :remote => true) %>
# # => <form action="/posts" method="post" data-remote="true">
#
# form_tag('http://far.away.com/form', :authenticity_token => false)
@@ -577,7 +577,7 @@ module ActionView
#
# ==== Examples
# number_field_tag 'quantity', nil, :in => 1...10
- # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
+ # # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
def number_field_tag(name, value = nil, options = {})
options = options.stringify_keys
options["type"] ||= "number"
diff --git a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb b/actionpack/lib/action_view/renderer/streaming_template_renderer.rb
index 1ccf5a8ddb..f46aabd2be 100644
--- a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/streaming_template_renderer.rb
@@ -1,7 +1,4 @@
-# 1.9 ships with Fibers but we need to require the extra
-# methods explicitly. We only load those extra methods if
-# Fiber is available in the first place.
-require 'fiber' if defined?(Fiber)
+require 'fiber'
module ActionView
# == TODO
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 5252e43c25..fab70c71d6 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -165,7 +165,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
match ':controller/:action'
end
- set.install_helpers
+ set.install_helpers([ActionController::Base, ActionView::Base])
process :redirect_to_named_route
assert_redirected_to 'http://test.host/route_one'
diff --git a/actionpack/test/controller/http_basic_authentication_test.rb b/actionpack/test/controller/http_basic_authentication_test.rb
index 364e96d4f6..7286b249c7 100644
--- a/actionpack/test/controller/http_basic_authentication_test.rb
+++ b/actionpack/test/controller/http_basic_authentication_test.rb
@@ -132,6 +132,6 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
private
def encode_credentials(username, password)
- "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
+ "Basic #{::Base64.encode64("#{username}:#{password}")}"
end
end
diff --git a/actionpack/test/controller/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb
index 1a17e24914..1532bd5c98 100644
--- a/actionpack/test/controller/new_base/render_streaming_test.rb
+++ b/actionpack/test/controller/new_base/render_streaming_test.rb
@@ -111,4 +111,4 @@ module RenderStreaming
assert_equal cache, headers["Cache-Control"]
end
end
-end if defined?(Fiber)
+end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_case_test.rb
index b3b7ece518..73b860ac18 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -171,6 +171,21 @@ XML
assert_equal params.to_query, @response.body
end
+
+ def test_document_body_and_params_with_post
+ post :test_params, :id => 1
+ assert_equal("{\"id\"=>\"1\", \"controller\"=>\"test_test/test\", \"action\"=>\"test_params\"}", @response.body)
+ end
+
+ def test_document_body_with_post
+ post :render_body, "document body"
+ assert_equal "document body", @response.body
+ end
+
+ def test_document_body_with_put
+ put :render_body, "document body"
+ assert_equal "document body", @response.body
+ end
def test_process_without_flash
process :set_flash
@@ -178,12 +193,12 @@ XML
end
def test_process_with_flash
- process :set_flash, nil, nil, { "test" => "value" }
+ process :set_flash, "GET", nil, nil, { "test" => "value" }
assert_equal '>value<', flash['test']
end
def test_process_with_flash_now
- process :set_flash_now, nil, nil, { "test_now" => "value_now" }
+ process :set_flash_now, "GET", nil, nil, { "test_now" => "value_now" }
assert_equal '>value_now<', flash['test_now']
end
@@ -196,7 +211,7 @@ XML
end
def test_process_with_session_arg
- process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' }
+ process :no_op, "GET", nil, { 'string' => 'value1', :symbol => 'value2' }
assert_equal 'value1', session['string']
assert_equal 'value1', session[:string]
assert_equal 'value2', session['symbol']
@@ -227,18 +242,25 @@ XML
end
def test_process_with_request_uri_with_params
- process :test_uri, :id => 7
+ process :test_uri, "GET", :id => 7
assert_equal "/test_test/test/test_uri/7", @response.body
end
+
+ def test_process_with_old_api
+ assert_deprecated do
+ process :test_uri, :id => 7
+ assert_equal "/test_test/test/test_uri/7", @response.body
+ end
+ end
def test_process_with_request_uri_with_params_with_explicit_uri
@request.env['PATH_INFO'] = "/explicit/uri"
- process :test_uri, :id => 7
+ process :test_uri, "GET", :id => 7
assert_equal "/explicit/uri", @response.body
end
def test_process_with_query_string
- process :test_query_string, :q => 'test'
+ process :test_query_string, "GET", :q => 'test'
assert_equal "q=test", @response.body
end
@@ -250,9 +272,9 @@ XML
end
def test_multiple_calls
- process :test_only_one_param, :left => true
+ process :test_only_one_param, "GET", :left => true
assert_equal "OK", @response.body
- process :test_only_one_param, :right => true
+ process :test_only_one_param, "GET", :right => true
assert_equal "OK", @response.body
end
diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
index d8fa751548..0984f00066 100644
--- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
@@ -41,7 +41,7 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
test "parses single file" do
with_test_routing do
- xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar></person>"
+ xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{::Base64.encode64('ABC')}</avatar></person>"
post "/parse", xml, default_headers
assert_response :ok
@@ -55,7 +55,7 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
test "logs error if parsing unsuccessful" do
with_test_routing do
output = StringIO.new
- xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar></pineapple>"
+ xml = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{::Base64.encode64('ABC')}</avatar></pineapple>"
post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => Logger.new(output))
assert_response :error
output.rewind && err = output.read
@@ -80,8 +80,8 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
<person>
<name>David</name>
<avatars>
- <avatar type='file' name='me.jpg' content_type='image/jpg'>#{ActiveSupport::Base64.encode64('ABC')}</avatar>
- <avatar type='file' name='you.gif' content_type='image/gif'>#{ActiveSupport::Base64.encode64('DEF')}</avatar>
+ <avatar type='file' name='me.jpg' content_type='image/jpg'>#{::Base64.encode64('ABC')}</avatar>
+ <avatar type='file' name='you.gif' content_type='image/gif'>#{::Base64.encode64('DEF')}</avatar>
</avatars>
</person>
end_body
diff --git a/actionpack/test/template/streaming_render_test.rb b/actionpack/test/template/streaming_render_test.rb
index 4d01352b43..520bf3a824 100644
--- a/actionpack/test/template/streaming_render_test.rb
+++ b/actionpack/test/template/streaming_render_test.rb
@@ -106,4 +106,4 @@ class FiberedTest < ActiveSupport::TestCase
buffered_render(:template => "test/nested_streaming", :layout => "layouts/streaming")
end
-end if defined?(Fiber)
+end
diff --git a/activemodel/MIT-LICENSE b/activemodel/MIT-LICENSE
index 7ad1051066..810daf856c 100644
--- a/activemodel/MIT-LICENSE
+++ b/activemodel/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2011 David Heinemeier Hansson
+Copyright (c) 2004-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb
index 9fc308375f..85514e63fd 100644
--- a/activemodel/lib/active_model.rb
+++ b/activemodel/lib/active_model.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/activemodel/lib/active_model/mass_assignment_security/permission_set.rb b/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
index a1fcdf1a38..9661349503 100644
--- a/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
+++ b/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
@@ -13,7 +13,7 @@ module ActiveModel
end
def deny?(key)
- raise NotImplementedError, "#deny?(key) suppose to be overwritten"
+ raise NotImplementedError, "#deny?(key) supposed to be overwritten"
end
protected
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 2c8ec3d4d1..c4feabfb5f 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,8 @@
## Rails 4.0.0 (unreleased) ##
+* Connections *must* be closed at the end of a thread. If not, your
+ connection pool can fill and an exception will be raised.
+
* Added the `ActiveRecord::Model` module which can be included in a
class as an alternative to inheriting from `ActiveRecord::Base`:
diff --git a/activerecord/MIT-LICENSE b/activerecord/MIT-LICENSE
index c73d1af096..03bde18130 100644
--- a/activerecord/MIT-LICENSE
+++ b/activerecord/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2011 David Heinemeier Hansson
+Copyright (c) 2004-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 4f194cb6cf..78e958442f 100644
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2011 David Heinemeier Hansson
+# Copyright (c) 2004-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index ea738cb305..b8f99adc22 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -9,6 +9,13 @@ module ActiveRecord
class ConnectionTimeoutError < ConnectionNotEstablished
end
+ # Raised when a connection pool is full and another connection is requested
+ class PoolFullError < ConnectionNotEstablished
+ def initialize size, timeout
+ super("Connection pool of size #{size} and timeout #{timeout}s is full")
+ end
+ end
+
module ConnectionAdapters
# Connection pool base class for managing Active Record database
# connections.
@@ -57,10 +64,35 @@ module ActiveRecord
# * +wait_timeout+: number of seconds to block and wait for a connection
# before giving up and raising a timeout error (default 5 seconds).
class ConnectionPool
+ # Every +frequency+ seconds, the reaper will call +reap+ on +pool+.
+ # A reaper instantiated with a nil frequency will never reap the
+ # connection pool.
+ #
+ # Configure the frequency by setting "reaping_frequency" in your
+ # database yaml file.
+ class Reaper
+ attr_reader :pool, :frequency
+
+ def initialize(pool, frequency)
+ @pool = pool
+ @frequency = frequency
+ end
+
+ def run
+ return unless frequency
+ Thread.new(frequency, pool) { |t, p|
+ while true
+ sleep t
+ p.reap
+ end
+ }
+ end
+ end
+
include MonitorMixin
- attr_accessor :automatic_reconnect
- attr_reader :spec, :connections
+ attr_accessor :automatic_reconnect, :timeout
+ attr_reader :spec, :connections, :size, :reaper
# Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification
# object which describes database connection information (e.g. adapter,
@@ -76,8 +108,9 @@ module ActiveRecord
# The cache of reserved connections mapped to threads
@reserved_connections = {}
- @queue = new_cond
@timeout = spec.config[:wait_timeout] || 5
+ @reaper = Reaper.new self, spec.config[:reaping_frequency]
+ @reaper.run
# default max pool size to 5
@size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
@@ -155,76 +188,47 @@ module ActiveRecord
# associated with stale threads.
def verify_active_connections! #:nodoc:
synchronize do
- clear_stale_cached_connections!
@connections.each do |connection|
connection.verify!
end
end
end
- # Return any checked-out connections back to the pool by threads that
- # are no longer alive.
- def clear_stale_cached_connections!
- keys = @reserved_connections.keys - Thread.list.find_all { |t|
- t.alive?
- }.map { |thread| thread.object_id }
- keys.each do |key|
- conn = @reserved_connections[key]
- ActiveSupport::Deprecation.warn(<<-eowarn) if conn.in_use?
-Database connections will not be closed automatically, please close your
-database connection at the end of the thread by calling `close` on your
-connection. For example: ActiveRecord::Base.connection.close
- eowarn
- checkin conn
- @reserved_connections.delete(key)
- end
+ def clear_stale_cached_connections! # :nodoc:
end
+ deprecate :clear_stale_cached_connections!
# Check-out a database connection from the pool, indicating that you want
# to use it. You should call #checkin when you no longer need this.
#
- # This is done by either returning an existing connection, or by creating
- # a new connection. If the maximum number of connections for this pool has
- # already been reached, but the pool is empty (i.e. they're all being used),
- # then this method will wait until a thread has checked in a connection.
- # The wait time is bounded however: if no connection can be checked out
- # within the timeout specified for this pool, then a ConnectionTimeoutError
- # exception will be raised.
+ # This is done by either returning and leasing existing connection, or by
+ # creating a new connection and leasing it.
+ #
+ # If all connections are leased and the pool is at capacity (meaning the
+ # number of currently leased connections is greater than or equal to the
+ # size limit set), an ActiveRecord::PoolFullError exception will be raised.
#
# Returns: an AbstractAdapter object.
#
# Raises:
- # - ConnectionTimeoutError: no connection can be obtained from the pool
- # within the timeout period.
+ # - PoolFullError: no connection can be obtained from the pool.
def checkout
# Checkout an available connection
synchronize do
- loop do
- conn = @connections.find { |c| c.lease }
-
- unless conn
- if @connections.size < @size
- conn = checkout_new_connection
- conn.lease
- end
- end
-
- if conn
- checkout_and_verify conn
- return conn
- end
-
- @queue.wait(@timeout)
-
- if(active_connections.size < @connections.size)
- next
- else
- clear_stale_cached_connections!
- if @size == active_connections.size
- raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it."
- end
- end
+ # Try to find a connection that hasn't been leased, and lease it
+ conn = connections.find { |c| c.lease }
+
+ # If all connections were leased, and we have room to expand,
+ # create a new connection and lease it.
+ if !conn && connections.size < size
+ conn = checkout_new_connection
+ conn.lease
+ end
+ if conn
+ checkout_and_verify conn
+ else
+ raise PoolFullError.new(size, timeout)
end
end
end
@@ -238,7 +242,33 @@ connection. For example: ActiveRecord::Base.connection.close
synchronize do
conn.run_callbacks :checkin do
conn.expire
- @queue.signal
+ end
+ end
+ end
+
+ # Remove a connection from the connection pool. The connection will
+ # remain open and active but will no longer be managed by this pool.
+ def remove(conn)
+ synchronize do
+ @connections.delete conn
+
+ # FIXME: we might want to store the key on the connection so that removing
+ # from the reserved hash will be a little easier.
+ thread_id = @reserved_connections.keys.find { |k|
+ @reserved_connections[k] == conn
+ }
+ @reserved_connections.delete thread_id if thread_id
+ end
+ end
+
+ # Removes dead connections from the pool. A dead connection can occur
+ # if a programmer forgets to close a connection at the end of a thread
+ # or a thread dies unexpectedly.
+ def reap
+ synchronize do
+ stale = Time.now - @timeout
+ connections.dup.each do |conn|
+ remove conn if conn.in_use? && stale > conn.last_use && !conn.active?
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
index 3e67c3a2b7..8491d42b86 100644
--- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
@@ -3,10 +3,14 @@ module ActiveRecord
class ConnectionSpecification #:nodoc:
attr_reader :config, :adapter_method
- def initialize (config, adapter_method)
+ def initialize(config, adapter_method)
@config, @adapter_method = config, adapter_method
end
+ def initialize_dup(original)
+ @config = original.config.dup
+ end
+
##
# Builds a ConnectionSpecification from user input
class Resolver # :nodoc:
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index deffc7cec5..c59c00f424 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -388,10 +388,15 @@ module ActiveRecord
@@all_cached_fixtures = Hash.new { |h,k| h[k] = {} }
- def self.find_table_name(table_name) # :nodoc:
+ def self.default_fixture_model_name(fixture_name) # :nodoc:
ActiveRecord::Base.pluralize_table_names ?
- table_name.to_s.singularize.camelize :
- table_name.to_s.camelize
+ fixture_name.singularize.camelize :
+ fixture_name.camelize
+ end
+
+ def self.default_fixture_table_name(fixture_name) # :nodoc:
+ "#{ActiveRecord::Base.table_name_prefix}"\
+ "#{fixture_name.tr('/', '_')}#{ActiveRecord::Base.table_name_suffix}".to_sym
end
def self.reset_cache
@@ -441,9 +446,6 @@ module ActiveRecord
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
table_names = [table_names].flatten.map { |n| n.to_s }
- table_names.each { |n|
- class_names[n.tr('/', '_').to_sym] = n.classify if n.include?('/')
- }
# FIXME: Apparently JK uses this.
connection = block_given? ? yield : ActiveRecord::Base.connection
@@ -457,12 +459,12 @@ module ActiveRecord
fixtures_map = {}
fixture_files = files_to_read.map do |path|
- table_name = path.tr '/', '_'
+ fixture_name = path
- fixtures_map[path] = ActiveRecord::Fixtures.new(
+ fixtures_map[fixture_name] = new( # ActiveRecord::Fixtures.new
connection,
- table_name,
- class_names[table_name.to_sym] || table_name.classify,
+ fixture_name,
+ class_names[fixture_name] || default_fixture_model_name(fixture_name),
::File.join(fixtures_directory, path))
end
@@ -506,25 +508,27 @@ module ActiveRecord
attr_reader :table_name, :name, :fixtures, :model_class
- def initialize(connection, table_name, class_name, fixture_path)
+ def initialize(connection, fixture_name, class_name, fixture_path)
@connection = connection
- @table_name = table_name
@fixture_path = fixture_path
- @name = table_name # preserve fixture base name
+ @name = fixture_name
@class_name = class_name
@fixtures = ActiveSupport::OrderedHash.new
- @table_name = "#{ActiveRecord::Base.table_name_prefix}#{@table_name}#{ActiveRecord::Base.table_name_suffix}"
# Should be an AR::Base type class
if class_name.is_a?(Class)
- @table_name = class_name.table_name
- @connection = class_name.connection
- @model_class = class_name
+ @model_class = class_name
else
- @model_class = class_name.constantize rescue nil
+ @model_class = class_name.constantize rescue nil
end
+ @connection = model_class.connection if model_class && model_class.respond_to?(:connection)
+
+ @table_name = ( model_class.respond_to?(:table_name) ?
+ model_class.table_name :
+ self.class.default_fixture_table_name(fixture_name) )
+
read_fixture_files
end
@@ -723,14 +727,29 @@ module ActiveRecord
self.use_instantiated_fixtures = false
self.pre_loaded_fixtures = false
- self.fixture_class_names = Hash.new do |h, table_name|
- h[table_name] = ActiveRecord::Fixtures.find_table_name(table_name)
+ self.fixture_class_names = Hash.new do |h, fixture_name|
+ h[fixture_name] = ActiveRecord::Fixtures.default_fixture_model_name(fixture_name)
end
end
module ClassMethods
+ # Sets the model class for a fixture when the class name cannot be inferred from the fixture name.
+ #
+ # Examples:
+ #
+ # set_fixture_class :some_fixture => SomeModel,
+ # 'namespaced/fixture' => Another::Model
+ #
+ # The keys must be the fixture names, that coincide with the short paths to the fixture files.
+ #--
+ # It is also possible to pass the class name instead of the class:
+ # set_fixture_class 'some_fixture' => 'SomeModel'
+ # I think this option is redundant, i propose to deprecate it.
+ # Isn't it easier to always pass the class itself?
+ # (2011-12-20 alexeymuranov)
+ #++
def set_fixture_class(class_names = {})
- self.fixture_class_names = self.fixture_class_names.merge(class_names)
+ self.fixture_class_names = self.fixture_class_names.merge(class_names.stringify_keys)
end
def fixtures(*fixture_names)
@@ -770,9 +789,9 @@ module ActiveRecord
fixture_names = Array.wrap(fixture_names || fixture_table_names)
methods = Module.new do
fixture_names.each do |fixture_name|
- fixture_name = fixture_name.to_s.tr('./', '_')
+ accessor_name = fixture_name.tr('/', '_').to_sym
- define_method(fixture_name) do |*fixtures|
+ define_method(accessor_name) do |*fixtures|
force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
@fixture_cache[fixture_name] ||= {}
@@ -785,13 +804,13 @@ module ActiveRecord
@fixture_cache[fixture_name][fixture] ||= @loaded_fixtures[fixture_name][fixture.to_s].find
end
else
- raise StandardError, "No fixture with name '#{fixture}' found for table '#{fixture_name}'"
+ raise StandardError, "No entry named '#{fixture}' found for fixture collection '#{fixture_name}'"
end
end
instances.size == 1 ? instances.first : instances
end
- private fixture_name
+ private accessor_name
end
end
include methods
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 180424641a..822b51e838 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -539,7 +539,7 @@ end
namespace :railties do
namespace :install do
- # desc "Copies missing migrations from Railties (e.g. plugins, engines). You can specify Railties to use with FROM=railtie1,railtie2"
+ # desc "Copies missing migrations from Railties (e.g. engines). You can specify Railties to use with FROM=railtie1,railtie2"
task :migrations => :'db:load_config' do
to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map {|n| n.strip }
railties = ActiveSupport::OrderedHash.new
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb
index e3bbd06f7e..1029bed064 100644
--- a/activerecord/lib/active_record/session_store.rb
+++ b/activerecord/lib/active_record/session_store.rb
@@ -51,11 +51,11 @@ module ActiveRecord
class SessionStore < ActionDispatch::Session::AbstractStore
module ClassMethods # :nodoc:
def marshal(data)
- ActiveSupport::Base64.encode64(Marshal.dump(data)) if data
+ ::Base64.encode64(Marshal.dump(data)) if data
end
def unmarshal(data)
- Marshal.load(ActiveSupport::Base64.decode64(data)) if data
+ Marshal.load(::Base64.decode64(data)) if data
end
def drop_table!
@@ -169,11 +169,11 @@ module ActiveRecord
# are implemented as class methods that you may override. By default,
# marshaling data is
#
- # ActiveSupport::Base64.encode64(Marshal.dump(data))
+ # ::Base64.encode64(Marshal.dump(data))
#
# and unmarshaling data is
#
- # Marshal.load(ActiveSupport::Base64.decode64(data))
+ # Marshal.load(::Base64.decode64(data))
#
# This marshaling behavior is intended to store the widest range of
# binary session data in a +text+ column. For higher performance,
diff --git a/activerecord/test/cases/connection_adapters/connection_specification_test.rb b/activerecord/test/cases/connection_adapters/connection_specification_test.rb
new file mode 100644
index 0000000000..ea2196cda2
--- /dev/null
+++ b/activerecord/test/cases/connection_adapters/connection_specification_test.rb
@@ -0,0 +1,12 @@
+require "cases/helper"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class ConnectionSpecificationTest < ActiveRecord::TestCase
+ def test_dup_deep_copy_config
+ spec = ConnectionSpecification.new({ :a => :b }, "bar")
+ assert_not_equal(spec.config.object_id, spec.dup.config.object_id)
+ end
+ end
+ end
+end
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
index d170a13b23..26842d3998 100644
--- a/activerecord/test/cases/connection_pool_test.rb
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -4,6 +4,8 @@ module ActiveRecord
module ConnectionAdapters
class ConnectionPoolTest < ActiveRecord::TestCase
def setup
+ super
+
# Keep a duplicate pool so we do not bother others
@pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec
@@ -18,6 +20,70 @@ module ActiveRecord
end
end
+ def teardown
+ super
+ @pool.connections.each(&:close)
+ end
+
+ def test_full_pool_exception
+ assert_raises(PoolFullError) do
+ (@pool.size + 1).times do
+ @pool.checkout
+ end
+ end
+ end
+
+ def test_reap_and_active
+ @pool.checkout
+ @pool.checkout
+ @pool.checkout
+ @pool.timeout = 0
+
+ connections = @pool.connections.dup
+
+ @pool.reap
+
+ assert_equal connections.length, @pool.connections.length
+ end
+
+ def test_reap_inactive
+ @pool.checkout
+ @pool.checkout
+ @pool.checkout
+ @pool.timeout = 0
+
+ connections = @pool.connections.dup
+ connections.each do |conn|
+ conn.extend(Module.new { def active?; false; end; })
+ end
+
+ @pool.reap
+
+ assert_equal 0, @pool.connections.length
+ ensure
+ connections.each(&:close)
+ end
+
+ def test_remove_connection
+ conn = @pool.checkout
+ assert conn.in_use?
+
+ length = @pool.connections.length
+ @pool.remove conn
+ assert conn.in_use?
+ assert_equal(length - 1, @pool.connections.length)
+ ensure
+ conn.close
+ end
+
+ def test_remove_connection_for_thread
+ conn = @pool.connection
+ @pool.remove conn
+ assert_not_equal(conn, @pool.connection)
+ ensure
+ conn.close
+ end
+
def test_active_connection?
assert !@pool.active_connection?
assert @pool.connection
@@ -35,27 +101,16 @@ module ActiveRecord
threads << Thread.new(i) do |pool_count|
connection = pool.connection
assert_not_nil connection
+ connection.close
end
end
- threads.each {|t| t.join}
+ threads.each(&:join)
Thread.new do
- threads.each do |t|
- thread_ids = pool.instance_variable_get(:@reserved_connections).keys
- assert thread_ids.include?(t.object_id)
- end
-
- assert_deprecated do
- pool.connection
- end
- threads.each do |t|
- thread_ids = pool.instance_variable_get(:@reserved_connections).keys
- assert !thread_ids.include?(t.object_id)
- end
+ assert pool.connection
pool.connection.close
end.join
-
end
def test_automatic_reconnect=
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index ba09df4b7d..859bb7992b 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -1,6 +1,7 @@
require 'cases/helper'
require 'models/admin'
require 'models/admin/account'
+require 'models/admin/randomly_named_c1'
require 'models/admin/user'
require 'models/binary'
require 'models/book'
@@ -14,6 +15,7 @@ require 'models/matey'
require 'models/parrot'
require 'models/pirate'
require 'models/post'
+require 'models/randomly_named_c1'
require 'models/reply'
require 'models/ship'
require 'models/task'
@@ -745,3 +747,34 @@ class FixtureLoadingTest < ActiveRecord::TestCase
ActiveRecord::TestCase.try_to_load_dependency(:works_out_fine)
end
end
+
+class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
+ ActiveRecord::Fixtures.reset_cache
+
+ set_fixture_class :randomly_named_a9 =>
+ ClassNameThatDoesNotFollowCONVENTIONS,
+ :'admin/randomly_named_a9' =>
+ Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ 'admin/randomly_named_b0' =>
+ Admin::ClassNameThatDoesNotFollowCONVENTIONS
+
+ fixtures :randomly_named_a9, 'admin/randomly_named_a9',
+ :'admin/randomly_named_b0'
+
+ def test_named_accessor_for_randomly_named_fixture_and_class
+ assert_kind_of ClassNameThatDoesNotFollowCONVENTIONS,
+ randomly_named_a9(:first_instance)
+ end
+
+ def test_named_accessor_for_randomly_named_namespaced_fixture_and_class
+ assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ admin_randomly_named_a9(:first_instance)
+ assert_kind_of Admin::ClassNameThatDoesNotFollowCONVENTIONS,
+ admin_randomly_named_b0(:second_instance)
+ end
+
+ def test_table_name_is_defined_in_the_model
+ assert_equal :randomly_named_table, ActiveRecord::Fixtures::all_loaded_fixtures["admin/randomly_named_a9"].table_name
+ assert_equal :randomly_named_table, Admin::ClassNameThatDoesNotFollowCONVENTIONS.table_name
+ end
+end
diff --git a/activerecord/test/cases/reaper_test.rb b/activerecord/test/cases/reaper_test.rb
new file mode 100644
index 0000000000..576ab60090
--- /dev/null
+++ b/activerecord/test/cases/reaper_test.rb
@@ -0,0 +1,81 @@
+require "cases/helper"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class ReaperTest < ActiveRecord::TestCase
+ attr_reader :pool
+
+ def setup
+ super
+ @pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec
+ end
+
+ def teardown
+ super
+ @pool.connections.each(&:close)
+ end
+
+ class FakePool
+ attr_reader :reaped
+
+ def initialize
+ @reaped = false
+ end
+
+ def reap
+ @reaped = true
+ end
+ end
+
+ # A reaper with nil time should never reap connections
+ def test_nil_time
+ fp = FakePool.new
+ assert !fp.reaped
+ reaper = ConnectionPool::Reaper.new(fp, nil)
+ reaper.run
+ assert !fp.reaped
+ end
+
+ def test_some_time
+ fp = FakePool.new
+ assert !fp.reaped
+
+ reaper = ConnectionPool::Reaper.new(fp, 0.0001)
+ reaper.run
+ until fp.reaped
+ Thread.pass
+ end
+ assert fp.reaped
+ end
+
+ def test_pool_has_reaper
+ assert pool.reaper
+ end
+
+ def test_reaping_frequency_configuration
+ spec = ActiveRecord::Base.connection_pool.spec.dup
+ spec.config[:reaping_frequency] = 100
+ pool = ConnectionPool.new spec
+ assert_equal 100, pool.reaper.frequency
+ end
+
+ def test_connection_pool_starts_reaper
+ spec = ActiveRecord::Base.connection_pool.spec.dup
+ spec.config[:reaping_frequency] = 0.0001
+
+ pool = ConnectionPool.new spec
+ pool.timeout = 0
+
+ conn = pool.checkout
+ count = pool.connections.length
+
+ conn.extend(Module.new { def active?; false; end; })
+
+ while count == pool.connections.length
+ Thread.pass
+ end
+ assert_equal(count - 1, pool.connections.length)
+ end
+ end
+ end
+end
diff --git a/activerecord/test/fixtures/admin/randomly_named_a9.yml b/activerecord/test/fixtures/admin/randomly_named_a9.yml
new file mode 100644
index 0000000000..bc51c83112
--- /dev/null
+++ b/activerecord/test/fixtures/admin/randomly_named_a9.yml
@@ -0,0 +1,7 @@
+first_instance:
+ some_attribute: AAA
+ another_attribute: 000
+
+second_instance:
+ some_attribute: BBB
+ another_attribute: 999
diff --git a/activerecord/test/fixtures/admin/randomly_named_b0.yml b/activerecord/test/fixtures/admin/randomly_named_b0.yml
new file mode 100644
index 0000000000..bc51c83112
--- /dev/null
+++ b/activerecord/test/fixtures/admin/randomly_named_b0.yml
@@ -0,0 +1,7 @@
+first_instance:
+ some_attribute: AAA
+ another_attribute: 000
+
+second_instance:
+ some_attribute: BBB
+ another_attribute: 999
diff --git a/activerecord/test/fixtures/randomly_named_a9.yml b/activerecord/test/fixtures/randomly_named_a9.yml
new file mode 100644
index 0000000000..bc51c83112
--- /dev/null
+++ b/activerecord/test/fixtures/randomly_named_a9.yml
@@ -0,0 +1,7 @@
+first_instance:
+ some_attribute: AAA
+ another_attribute: 000
+
+second_instance:
+ some_attribute: BBB
+ another_attribute: 999
diff --git a/activerecord/test/models/admin/randomly_named_c1.rb b/activerecord/test/models/admin/randomly_named_c1.rb
new file mode 100644
index 0000000000..2f81d5b831
--- /dev/null
+++ b/activerecord/test/models/admin/randomly_named_c1.rb
@@ -0,0 +1,3 @@
+class Admin::ClassNameThatDoesNotFollowCONVENTIONS < ActiveRecord::Base
+ self.table_name = :randomly_named_table
+end
diff --git a/activerecord/test/models/randomly_named_c1.rb b/activerecord/test/models/randomly_named_c1.rb
new file mode 100644
index 0000000000..18a86c4989
--- /dev/null
+++ b/activerecord/test/models/randomly_named_c1.rb
@@ -0,0 +1,3 @@
+class ClassNameThatDoesNotFollowCONVENTIONS < ActiveRecord::Base
+ self.table_name = :randomly_named_table
+end
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index b06175cd3f..b8f34bb739 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -505,6 +505,11 @@ ActiveRecord::Schema.define do
t.string :type
end
+ create_table :randomly_named_table, :force => true do |t|
+ t.string :some_attribute
+ t.integer :another_attribute
+ end
+
create_table :ratings, :force => true do |t|
t.integer :comment_id
t.integer :value
diff --git a/activeresource/MIT-LICENSE b/activeresource/MIT-LICENSE
index 216b6e5ba0..187e748f83 100644
--- a/activeresource/MIT-LICENSE
+++ b/activeresource/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2006-2011 David Heinemeier Hansson
+Copyright (c) 2006-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/activeresource/lib/active_resource.rb b/activeresource/lib/active_resource.rb
index 0794a1a800..ab06086631 100644
--- a/activeresource/lib/active_resource.rb
+++ b/activeresource/lib/active_resource.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2006-2011 David Heinemeier Hansson
+# Copyright (c) 2006-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/activeresource/test/cases/authorization_test.rb b/activeresource/test/cases/authorization_test.rb
index 17cd9b30fc..dabc40dfe7 100644
--- a/activeresource/test/cases/authorization_test.rb
+++ b/activeresource/test/cases/authorization_test.rb
@@ -53,7 +53,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["david", "test123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_with_username_but_no_password
@@ -62,7 +62,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["david"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_with_password_but_no_username
@@ -71,7 +71,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["", "test123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_with_decoded_credentials_from_url
@@ -80,7 +80,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["my@email.com", "123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["my@email.com", "123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_explicitly_setting_username_and_password
@@ -92,7 +92,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["david", "test123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_explicitly_setting_username_but_no_password
@@ -102,7 +102,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["david"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["david"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_explicitly_setting_password_but_no_username
@@ -112,7 +112,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["", "test123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_if_credentials_supplied_and_auth_type_is_basic
@@ -122,7 +122,7 @@ class AuthorizationTest < Test::Unit::TestCase
authorization = authorization_header["Authorization"].to_s.split
assert_equal "Basic", authorization[0]
- assert_equal ["david", "test123"], ActiveSupport::Base64.decode64(authorization[1]).split(":")[0..1]
+ assert_equal ["david", "test123"], ::Base64.decode64(authorization[1]).split(":")[0..1]
end
def test_authorization_header_if_credentials_supplied_and_auth_type_is_digest
diff --git a/activesupport/MIT-LICENSE b/activesupport/MIT-LICENSE
index 5e8b7a9450..c2bcf1d3e7 100644
--- a/activesupport/MIT-LICENSE
+++ b/activesupport/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2011 David Heinemeier Hansson
+Copyright (c) 2005-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index 9fdc7a3b83..dbf0c25c5c 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2005-2011 David Heinemeier Hansson
+# Copyright (c) 2005-2012 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -52,7 +52,6 @@ module ActiveSupport
# TODO: Narrow this list down
eager_autoload do
autoload :BacktraceCleaner
- autoload :Base64
autoload :BasicObject
autoload :Benchmarkable
autoload :Cache
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb
deleted file mode 100644
index 41a1a3469d..0000000000
--- a/activesupport/lib/active_support/base64.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'base64'
-
-module ActiveSupport
- Base64 = ::Base64
-
- # *DEPRECATED*: Use +Base64.strict_encode64+ instead.
- #
- # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
- # or memcache keys without further processing.
- #
- # ActiveSupport::Base64.encode64s("Original unencoded string")
- # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw=="
- def Base64.encode64s(value)
- ActiveSupport::Deprecation.warn "encode64s " \
- "is deprecated. Use Base64.strict_encode64 instead", caller
- strict_encode64(value)
- end
-end
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 0495741c15..df3aeb6b8a 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -77,8 +77,8 @@ module ActiveSupport
# save
# end
#
- def run_callbacks(kind, *args, &block)
- send("_run_#{kind}_callbacks", *args, &block)
+ def run_callbacks(kind, key = nil, &block)
+ self.class.__run_callbacks(key, kind, self, &block)
end
private
@@ -376,24 +376,12 @@ module ActiveSupport
end
module ClassMethods
- # Generate the internal runner method called by +run_callbacks+.
- def __define_runner(symbol) #:nodoc:
- runner_method = "_run_#{symbol}_callbacks"
- unless private_method_defined?(runner_method)
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- def #{runner_method}(key = nil, &blk)
- self.class.__run_callback(key, :#{symbol}, self, &blk)
- end
- private :#{runner_method}
- RUBY_EVAL
- end
- end
# This method calls the callback method for the given key.
# If this called first time it creates a new callback method for the key,
# calculating which callbacks can be omitted because of per_key conditions.
#
- def __run_callback(key, kind, object, &blk) #:nodoc:
+ def __run_callbacks(key, kind, object, &blk) #:nodoc:
name = __callback_runner_name(key, kind)
unless object.respond_to?(name)
str = send("_#{kind}_callbacks").compile(key, object)
@@ -618,7 +606,6 @@ module ActiveSupport
callbacks.each do |callback|
class_attribute "_#{callback}_callbacks"
send("_#{callback}_callbacks=", CallbackChain.new(callback, config))
- __define_runner(callback)
end
end
end
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index 851012e3bf..d7b3ad7d8d 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -6,7 +6,7 @@ require 'active_support/values/time_zone'
class DateTime
# Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows
# DateTimes outside the range of what can be created with Time.
- remove_method :to_time if instance_methods.include?(:to_time)
+ remove_method :to_time
# Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
#
diff --git a/activesupport/lib/active_support/core_ext/kernel/debugger.rb b/activesupport/lib/active_support/core_ext/kernel/debugger.rb
index 7516f41e0b..d5b590e9f0 100644
--- a/activesupport/lib/active_support/core_ext/kernel/debugger.rb
+++ b/activesupport/lib/active_support/core_ext/kernel/debugger.rb
@@ -2,7 +2,7 @@ module Kernel
unless respond_to?(:debugger)
# Starts a debugging session if ruby-debug has been loaded (call rails server --debugger to do load it).
def debugger
- message = "\n***** Debugger requested, but was not available (ensure ruby-debug is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
+ message = "\n***** Debugger requested, but was not available (ensure ruby-debug19 is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
end
alias breakpoint debugger unless respond_to?(:breakpoint)
diff --git a/activesupport/lib/active_support/core_ext/range/include_range.rb b/activesupport/lib/active_support/core_ext/range/include_range.rb
index c9986d4724..684b7cbc4a 100644
--- a/activesupport/lib/active_support/core_ext/range/include_range.rb
+++ b/activesupport/lib/active_support/core_ext/range/include_range.rb
@@ -9,7 +9,9 @@ class Range
# (5..9).include?(11) # => false
def include_with_range?(value)
if value.is_a?(::Range)
- min <= value.min && max >= value.max
+ # 1...10 includes 1..9 but it does not include 1..10.
+ operator = exclude_end? && !value.exclude_end? ? :< : :<=
+ include_without_range?(value.first) && value.last.send(operator, last)
else
include_without_range?(value)
end
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 89b0923882..00c67a470d 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -10,7 +10,6 @@ module ActiveSupport
# 1.month.ago # equivalent to Time.now.advance(:months => -1)
class Duration < BasicObject
attr_accessor :value, :parts
- delegate :duplicable?, :to => :value # required when using ActiveSupport's BasicObject on 1.8
def initialize(value, parts) #:nodoc:
@value, @parts = value, parts
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index d7181035d3..07b6a940c6 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -206,6 +206,10 @@ module Enumerable
end
end
+class Range
+ def as_json(options = nil) to_s end #:nodoc:
+end
+
class Array
def as_json(options = nil) #:nodoc:
# use encoder as a proxy to call as_json on all elements, to protect from circular references
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index 476ba0b3d1..6ec5a04933 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -1,5 +1,5 @@
require 'openssl'
-require 'active_support/base64'
+require 'base64'
module ActiveSupport
# MessageEncryptor is a simple way to encrypt values which get stored somewhere
@@ -56,12 +56,12 @@ module ActiveSupport
encrypted_data = cipher.update(@serializer.dump(value))
encrypted_data << cipher.final
- [encrypted_data, iv].map {|v| ActiveSupport::Base64.strict_encode64(v)}.join("--")
+ [encrypted_data, iv].map {|v| ::Base64.strict_encode64(v)}.join("--")
end
def _decrypt(encrypted_message)
cipher = new_cipher
- encrypted_data, iv = encrypted_message.split("--").map {|v| ActiveSupport::Base64.decode64(v)}
+ encrypted_data, iv = encrypted_message.split("--").map {|v| ::Base64.decode64(v)}
cipher.decrypt
cipher.key = @secret
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index 7cb5b1e82d..3b27089fa0 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -1,4 +1,4 @@
-require 'active_support/base64'
+require 'base64'
require 'active_support/core_ext/object/blank'
module ActiveSupport
@@ -37,14 +37,14 @@ module ActiveSupport
data, digest = signed_message.split("--")
if data.present? && digest.present? && secure_compare(digest, generate_digest(data))
- @serializer.load(ActiveSupport::Base64.decode64(data))
+ @serializer.load(::Base64.decode64(data))
else
raise InvalidSignature
end
end
def generate(value)
- data = ActiveSupport::Base64.strict_encode64(@serializer.dump(value))
+ data = ::Base64.strict_encode64(@serializer.dump(value))
"#{data}--#{generate_digest(data)}"
end
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index 8d6c27e381..707544e594 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -10,15 +10,9 @@ require 'active_support/core_ext/kernel/reporting'
module ActiveSupport
class TestCase < ::Test::Unit::TestCase
- if defined? MiniTest
- Assertion = MiniTest::Assertion
- alias_method :method_name, :name if method_defined? :name
- alias_method :method_name, :__name__ if method_defined? :__name__
- else
- Assertion = Test::Unit::AssertionFailedError
-
- undef :default_test
- end
+ Assertion = MiniTest::Assertion
+ alias_method :method_name, :name if method_defined? :name
+ alias_method :method_name, :__name__ if method_defined? :__name__
$tags = {}
def self.for_tag(tag)
diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb
index 1ea9a9d7e1..677e9910bb 100644
--- a/activesupport/lib/active_support/xml_mini.rb
+++ b/activesupport/lib/active_support/xml_mini.rb
@@ -1,4 +1,5 @@
require 'time'
+require 'base64'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/string/inflections'
@@ -48,7 +49,7 @@ module ActiveSupport
"symbol" => Proc.new { |symbol| symbol.to_s },
"date" => Proc.new { |date| date.to_s(:db) },
"datetime" => Proc.new { |time| time.xmlschema },
- "binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
+ "binary" => Proc.new { |binary| ::Base64.encode64(binary) },
"yaml" => Proc.new { |yaml| yaml.to_yaml }
} unless defined?(FORMATTING)
@@ -64,7 +65,7 @@ module ActiveSupport
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
"string" => Proc.new { |string| string.to_s },
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
- "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
+ "base64Binary" => Proc.new { |bin| ::Base64.decode64(bin) },
"binary" => Proc.new { |bin, entity| _parse_binary(bin, entity) },
"file" => Proc.new { |file, entity| _parse_file(file, entity) }
}
@@ -148,14 +149,14 @@ module ActiveSupport
def _parse_binary(bin, entity) #:nodoc:
case entity['encoding']
when 'base64'
- ActiveSupport::Base64.decode64(bin)
+ ::Base64.decode64(bin)
else
bin
end
end
def _parse_file(file, entity)
- f = StringIO.new(ActiveSupport::Base64.decode64(file))
+ f = StringIO.new(::Base64.decode64(file))
f.extend(FileLike)
f.original_filename = entity['name']
f.content_type = entity['content_type']
diff --git a/activesupport/test/core_ext/base64_ext_test.rb b/activesupport/test/core_ext/base64_ext_test.rb
deleted file mode 100644
index 544c990b3c..0000000000
--- a/activesupport/test/core_ext/base64_ext_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'abstract_unit'
-
-class Base64Test < Test::Unit::TestCase
- def test_no_newline_in_encoded_value
- ActiveSupport::Deprecation.silence do
- assert_match(/\n/, ActiveSupport::Base64.encode64("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"))
- assert_no_match(/\n/, ActiveSupport::Base64.encode64s("oneverylongstringthatwouldnormallybesplitupbynewlinesbytheregularbase64"))
- end
- end
-end
diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb
index f4b773e5fb..e50b6c132a 100644
--- a/activesupport/test/core_ext/range_ext_test.rb
+++ b/activesupport/test/core_ext/range_ext_test.rb
@@ -53,6 +53,10 @@ class RangeTest < Test::Unit::TestCase
assert !(2..8).include?(5..9)
end
+ def test_should_include_identical_exclusive_with_floats
+ assert((1.0...10.0).include?(1.0...10.0))
+ end
+
def test_blockless_step
assert_equal [1,3,5,7,9], (1..10).step(2)
end
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index a6435a763a..bebad18e99 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -38,6 +38,10 @@ class TestJSONEncoding < Test::Unit::TestCase
ArrayTests = [[ ['a', 'b', 'c'], %([\"a\",\"b\",\"c\"]) ],
[ [1, 'a', :b, nil, false], %([1,\"a\",\"b\",null,false]) ]]
+ RangeTests = [[ 1..2, %("1..2")],
+ [ 1...2, %("1...2")],
+ [ 1.5..2.5, %("1.5..2.5")]]
+
SymbolTests = [[ :a, %("a") ],
[ :this, %("this") ],
[ :"a b", %("a b") ]]
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb
index 11142a358f..b544742300 100644
--- a/activesupport/test/message_encryptor_test.rb
+++ b/activesupport/test/message_encryptor_test.rb
@@ -76,10 +76,10 @@ class MessageEncryptorTest < ActiveSupport::TestCase
end
def munge(base64_string)
- bits = ActiveSupport::Base64.decode64(base64_string)
+ bits = ::Base64.decode64(base64_string)
bits.reverse!
- ActiveSupport::Base64.strict_encode64(bits)
+ ::Base64.strict_encode64(bits)
end
end
-end \ No newline at end of file
+end
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 1e7ed17f33..31ff241230 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,11 @@
+## Rails 4.0.0 (unreleased) ##
+
+* Rails::Plugin has gone. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies. *Santiago Pastorino*
+
## Rails 3.2.0 (unreleased) ##
+* Rails::Plugin is deprecated and will be removed in Rails 4.0. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies. *Santiago Pastorino*
+
* Guides are available as a single .mobi for the Kindle and free Kindle readers apps. *Michael Pearson & Xavier Noria*
* Allow scaffold/model/migration generators to accept a "index" and "uniq" modifiers, as in: "tracking_id:integer:uniq" in order to generate (unique) indexes. Some types also accept custom options, for instance, you can specify the precision and scale for decimals as "price:decimal{7,2}". *Dmitrii Samoilov*
diff --git a/railties/MIT-LICENSE b/railties/MIT-LICENSE
index c73d1af096..03bde18130 100644
--- a/railties/MIT-LICENSE
+++ b/railties/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2011 David Heinemeier Hansson
+Copyright (c) 2004-2012 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/railties/guides/code/getting_started/README.rdoc b/railties/guides/code/getting_started/README.rdoc
index 7c36f2356e..d2014bd35f 100644
--- a/railties/guides/code/getting_started/README.rdoc
+++ b/railties/guides/code/getting_started/README.rdoc
@@ -86,8 +86,8 @@ programming in general.
Debugger support is available through the debugger command when you start your
Mongrel or WEBrick server with --debugger. This means that you can break out of
execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+resume execution! You need to install ruby-debug19 to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug19</tt>. Example:
class WeblogController < ActionController::Base
def index
@@ -191,7 +191,6 @@ The default directory structure of a generated Ruby on Rails application:
`-- vendor
|-- assets
`-- stylesheets
- `-- plugins
app
Holds all the code that's specific to this particular application.
@@ -256,6 +255,5 @@ test
directory.
vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
+ External libraries that the application depends on. If the app has frozen rails,
+ those gems also go here, under vendor/rails/. This directory is in the load path.
diff --git a/railties/guides/code/getting_started/config/application.rb b/railties/guides/code/getting_started/config/application.rb
index e16da30f72..5f9010fced 100644
--- a/railties/guides/code/getting_started/config/application.rb
+++ b/railties/guides/code/getting_started/config/application.rb
@@ -18,10 +18,6 @@ module Blog
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
- # Only load the plugins named here, in the order given (default is alphabetical).
- # :all can be used as a placeholder for all plugins not explicitly named.
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
diff --git a/railties/guides/rails_guides/helpers.rb b/railties/guides/rails_guides/helpers.rb
index 45ad9b9588..e6ef656474 100644
--- a/railties/guides/rails_guides/helpers.rb
+++ b/railties/guides/rails_guides/helpers.rb
@@ -11,15 +11,23 @@ module RailsGuides
result << content_tag(:dd, capture(&block))
result
end
-
+
def documents_by_section
@documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__))
end
-
+
def documents_flat
documents_by_section.map {|section| section['documents']}.flatten
end
+ def finished_documents(documents)
+ documents.reject { |document| document['work_in_progress'] }
+ end
+
+ def docs_for_menu(position)
+ position == 'L' ? documents_by_section.to(3) : documents_by_section.from(4)
+ end
+
def author(name, nick, image = 'credits_pic_blank.gif', &block)
image = "images/#{image}"
diff --git a/railties/guides/source/3_2_release_notes.textile b/railties/guides/source/3_2_release_notes.textile
index c1afee004e..2965dc6fae 100644
--- a/railties/guides/source/3_2_release_notes.textile
+++ b/railties/guides/source/3_2_release_notes.textile
@@ -67,6 +67,8 @@ When running a multi-user, multi-account application, it's a great help to be ab
h3. Railties
+* Rails::Plugin is deprecated and will be removed in Rails 4.0. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies.
+
* Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting <tt>config.reload_classes_only_on_change</tt> to false.
* New applications get a flag <tt>config.active_record.auto_explain_threshold_in_seconds</tt> in the environments configuration files. With a value of <tt>0.5</tt> in <tt>development.rb</tt> and commented out in <tt>production.rb</tt>. No mention in <tt>test.rb</tt>.
diff --git a/railties/guides/source/api_documentation_guidelines.textile b/railties/guides/source/api_documentation_guidelines.textile
index 99eb668513..93120c15a7 100644
--- a/railties/guides/source/api_documentation_guidelines.textile
+++ b/railties/guides/source/api_documentation_guidelines.textile
@@ -134,13 +134,6 @@ h4. Regular Font
When "true" and "false" are English words rather than Ruby keywords use a regular font:
-<ruby>
-# If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
-# to make it reloadable:
-#
-# Dependencies.load_once_paths.delete lib_path
-</ruby>
-
h3. Description Lists
In lists of options, parameters, etc. use a hyphen between the item and its description (reads better than a colon because normally options are symbols):
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile
index f48f5afd54..05cb8888a0 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/railties/guides/source/asset_pipeline.textile
@@ -83,7 +83,7 @@ The other problem is that when static assets are deployed with each new release
Fingerprinting fixes these problems by avoiding query strings, and by ensuring filenames are consistent based on their content.
-Fingerprinting is enabled by default for production and disabled for all the others environments. You can enable or disable it in your configuration through the +config.assets.digest+ option.
+Fingerprinting is enabled by default for production and disabled for all other environments. You can enable or disable it in your configuration through the +config.assets.digest+ option.
More reading:
@@ -103,7 +103,7 @@ When a scaffold or controller is generated for the application, Rails also gener
For example, if a +ProjectsController+ is generated, there will be a new file at +app/assets/javascripts/projects.js.coffee+ and another at +app/assets/stylesheets/projects.css.scss+. You should put any JavaScript or CSS unique to a controller inside their respective asset files, as these files can then be loaded just for these controllers with lines such as +<%= javascript_include_tag params[:controller] %>+ or +<%= stylesheet_link_tag params[:controller] %>+.
-NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use CoffeeScript. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
+NOTE: You will need an "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use CoffeeScript. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
h4. Asset Organization
@@ -194,7 +194,7 @@ $('#logo').attr({
This writes the path to the particular asset being referenced.
-Similarly, you can use the +asset_path+ helper in CoffeeScript files with +erb+ extension (eg. +application.js.coffee.erb+):
+Similarly, you can use the +asset_path+ helper in CoffeeScript files with +erb+ extension (e.g., +application.js.coffee.erb+):
<plain>
$('#logo').attr src: "<%= asset_path('logo.png') %>"
@@ -253,15 +253,15 @@ h4. Preprocessing
The file extensions used on an asset determine what preprocessing is applied. When a controller or a scaffold is generated with the default Rails gemset, a CoffeeScript file and a SCSS file are generated in place of a regular JavaScript and CSS file. The example used before was a controller called "projects", which generated an +app/assets/javascripts/projects.js.coffee+ and an +app/assets/stylesheets/projects.css.scss+ file.
-When these files are requested, they are processed by the processors provided by the +coffee-script+ and +sass-rails+ gems and then sent back to the browser as JavaScript and CSS respectively.
+When these files are requested, they are processed by the processors provided by the +coffee-script+ and +sass+ gems and then sent back to the browser as JavaScript and CSS respectively.
-Additional layers of preprocessing can be requested by adding other extensions, where each extension is processed in a right-to-left manner. These should be used in the order the processing should be applied. For example, a stylesheet called +app/assets/stylesheets/projects.css.scss.erb+ is first processed as ERB, then SCSS and finally served as CSS. The same applies to a JavaScript file -- +app/assets/javascripts/projects.js.coffee.erb+ is processed as ERB, CoffeeScript, and served as JavaScript.
+Additional layers of preprocessing can be requested by adding other extensions, where each extension is processed in a right-to-left manner. These should be used in the order the processing should be applied. For example, a stylesheet called +app/assets/stylesheets/projects.css.scss.erb+ is first processed as ERB, then SCSS, and finally served as CSS. The same applies to a JavaScript file -- +app/assets/javascripts/projects.js.coffee.erb+ is processed as ERB, then CoffeeScript, and served as JavaScript.
Keep in mind that the order of these preprocessors is important. For example, if you called your JavaScript file +app/assets/javascripts/projects.js.erb.coffee+ then it would be processed with the CoffeeScript interpreter first, which wouldn't understand ERB and therefore you would run into problems.
h3. In Development
-In development mode assets are served as separate files in the order they are specified in the manifest file.
+In development mode, assets are served as separate files in the order they are specified in the manifest file.
This manifest +app/assets/javascripts/application.js+:
@@ -289,7 +289,7 @@ You can turn off debug mode by updating +config/environments/development.rb+ to
config.assets.debug = false
</ruby>
-When debug mode is off Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead:
+When debug mode is off, Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead:
<html>
<script src="/assets/application.js" type="text/javascript"></script>
@@ -369,7 +369,7 @@ It is important that this folder is shared between deployments so that remotely
NOTE. If you are precompiling your assets locally, you can use +bundle install --without assets+ on the server to avoid installing the assets gems (the gems in the assets group in the Gemfile).
-The default matcher for compiling files includes +application.js+, +application.css+ and all non-JS/CSS files (ie. +.coffee+ and +.scss+ files are *not* automatically included as they compile to JS/CSS):
+The default matcher for compiling files includes +application.js+, +application.css+ and all non-JS/CSS files (i.e., +.coffee+ and +.scss+ files are *not* automatically included as they compile to JS/CSS):
<ruby>
[ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) }, /application.(css|js)$/ ]
@@ -451,7 +451,7 @@ This directive is available if the core module that provides this feature was co
If you're compiling nginx with Phusion Passenger you'll need to pass that option when prompted.
-Unfortunately, a robust configuration for Apache is possible but tricky, please Google around.
+Unfortunately, a robust configuration for Apache is possible but tricky; please Google around.
h4. Live Compilation
@@ -493,7 +493,7 @@ The +config.assets.compress+ must be set to +true+ to enable CSS compression.
h4. JavaScript Compression
-Possible options for JavaScript compression are +:closure+, +:uglifier+ and +:yui+. These require the use of the +closure-compiler+, +uglifier+ or +yui-compressor+ gems respectively.
+Possible options for JavaScript compression are +:closure+, +:uglifier+ and +:yui+. These require the use of the +closure-compiler+, +uglifier+ or +yui-compressor+ gems, respectively.
The default Gemfile includes "uglifier":https://github.com/lautis/uglifier. This gem wraps "UglifierJS":https://github.com/mishoo/UglifyJS (written for NodeJS) in Ruby. It compresses your code by removing white space and other magical things like changing your +if+ and +else+ statements to ternary operators where possible.
@@ -505,7 +505,7 @@ config.assets.js_compressor = :uglifier
The +config.assets.compress+ must be set to +true+ to enable JavaScript compression
-NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use +uglifier+. If you are using Mac OS X or Windows you have installed a JavaScript runtime in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
+NOTE: You will need an "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use +uglifier+. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes.
h4. Using Your Own Compressor
@@ -540,7 +540,7 @@ This is a handy option if you have any existing project (pre Rails 3.1) that alr
h4. X-Sendfile Headers
-The X-Sendfile header is a directive to the server to ignore the response from the application, and instead serve the file specified in the headers. This option is off by default, but can be enabled if your server supports it. When enabled, this passes responsibility for serving the file to the web server, which is faster.
+The X-Sendfile header is a directive to the web server to ignore the response from the application, and instead serve a specified file from disk. This option is off by default, but can be enabled if your server supports it. When enabled, this passes responsibility for serving the file to the web server, which is faster.
Apache and nginx support this option which is enabled in <tt>config/environments/production.rb</tt>.
@@ -549,7 +549,7 @@ Apache and nginx support this option which is enabled in <tt>config/environments
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
</erb>
-WARNING: If you are upgrading an existing application and intend to use this option, take care to paste this configuration option only into +production.rb+ (and not +application.rb+) and any other environment you define with production behavior.
+WARNING: If you are upgrading an existing application and intend to use this option, take care to paste this configuration option only into +production.rb+ and any other environments you define with production behavior (not +application.rb+).
h3. How Caching Works
@@ -569,7 +569,7 @@ TODO: Registering gems on "Tilt":https://github.com/rtomayko/tilt enabling Sproc
h3. Upgrading from Old Versions of Rails
-There are two issues when upgrading. The first is moving the files to the new locations. See "Asset Organization":#asset-organization above for guidance on the correct locations for different file types.
+There are two issues when upgrading. The first is moving the files from +public/+ to the new locations. See "Asset Organization":#asset-organization above for guidance on the correct locations for different file types.
The second is updating the various environment files with the correct default options. The following changes reflect the defaults in version 3.1.0.
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index fa783edc58..fe4a84dae9 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -45,8 +45,6 @@ $ rails new commandsapp
...
create tmp/cache
create tmp/pids
- create vendor/plugins
- create vendor/plugins/.gitkeep
</shell>
Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box.
@@ -295,18 +293,6 @@ h4. +rails dbconsole+
You can also use the alias "db" to invoke the dbconsole: <tt>rails db</tt>.
-h4. +rails plugin+
-
-The +rails plugin+ command simplifies plugin management. Plugins can be installed by name or their repository URLs. You need to have Git installed if you want to install a plugin from a Git repo. The same holds for Subversion too.
-
-<shell>
-$ rails plugin install https://github.com/technoweenie/acts_as_paranoid.git
-+ ./CHANGELOG
-+ ./MIT-LICENSE
-...
-...
-</shell>
-
h4. +rails runner+
<tt>runner</tt> runs Ruby code in the context of Rails non-interactively. For instance:
@@ -415,8 +401,6 @@ The +doc:+ namespace has the tools to generate documentation for your app, API d
* +rake doc:app+ generates documentation for your application in +doc/app+.
* +rake doc:guides+ generates Rails guides in +doc/guides+.
* +rake doc:rails+ generates API documentation for Rails in +doc/api+.
-* +rake doc:plugins+ generates API documentation for all the plugins installed in the application in +doc/plugins+.
-* +rake doc:clobber_plugins+ removes the generated documentation for all plugins.
h4. +notes+
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 09ef308665..3153cac2f9 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -42,7 +42,7 @@ h4. Rails General Configuration
These configuration methods are to be called on a +Rails::Railtie+ object, such as a subclass of +Rails::Engine+ or +Rails::Application+.
-* +config.after_initialize+ takes a block which will be run _after_ Rails has finished initializing the application. That includes the initialization of the framework itself, plugins, engines, and all the application's initializers in +config/initializers+. Note that this block _will_ be run for rake tasks. Useful for configuring values set up by other initializers:
+* +config.after_initialize+ takes a block which will be run _after_ Rails has finished initializing the application. That includes the initialization of the framework itself, engines, and all the application's initializers in +config/initializers+. Note that this block _will_ be run for rake tasks. Useful for configuring values set up by other initializers:
<ruby>
config.after_initialize do
@@ -98,14 +98,10 @@ NOTE. The +config.asset_path+ configuration is ignored if the asset pipeline is
* +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware":#configuring-middleware section below.
-* +config.plugins+ accepts the list of plugins to load. The default is +nil+ in which case all plugins will be loaded. If this is set to +[]+, no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. This option lets you enforce some particular loading order, useful when dependencies between plugins require it. For that use case, put first the plugins you want to be loaded in a certain order, and then the special symbol +:all+ to have the rest loaded without the need to specify them.
-
* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Enabled by +config.threadsafe!+. Defaults to +nil+, so is disabled.
* +config.reload_classes_only_on_change+ enables or disables reloading of classes only when tracked files change. By default tracks everything on autoload paths and is set to true. If +config.cache_classes+ is true, this option is ignored.
-* +config.reload_plugins+ enables or disables plugin reloading. Defaults to false.
-
* +config.secret_token+ used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. Applications get +config.secret_token+ initialized to a random key in +config/initializers/secret_token.rb+.
* +config.serve_static_assets+ configures Rails itself to serve static assets. Defaults to true, but in the production environment is turned off as the server software (e.g. Nginx or Apache) used to run the application should serve static assets instead. Unlike the default setting set this to true when running (absolutely not recommended!) or testing your app in production mode using WEBrick. Otherwise you won´t be able use page caching and requests for files that exist regularly under the public directory will anyway hit your Rails app.
@@ -462,7 +458,7 @@ Some parts of Rails can also be configured externally by supplying environment v
h3. Using Initializer Files
-After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks, plugins and gems are loaded, such as options to configure settings for these parts.
+After loading the framework and any gems in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and gems are loaded, such as options to configure settings for these parts.
NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down.
@@ -617,7 +613,7 @@ The error occurred while evaluating nil.each
*+prepend_helpers_path+* Adds the directory +app/helpers+ from the application, railties and engines to the lookup path for helpers for the application.
-*+load_config_initializers+* Loads all Ruby files from +config/initializers+ in the application, railties and engines. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
+*+load_config_initializers+* Loads all Ruby files from +config/initializers+ in the application, railties and engines. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks are loaded.
*+engines_blank_point+* Provides a point-in-initialization to hook into if you wish to do anything before engines are loaded. After this point, all railtie and engine initializers are ran.
diff --git a/railties/guides/source/documents.yaml b/railties/guides/source/documents.yaml
index dccfefb4fb..58713a08a8 100644
--- a/railties/guides/source/documents.yaml
+++ b/railties/guides/source/documents.yaml
@@ -84,7 +84,7 @@
url: configuring.html
description: This guide covers the basic configuration settings for a Rails application.
-
- name: Rails Command Line Tools and Rake tasks
+ name: Rails Command Line Tools and Rake Tasks
url: command_line.html
description: This guide covers the command line tools and rake tasks provided by Rails.
-
diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile
index d93dcf40bf..920ff997ae 100644
--- a/railties/guides/source/generators.textile
+++ b/railties/guides/source/generators.textile
@@ -406,22 +406,6 @@ The following are methods available for both generators and templates for Rails.
NOTE: Methods provided by Thor are not covered this guide and can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
-h4. +plugin+
-
-+plugin+ will install a plugin into the current application.
-
-<ruby>
-plugin("dynamic-form", :git => "git://github.com/rails/dynamic-form.git")
-</ruby>
-
-Available options are:
-
-* +:git+ - Takes the path to the git repository where this plugin can be found.
-* +:branch+ - The name of the branch of the git repository where the plugin is found.
-* +:submodule+ - Set to +true+ for the plugin to be installed as a submodule. Defaults to +false+.
-* +:svn+ - Takes the path to the svn repository where this plugin can be found.
-* +:revision+ - The revision of the plugin in an SVN repository.
-
h4. +gem+
Specifies a gem dependency of the application.
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index 54f3c74695..a36f84e9fd 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -290,7 +290,7 @@ rundown on the function of each of the files and folders that Rails created by d
|script/|Contains the rails script that starts your app and can contain other scripts you use to deploy or run your application.|
|test/|Unit tests, fixtures, and other test apparatus. These are covered in "Testing Rails Applications":testing.html|
|tmp/|Temporary files|
-|vendor/|A place for all third-party code. In a typical Rails application, this includes Ruby Gems, the Rails source code (if you optionally install it into your project) and plugins containing additional prepackaged functionality.|
+|vendor/|A place for all third-party code. In a typical Rails application, this includes Ruby Gems and the Rails source code (if you optionally install it into your project).|
h4. Configuring a Database
@@ -811,8 +811,7 @@ and links. A few things to note in the view:
NOTE. In previous versions of Rails, you had to use +&lt;%=h post.name %&gt;+ so
that any HTML would be escaped before being inserted into the page. In Rails
-3.0+, this is now the default. To get unescaped HTML, you now use +&lt;%= raw
-post.name %&gt;+.
+3 and above, this is now the default. To get unescaped HTML, you now use <tt>&lt;%= raw post.name %&gt;</tt>.
TIP: For more details on the rendering process, see "Layouts and Rendering in
Rails":layouts_and_rendering.html.
@@ -825,7 +824,7 @@ Rails renders a view to the browser, it does so by putting the view's HTML into
a layout's HTML. In previous versions of Rails, the +rails generate scaffold+
command would automatically create a controller specific layout, like
+app/views/layouts/posts.html.erb+, for the posts controller. However this has
-been changed in Rails 3.0+. An application specific +layout+ is used for all the
+been changed in Rails 3. An application specific +layout+ is used for all the
controllers and can be found in +app/views/layouts/application.html.erb+. Open
this layout in your editor and modify the +body+ tag to include the style directive
below:
@@ -1870,7 +1869,6 @@ free to consult these support resources:
* The "Ruby on Rails Tutorial":http://railstutorial.org/book
* The "Ruby on Rails mailing list":http://groups.google.com/group/rubyonrails-talk
* The "#rubyonrails":irc://irc.freenode.net/#rubyonrails channel on irc.freenode.net
-* The "Rails Wiki":http://wiki.rubyonrails.org/
Rails also comes with built-in help that you can generate using the rake command-line utility:
diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb
index e69936b43a..84427b380c 100644
--- a/railties/guides/source/layout.html.erb
+++ b/railties/guides/source/layout.html.erb
@@ -44,51 +44,16 @@
<li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">Guides Index</a>
<div id="guides" class="clearfix" style="display: none;">
<hr />
- <dl class="L">
- <dt>Start Here</dt>
- <dd><a href="getting_started.html">Getting Started with Rails</a></dd>
- <dt>Models</dt>
- <dd><a href="migrations.html">Rails Database Migrations</a></dd>
- <dd><a href="active_record_validations_callbacks.html">Active Record Validations and Callbacks</a></dd>
- <dd><a href="association_basics.html">Active Record Associations</a></dd>
- <dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
- <dt>Views</dt>
- <dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
- <dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
- <dt>Controllers</dt>
- <dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
- <dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
- </dl>
- <dl class="R">
- <dt>Digging Deeper</dt>
- <dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
- <dd><a href="i18n.html">Rails Internationalization API</a></dd>
- <dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
- <dd><a href="testing.html">Testing Rails Applications</a></dd>
- <dd><a href="security.html">Securing Rails Applications</a></dd>
- <dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
- <dd><a href="performance_testing.html">Performance Testing Rails Applications</a></dd>
- <dd><a href="configuring.html">Configuring Rails Applications</a></dd>
- <dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
- <dd><a href="caching_with_rails.html">Caching with Rails</a></dd>
- <dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
-
- <dt>Extending Rails</dt>
- <dd><a href="plugins.html">The Basics of Creating Rails Plugins</a></dd>
- <dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
- <dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
-
- <dt>Contributing to Ruby on Rails</dt>
- <dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
- <dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
- <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
-
- <dt>Release Notes</dt>
- <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
- <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
- <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
- <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
- </dl>
+ <% ['L', 'R'].each do |position| %>
+ <dl class="<%= position %>">
+ <% docs_for_menu(position).each do |section| %>
+ <dt><%= section['name'] %></dt>
+ <% finished_documents(section['documents']).each do |document| %>
+ <dd><a href="<%= document['url'] %>"><%= document['name'] %></a></dd>
+ <% end %>
+ <% end %>
+ </dl>
+ <% end %>
</div>
</li>
<li><a href="contributing_to_ruby_on_rails.html">Contribute</a></li>
diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile
index 5cfd336d1e..ccff2a1eed 100644
--- a/railties/guides/source/plugins.textile
+++ b/railties/guides/source/plugins.textile
@@ -30,16 +30,6 @@ Before you continue, take a moment to decide if your new plugin will be potentia
* If your plugin is specific to your application, your new plugin will be a _vendored plugin_.
* If you think your plugin may be used across applications, build it as a _gemified plugin_.
-h4. Either generate a vendored plugin...
-
-Use the +rails generate plugin+ command in your Rails root directory
- to create a new plugin that will live in the +vendor/plugins+
- directory. See usage and options by asking for help:
-
-<shell>
-$ rails generate plugin --help
-</shell>
-
h4. Or generate a gemified plugin.
Writing your Rails plugin as a gem, rather than as a vendored plugin,
@@ -412,30 +402,6 @@ After running +bundle install+, your gem functionality will be available to the
When the gem is ready to be shared as a formal release, it can be published to "RubyGems":http://www.rubygems.org.
For more information about publishing gems to RubyGems, see: "http://blog.thepete.net/2010/11/creating-and-publishing-your-first-ruby.html":http://blog.thepete.net/2010/11/creating-and-publishing-your-first-ruby.html
-h3. Non-Gem Plugins
-
-Non-gem plugins are useful for functionality that won't be shared with another project. Keeping your custom functionality in the
-vendor/plugins directory un-clutters the rest of the application.
-
-Move the directory that you created for the gem based plugin into the vendor/plugins directory of a generated Rails application, create a vendor/plugins/yaffle/init.rb file that contains "require 'yaffle'" and everything will still work.
-
-<ruby>
-# yaffle/init.rb
-
-require 'yaffle'
-</ruby>
-
-You can test this by changing to the Rails application that you added the plugin to and starting a rails console. Once in the
-console we can check to see if the String has an instance method to_squawk:
-
-<shell>
-$ cd my_app
-$ rails console
-$ "Rails plugins are easy!".to_squawk
-</shell>
-
-You can also remove the .gemspec, Gemfile and Gemfile.lock files as they will no longer be needed.
-
h3. RDoc Documentation
Once your plugin is stable and you are ready to deploy do everyone else a favor and document it! Luckily, writing documentation for your plugin is easy.
@@ -461,4 +427,3 @@ h4. References
* "Using Gemspecs As Intended":http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/
* "Gemspec Reference":http://docs.rubygems.org/read/chapter/20
* "GemPlugins":http://www.mbleigh.com/2008/06/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins
-* "Keeping init.rb thin":http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html
diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile
index 3b51a52733..f50ced3307 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/railties/guides/source/rails_application_templates.textile
@@ -1,6 +1,6 @@
h2. Rails Application Templates
-Application templates are simple Ruby files containing DSL for adding plugins/gems/initializers etc. to your freshly created Rails project or an existing Rails project.
+Application templates are simple Ruby files containing DSL for adding gems/initializers etc. to your freshly created Rails project or an existing Rails project.
By referring to this guide, you will be able to:
@@ -82,31 +82,6 @@ For example, if you need to source a gem from "http://code.whytheluckystiff.net"
add_source "http://code.whytheluckystiff.net"
</ruby>
-h4. plugin(name, options = {})
-
-Installs a plugin to the generated application.
-
-Plugin can be installed from Git:
-
-<ruby>
-plugin 'authentication', :git => 'git://github.com/foor/bar.git'
-</ruby>
-
-You can even install plugins as git submodules:
-
-<ruby>
-plugin 'authentication', :git => 'git://github.com/foor/bar.git',
- :submodule => true
-</ruby>
-
-Please note that you need to +git :init+ before you can install a plugin as a submodule.
-
-Or use plain old SVN:
-
-<ruby>
-plugin 'usingsvn', :svn => 'svn://example.com/usingsvn/trunk'
-</ruby>
-
h4. vendor/lib/file/initializer(filename, data = nil, &block)
Adds an initializer to the generated application’s +config/initializers+ directory.
diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile
index 5dbbe2c0f0..e0386b95b4 100644
--- a/railties/guides/source/testing.textile
+++ b/railties/guides/source/testing.textile
@@ -738,7 +738,6 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai
|+rake test:benchmark+ |Benchmark the performance tests|
|+rake test:functionals+ |Runs all the functional tests from +test/functional+|
|+rake test:integration+ |Runs all the integration tests from +test/integration+|
-|+rake test:plugins+ |Run all the plugin tests from +vendor/plugins/*/**/test+ (or specify with +PLUGIN=_name_+)|
|+rake test:profile+ |Profile the performance tests|
|+rake test:recent+ |Tests recent changes|
|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Supports Subversion and Git|
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 493102a58f..7103dad1f3 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'fileutils'
-require 'rails/plugin'
require 'rails/engine'
module Rails
@@ -9,7 +8,7 @@ module Rails
#
# == Initialization
#
- # Rails::Application is responsible for executing all railties, engines and plugin
+ # Rails::Application is responsible for executing all railties and engines
# initializers. It also executes some bootstrap initializers (check
# Rails::Application::Bootstrap) and finishing initializers, after all the others
# are executed (check Rails::Application::Finisher).
@@ -19,7 +18,7 @@ module Rails
# Besides providing the same configuration as Rails::Engine and Rails::Railtie,
# the application object has several specific configurations, for example
# "allow_concurrency", "cache_classes", "consider_all_requests_local", "filter_parameters",
- # "logger", "reload_plugins" and so forth.
+ # "logger" and so forth.
#
# Check Rails::Application::Configuration to see them all.
#
diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb
index 78d2e6c913..f96a7d1772 100644
--- a/railties/lib/rails/application/bootstrap.rb
+++ b/railties/lib/rails/application/bootstrap.rb
@@ -28,7 +28,7 @@ module Rails
FileUtils.mkdir_p File.dirname path
end
- f = File.open path, 'w'
+ f = File.open path, 'a'
f.binmode
f.sync = !Rails.env.production? # make sure every write flushes
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 79b12ad4eb..7b6cb9d8d7 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -10,7 +10,7 @@ module Rails
:cache_classes, :cache_store, :consider_all_requests_local,
:dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
:force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
- :railties_order, :relative_url_root, :reload_plugins, :secret_token,
+ :railties_order, :relative_url_root, :secret_token,
:serve_static_assets, :ssl_options, :static_cache_control, :session_options,
:time_zone, :reload_classes_only_on_change
diff --git a/railties/lib/rails/application/railties.rb b/railties/lib/rails/application/railties.rb
index 8f3a3e8bbb..f20a9689de 100644
--- a/railties/lib/rails/application/railties.rb
+++ b/railties/lib/rails/application/railties.rb
@@ -4,7 +4,7 @@ module Rails
class Application < Engine
class Railties < Rails::Engine::Railties
def all(&block)
- @all ||= railties + engines + plugins
+ @all ||= railties + engines
@all.each(&block) if block
@all
end
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb
index ada150ceec..71fe604e69 100644
--- a/railties/lib/rails/commands.rb
+++ b/railties/lib/rails/commands.rb
@@ -91,7 +91,7 @@ In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
benchmarker See how fast a piece of code runs
profiler Get profile information from a piece of code
- plugin Install a plugin
+ plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
deleted file mode 100644
index 4ddd12ae0b..0000000000
--- a/railties/lib/rails/commands/plugin.rb
+++ /dev/null
@@ -1,544 +0,0 @@
-# Rails Plugin Manager.
-#
-# Installing plugins:
-#
-# $ rails plugin install continuous_builder asset_timestamping
-#
-# Specifying revisions:
-#
-# * Subversion revision is a single integer.
-#
-# * Git revision format:
-# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental'
-# - short: 'experimental' (equivalent to 'refs/heads/experimental')
-# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0')
-#
-#
-# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com)
-# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php)
-
-$verbose = false
-
-require 'open-uri'
-require 'fileutils'
-require 'tempfile'
-
-include FileUtils
-
-class RailsEnvironment
- attr_reader :root
-
- def initialize(dir)
- @root = dir
- end
-
- def self.find(dir=nil)
- dir ||= pwd
- while dir.length > 1
- return new(dir) if File.exist?(File.join(dir, 'config', 'environment.rb'))
- dir = File.dirname(dir)
- end
- end
-
- def self.default
- @default ||= find
- end
-
- def self.default=(rails_env)
- @default = rails_env
- end
-
- def install(name_uri_or_plugin)
- if name_uri_or_plugin.is_a? String
- if name_uri_or_plugin =~ /:\/\//
- plugin = Plugin.new(name_uri_or_plugin)
- else
- plugin = Plugins[name_uri_or_plugin]
- end
- else
- plugin = name_uri_or_plugin
- end
- if plugin
- plugin.install
- else
- puts "Plugin not found: #{name_uri_or_plugin}"
- end
- end
-
- def use_svn?
- require 'active_support/core_ext/kernel'
- silence_stderr {`svn --version` rescue nil}
- !$?.nil? && $?.success?
- end
-
- def use_externals?
- use_svn? && File.directory?("#{root}/vendor/plugins/.svn")
- end
-
- def use_checkout?
- # this is a bit of a guess. we assume that if the rails environment
- # is under subversion then they probably want the plugin checked out
- # instead of exported. This can be overridden on the command line
- File.directory?("#{root}/.svn")
- end
-
- def best_install_method
- return :http unless use_svn?
- case
- when use_externals? then :externals
- when use_checkout? then :checkout
- else :export
- end
- end
-
- def externals
- return [] unless use_externals?
- ext = `svn propget svn:externals "#{root}/vendor/plugins"`
- lines = ext.respond_to?(:lines) ? ext.lines : ext
- lines.reject{ |line| line.strip == '' }.map do |line|
- line.strip.split(/\s+/, 2)
- end
- end
-
- def externals=(items)
- unless items.is_a? String
- items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n")
- end
- Tempfile.open("svn-set-prop") do |file|
- file.write(items)
- file.flush
- system("svn propset -q svn:externals -F \"#{file.path}\" \"#{root}/vendor/plugins\"")
- end
- end
-end
-
-class Plugin
- attr_reader :name, :uri
-
- def initialize(uri, name = nil)
- @uri = uri
- guess_name(uri)
- end
-
- def self.find(name)
- new(name)
- end
-
- def to_s
- "#{@name.ljust(30)}#{@uri}"
- end
-
- def svn_url?
- @uri =~ /svn(?:\+ssh)?:\/\/*/
- end
-
- def git_url?
- @uri =~ /^git:\/\// || @uri =~ /\.git$/
- end
-
- def installed?
- File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \
- or rails_env.externals.detect{ |name, repo| self.uri == repo }
- end
-
- def install(method=nil, options = {})
- method ||= rails_env.best_install_method?
- if :http == method
- method = :export if svn_url?
- method = :git if git_url?
- end
-
- uninstall if installed? and options[:force]
-
- unless installed?
- send("install_using_#{method}", options)
- run_install_hook
- else
- puts "already installed: #{name} (#{uri}). pass --force to reinstall"
- end
- end
-
- def uninstall
- path = "#{rails_env.root}/vendor/plugins/#{name}"
- if File.directory?(path)
- puts "Removing 'vendor/plugins/#{name}'" if $verbose
- run_uninstall_hook
- rm_r path
- else
- puts "Plugin doesn't exist: #{path}"
- end
-
- if rails_env.use_externals?
- # clean up svn:externals
- externals = rails_env.externals
- externals.reject!{|n, u| name == n or name == u}
- rails_env.externals = externals
- end
- end
-
- def info
- tmp = "#{rails_env.root}/_tmp_about.yml"
- if svn_url?
- cmd = "svn export #{@uri} \"#{rails_env.root}/#{tmp}\""
- puts cmd if $verbose
- system(cmd)
- end
- open(svn_url? ? tmp : File.join(@uri, 'about.yml')) do |stream|
- stream.read
- end rescue "No about.yml found in #{uri}"
- ensure
- FileUtils.rm_rf tmp if svn_url?
- end
-
- private
-
- def run_install_hook
- install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb"
- load install_hook_file if File.exist? install_hook_file
- end
-
- def run_uninstall_hook
- uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb"
- load uninstall_hook_file if File.exist? uninstall_hook_file
- end
-
- def install_using_export(options = {})
- svn_command :export, options
- end
-
- def install_using_checkout(options = {})
- svn_command :checkout, options
- end
-
- def install_using_externals(options = {})
- externals = rails_env.externals
- externals.push([@name, uri])
- rails_env.externals = externals
- install_using_checkout(options)
- end
-
- def install_using_http(options = {})
- root = rails_env.root
- mkdir_p "#{root}/vendor/plugins/#{@name}"
- Dir.chdir "#{root}/vendor/plugins/#{@name}" do
- puts "fetching from '#{uri}'" if $verbose
- fetcher = RecursiveHTTPFetcher.new(uri, -1)
- fetcher.quiet = true if options[:quiet]
- fetcher.fetch
- end
- end
-
- def install_using_git(options = {})
- root = rails_env.root
- mkdir_p(install_path = "#{root}/vendor/plugins/#{name}")
- Dir.chdir install_path do
- init_cmd = "git init"
- init_cmd += " -q" if options[:quiet] and not $verbose
- puts init_cmd if $verbose
- system(init_cmd)
- base_cmd = "git pull --depth 1 #{uri}"
- base_cmd += " -q" if options[:quiet] and not $verbose
- base_cmd += " #{options[:revision]}" if options[:revision]
- puts base_cmd if $verbose
- if system(base_cmd)
- puts "removing: .git .gitignore" if $verbose
- rm_rf %w(.git .gitignore)
- else
- rm_rf install_path
- end
- end
- end
-
- def svn_command(cmd, options = {})
- root = rails_env.root
- mkdir_p "#{root}/vendor/plugins"
- base_cmd = "svn #{cmd} #{uri} \"#{root}/vendor/plugins/#{name}\""
- base_cmd += ' -q' if options[:quiet] and not $verbose
- base_cmd += " -r #{options[:revision]}" if options[:revision]
- puts base_cmd if $verbose
- system(base_cmd)
- end
-
- def guess_name(url)
- @name = File.basename(url)
- if @name == 'trunk' || @name.empty?
- @name = File.basename(File.dirname(url))
- end
- @name.gsub!(/\.git$/, '') if @name =~ /\.git$/
- end
-
- def rails_env
- @rails_env || RailsEnvironment.default
- end
-end
-
-# load default environment and parse arguments
-require 'optparse'
-module Rails
- module Commands
- class Plugin
- attr_reader :environment, :script_name
- def initialize
- @environment = RailsEnvironment.default
- @rails_root = RailsEnvironment.default.root
- @script_name = File.basename($0)
- end
-
- def environment=(value)
- @environment = value
- RailsEnvironment.default = value
- end
-
- def options
- OptionParser.new do |o|
- o.set_summary_indent(' ')
- o.banner = "Usage: plugin [OPTIONS] command"
- o.define_head "Rails plugin manager."
-
- o.separator ""
- o.separator "GENERAL OPTIONS"
-
- o.on("-r", "--root=DIR", String,
- "Set an explicit rails app directory.",
- "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
-
- o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
- o.on("-h", "--help", "Show this help message.") { puts o; exit }
-
- o.separator ""
- o.separator "COMMANDS"
-
- o.separator " install Install plugin(s) from known repositories or URLs."
- o.separator " remove Uninstall plugins."
-
- o.separator ""
- o.separator "EXAMPLES"
- o.separator " Install a plugin from a subversion URL:"
- o.separator " #{@script_name} plugin install http://example.com/my_svn_plugin\n"
- o.separator " Install a plugin from a git URL:"
- o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n"
- o.separator " Install a plugin and add a svn:externals entry to vendor/plugins"
- o.separator " #{@script_name} plugin install -x my_svn_plugin\n"
- end
- end
-
- def parse!(args=ARGV)
- general, sub = split_args(args)
- options.parse!(general)
-
- command = general.shift
- if command =~ /^(install|remove)$/
- command = Commands.const_get(command.capitalize).new(self)
- command.parse!(sub)
- else
- puts "Unknown command: #{command}" unless command.blank?
- puts options
- exit 1
- end
- end
-
- def split_args(args)
- left = []
- left << args.shift while args[0] and args[0] =~ /^-/
- left << args.shift if args[0]
- [left, args]
- end
-
- def self.parse!(args=ARGV)
- Plugin.new.parse!(args)
- end
- end
-
- class Install
- def initialize(base_command)
- @base_command = base_command
- @method = :http
- @options = { :quiet => false, :revision => nil, :force => false }
- end
-
- def options
- OptionParser.new do |o|
- o.set_summary_indent(' ')
- o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]"
- o.define_head "Install one or more plugins."
- o.separator ""
- o.separator "Options:"
- o.on( "-x", "--externals",
- "Use svn:externals to grab the plugin.",
- "Enables plugin updates and plugin versioning.") { |v| @method = :externals }
- o.on( "-o", "--checkout",
- "Use svn checkout to grab the plugin.",
- "Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout }
- o.on( "-e", "--export",
- "Use svn export to grab the plugin.",
- "Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry.") { |v| @method = :export }
- o.on( "-q", "--quiet",
- "Suppresses the output from installation.",
- "Ignored if -v is passed (rails plugin -v install ...)") { |v| @options[:quiet] = true }
- o.on( "-r REVISION", "--revision REVISION",
- "Checks out the given revision from subversion or git.",
- "Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
- o.on( "-f", "--force",
- "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
- o.separator ""
- o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to "
- o.separator "a plugin repository."
- end
- end
-
- def determine_install_method
- best = @base_command.environment.best_install_method
- @method = :http if best == :http and @method == :export
- case
- when (best == :http and @method != :http)
- msg = "Cannot install using subversion because `svn' cannot be found in your PATH"
- when (best == :export and (@method != :export and @method != :http))
- msg = "Cannot install using #{@method} because this project is not under subversion."
- when (best != :externals and @method == :externals)
- msg = "Cannot install using externals because vendor/plugins is not under subversion."
- end
- if msg
- puts msg
- exit 1
- end
- @method
- end
-
- def parse!(args)
- options.parse!(args)
- if args.blank?
- puts options
- exit 1
- end
- environment = @base_command.environment
- install_method = determine_install_method
- puts "Plugins will be installed using #{install_method}" if $verbose
- args.each do |name|
- ::Plugin.find(name).install(install_method, @options)
- end
- rescue StandardError => e
- puts "Plugin not found: #{args.inspect}"
- puts e.inspect if $verbose
- exit 1
- end
- end
-
- class Remove
- def initialize(base_command)
- @base_command = base_command
- end
-
- def options
- OptionParser.new do |o|
- o.set_summary_indent(' ')
- o.banner = "Usage: #{@base_command.script_name} remove name [name]..."
- o.define_head "Remove plugins."
- end
- end
-
- def parse!(args)
- options.parse!(args)
- if args.blank?
- puts options
- exit 1
- end
- root = @base_command.environment.root
- args.each do |name|
- ::Plugin.new(name).uninstall
- end
- end
- end
-
- class Info
- def initialize(base_command)
- @base_command = base_command
- end
-
- def options
- OptionParser.new do |o|
- o.set_summary_indent(' ')
- o.banner = "Usage: #{@base_command.script_name} info name [name]..."
- o.define_head "Shows plugin info at {url}/about.yml."
- end
- end
-
- def parse!(args)
- options.parse!(args)
- args.each do |name|
- puts ::Plugin.find(name).info
- puts
- end
- end
- end
- end
-end
-
-class RecursiveHTTPFetcher
- attr_accessor :quiet
- def initialize(urls_to_fetch, level = 1, cwd = ".")
- @level = level
- @cwd = cwd
- @urls_to_fetch = urls_to_fetch.lines
- @quiet = false
- end
-
- def ls
- @urls_to_fetch.collect do |url|
- if url =~ /^svn(\+ssh)?:\/\/.*/
- `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil
- else
- open(url) do |stream|
- links("", stream.read)
- end rescue nil
- end
- end.flatten
- end
-
- def push_d(dir)
- @cwd = File.join(@cwd, dir)
- FileUtils.mkdir_p(@cwd)
- end
-
- def pop_d
- @cwd = File.dirname(@cwd)
- end
-
- def links(base_url, contents)
- links = []
- contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link|
- link = link.sub(/href="/i, "")
- next if link =~ /svnindex.xsl$/
- next if link =~ /^(\w*:|)\/\// || link =~ /^\./
- links << File.join(base_url, link)
- end
- links
- end
-
- def download(link)
- puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet
- open(link) do |stream|
- File.open(File.join(@cwd, File.basename(link)), "wb") do |file|
- file.write(stream.read)
- end
- end
- end
-
- def fetch(links = @urls_to_fetch)
- links.each do |l|
- (l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l)
- end
- end
-
- def fetch_dir(url)
- @level += 1
- push_d(File.basename(url)) if @level > 0
- open(url) do |stream|
- contents = stream.read
- fetch(links(url, contents))
- end
- pop_d if @level > 0
- @level -= 1
- end
-end
-
-Rails::Commands::Plugin.parse!
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb
index d6015e9c01..d7405cb519 100644
--- a/railties/lib/rails/engine/configuration.rb
+++ b/railties/lib/rails/engine/configuration.rb
@@ -5,7 +5,6 @@ module Rails
class Configuration < ::Rails::Railtie::Configuration
attr_reader :root
attr_writer :middleware, :eager_load_paths, :autoload_once_paths, :autoload_paths
- attr_accessor :plugins
def initialize(root=nil)
super()
@@ -59,7 +58,6 @@ module Rails
paths.add "db/seeds", :with => "db/seeds.rb"
paths.add "vendor", :load_path => true
paths.add "vendor/assets", :glob => "*"
- paths.add "vendor/plugins"
paths
end
end
diff --git a/railties/lib/rails/engine/railties.rb b/railties/lib/rails/engine/railties.rb
index d5ecd2e48d..033d9c4180 100644
--- a/railties/lib/rails/engine/railties.rb
+++ b/railties/lib/rails/engine/railties.rb
@@ -7,18 +7,11 @@ module Rails
end
def all(&block)
- @all ||= plugins
+ @all ||= []
@all.each(&block) if block
@all
end
- def plugins
- @plugins ||= begin
- plugin_names = (@config.plugins || [:all]).map { |p| p.to_sym }
- Plugin.all(plugin_names, @config.paths["vendor/plugins"].existent)
- end
- end
-
def self.railties
@railties ||= ::Rails::Railtie.subclasses.map(&:instance)
end
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 27f8d13ce8..cd277c5097 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -38,11 +38,6 @@ module Rails
:test_unit => {
:fixture_replacement => '-r',
- },
-
- :plugin => {
- :generator => '-g',
- :tasks => '-r'
}
}
@@ -62,11 +57,6 @@ module Rails
:stylesheet_engine => :css,
:test_framework => false,
:template_engine => :erb
- },
-
- :plugin => {
- :generator => false,
- :tasks => false
}
}
@@ -195,7 +185,6 @@ module Rails
"#{test}:scaffold",
"#{test}:view",
"#{test}:performance",
- "#{test}:plugin",
"#{template}:controller",
"#{template}:scaffold",
"#{template}:mailer",
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 781d7bf47c..ce62ea463d 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -6,40 +6,6 @@ module Rails
module Generators
module Actions
- # Install a plugin. You must provide either a Subversion url or Git url.
- #
- # For a Git-hosted plugin, you can specify a branch and
- # whether it should be added as a submodule instead of cloned.
- #
- # For a Subversion-hosted plugin you can specify a revision.
- #
- # ==== Examples
- #
- # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
- # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :branch => 'stable'
- # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
- # plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
- # plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk', :revision => 1234
- #
- def plugin(name, options)
- log :plugin, name
-
- if options[:git] && options[:submodule]
- options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
- in_root do
- run "git submodule add #{options[:git]} vendor/plugins/#{name}", :verbose => false
- end
- elsif options[:git] || options[:svn]
- options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
- options[:svn] = "-r #{options[:revision]} #{options[:svn]}" if options[:revision]
- in_root do
- run_ruby_script "script/rails plugin install #{options[:svn] || options[:git]}", :verbose => false
- end
- else
- log "! no git or svn provided for #{name}. Skipping..."
- end
- end
-
# Adds an entry into Gemfile for the supplied gem. If env
# is specified, add the gem to the given environment.
#
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 2a6bd57df4..f0745df667 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -124,7 +124,6 @@ module Rails
def vendor
vendor_javascripts
vendor_stylesheets
- vendor_plugins
end
def vendor_javascripts
@@ -134,10 +133,6 @@ module Rails
def vendor_stylesheets
empty_directory_with_gitkeep "vendor/assets/stylesheets"
end
-
- def vendor_plugins
- empty_directory_with_gitkeep "vendor/plugins"
- end
end
module Generators
diff --git a/railties/lib/rails/generators/rails/app/templates/README b/railties/lib/rails/generators/rails/app/templates/README
index 7c36f2356e..d2014bd35f 100644
--- a/railties/lib/rails/generators/rails/app/templates/README
+++ b/railties/lib/rails/generators/rails/app/templates/README
@@ -86,8 +86,8 @@ programming in general.
Debugger support is available through the debugger command when you start your
Mongrel or WEBrick server with --debugger. This means that you can break out of
execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+resume execution! You need to install ruby-debug19 to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug19</tt>. Example:
class WeblogController < ActionController::Base
def index
@@ -191,7 +191,6 @@ The default directory structure of a generated Ruby on Rails application:
`-- vendor
|-- assets
`-- stylesheets
- `-- plugins
app
Holds all the code that's specific to this particular application.
@@ -256,6 +255,5 @@ test
directory.
vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
+ External libraries that the application depends on. If the app has frozen rails,
+ those gems also go here, under vendor/rails/. This directory is in the load path.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index c6dfa1f2dd..bcd3a2ad24 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -28,10 +28,6 @@ module <%= app_const_base %>
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
- # Only load the plugins named here, in the order given (default is alphabetical).
- # :all can be used as a placeholder for all plugins not explicitly named.
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
deleted file mode 100644
index 3e27688bb9..0000000000
--- a/railties/lib/rails/plugin.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'rails/engine'
-require 'active_support/core_ext/array/conversions'
-
-module Rails
- # Rails::Plugin is nothing more than a Rails::Engine, but since it's loaded too late
- # in the boot process, it does not have the same configuration powers as a bare
- # Rails::Engine.
- #
- # Opposite to Rails::Railtie and Rails::Engine, you are not supposed to inherit from
- # Rails::Plugin. Rails::Plugin is automatically configured to be an engine by simply
- # placing inside vendor/plugins. Since this is done automatically, you actually cannot
- # declare a Rails::Engine inside your Plugin, otherwise it would cause the same files
- # to be loaded twice. This means that if you want to ship an Engine as gem it cannot
- # be used as plugin and vice-versa.
- #
- # Besides this conceptual difference, the only difference between Rails::Engine and
- # Rails::Plugin is that plugins automatically load the file "init.rb" at the plugin
- # root during the boot process.
- #
- class Plugin < Engine
- def self.global_plugins
- @global_plugins ||= []
- end
-
- def self.inherited(base)
- raise "You cannot inherit from Rails::Plugin"
- end
-
- def self.all(list, paths)
- plugins = []
- paths.each do |path|
- Dir["#{path}/*"].each do |plugin_path|
- plugin = new(plugin_path)
- next unless list.include?(plugin.name) || list.include?(:all)
- if global_plugins.include?(plugin.name)
- warn "WARNING: plugin #{plugin.name} from #{path} was not loaded. Plugin with the same name has been already loaded."
- next
- end
- global_plugins << plugin.name
- plugins << plugin
- end
- end
-
- plugins.sort_by do |p|
- [list.index(p.name) || list.index(:all), p.name.to_s]
- end
- end
-
- attr_reader :name, :path
-
- def railtie_name
- name.to_s
- end
-
- def initialize(root)
- @name = File.basename(root).to_sym
- config.root = root
- end
-
- def config
- @config ||= Engine::Configuration.new
- end
-
- initializer :handle_lib_autoload, :before => :set_load_path do |app|
- autoload = if app.config.reload_plugins
- config.autoload_paths
- else
- config.autoload_once_paths
- end
-
- autoload.concat paths["lib"].existent
- end
-
- initializer :load_init_rb, :before => :load_config_initializers do |app|
- init_rb = File.expand_path("init.rb", root)
- if File.file?(init_rb)
- # This double assignment is to prevent an "unused variable" warning on Ruby 1.9.3.
- config = config = app.config
- # TODO: think about evaling initrb in context of Engine (currently it's
- # always evaled in context of Rails::Application)
- eval(File.read(init_rb), binding, init_rb)
- end
- end
-
- initializer :sanity_check_railties_collision do
- if Engine.subclasses.map { |k| k.root.to_s }.include?(root.to_s)
- raise "\"#{name}\" is a Railtie/Engine and cannot be installed as a plugin"
- end
- end
- end
-end
diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb
index 831188eeee..5a78da1731 100644
--- a/railties/lib/rails/rack/debugger.rb
+++ b/railties/lib/rails/rack/debugger.rb
@@ -12,7 +12,7 @@ module Rails
::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
puts "=> Debugger enabled"
rescue LoadError
- puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
+ puts "You need to install ruby-debug19 to run the server in debugging mode. With gems, use 'gem install ruby-debug19'"
exit
end
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 07a122e7d0..7fed7c8631 100644
--- a/railties/lib/rails/railtie.rb
+++ b/railties/lib/rails/railtie.rb
@@ -103,11 +103,11 @@ module Rails
# end
# end
#
- # == Application, Plugin and Engine
+ # == Application and Engine
#
# A Rails::Engine is nothing more than a Railtie with some initializers already set.
- # And since Rails::Application and Rails::Plugin are engines, the same configuration
- # described here can be used in all three.
+ # And since Rails::Application is an engine, the same configuration described here
+ # can be used in both.
#
# Be sure to look at the documentation of those specific classes for more information.
#
@@ -117,7 +117,7 @@ module Rails
include Initializable
- ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Plugin Rails::Engine Rails::Application)
+ ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Engine Rails::Application)
class << self
private :new
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index 1c28b2c8e6..e09379c8c2 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -55,7 +55,7 @@ namespace :doc do
rdoc.rdoc_files.include('app/**/*.rb')
rdoc.rdoc_files.include('lib/**/*.rb')
}
- Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
+ Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
# desc 'Generate documentation for the Rails framework.'
RDocTaskWithoutDescriptions.new("rails") { |rdoc|
@@ -108,48 +108,10 @@ namespace :doc do
end
}
- plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
-
- # desc "Generate documentation for all installed plugins"
- task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }
-
- # desc "Remove plugin documentation"
- task :clobber_plugins do
- rm_rf 'doc/plugins' rescue nil
- end
-
# desc "Generate Rails Guides"
task :guides do
# FIXME: Reaching outside lib directory is a bad idea
require File.expand_path('../../../../guides/rails_guides', __FILE__)
RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate
end
-
- namespace :plugins do
- # Define doc tasks for each plugin
- plugins.each do |plugin|
- # desc "Generate documentation for the #{plugin} plugin"
- task(plugin => :environment) do
- plugin_base = "vendor/plugins/#{plugin}"
- options = []
- files = Rake::FileList.new
- options << "-o doc/plugins/#{plugin}"
- options << "--title '#{plugin.titlecase} Plugin Documentation'"
- options << '--line-numbers'
- options << '--charset' << 'utf-8'
- options << '-T html'
-
- files.include("#{plugin_base}/lib/**/*.rb")
- if File.exist?("#{plugin_base}/README")
- files.include("#{plugin_base}/README")
- options << "--main '#{plugin_base}/README'"
- end
- files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG")
-
- options << files.to_s
-
- sh %(rdoc #{options * ' '})
- end
- end
- end
end
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index a23d22d607..2c0b167a99 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -45,7 +45,7 @@ end
task :default => :test
-desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)'
+desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile)'
task :test do
Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
end
@@ -119,14 +119,4 @@ namespace :test do
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
-
- Rails::SubTestTask.new(:plugins => :environment) do |t|
- t.libs << "test"
-
- if ENV['PLUGIN']
- t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
- else
- t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb'
- end
- end
end
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb
index 964cff48cd..84f4408147 100644
--- a/railties/test/application/paths_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -46,7 +46,6 @@ module ApplicationTests
assert_path @paths["app/views"], "app/views"
assert_path @paths["lib"], "lib"
assert_path @paths["vendor"], "vendor"
- assert_path @paths["vendor/plugins"], "vendor/plugins"
assert_path @paths["tmp"], "tmp"
assert_path @paths["config"], "config"
assert_path @paths["config/locales"], "config/locales/en.yml"
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index ee288871de..a8c8fcd5b7 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -9,8 +9,6 @@ class ActionsTest < Rails::Generators::TestCase
def setup
Rails.application = TestApp::Application
super
- @git_plugin_uri = 'git://github.com/technoweenie/restful-authentication.git'
- @svn_plugin_uri = 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
end
def teardown
@@ -37,41 +35,6 @@ class ActionsTest < Rails::Generators::TestCase
assert_file 'lib/test_file.rb', 'heres block data'
end
- def test_plugin_with_git_option_should_run_plugin_install
- generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@git_plugin_uri}", :verbose => false)
- action :plugin, 'restful-authentication', :git => @git_plugin_uri
- end
-
- def test_plugin_with_svn_option_should_run_plugin_install
- generator.expects(:run_ruby_script).once.with("script/rails plugin install #{@svn_plugin_uri}", :verbose => false)
- action :plugin, 'restful-authentication', :svn => @svn_plugin_uri
- end
-
- def test_plugin_with_git_option_and_branch_should_run_plugin_install
- generator.expects(:run_ruby_script).once.with("script/rails plugin install -b stable #{@git_plugin_uri}", :verbose => false)
- action :plugin, 'restful-authentication', :git => @git_plugin_uri, :branch => 'stable'
- end
-
- def test_plugin_with_svn_option_and_revision_should_run_plugin_install
- generator.expects(:run_ruby_script).once.with("script/rails plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false)
- action :plugin, 'restful-authentication', :svn => @svn_plugin_uri, :revision => 1234
- end
-
- def test_plugin_with_git_option_and_submodule_should_use_git_scm
- generator.expects(:run).with("git submodule add #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false)
- action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true
- end
-
- def test_plugin_with_git_option_and_submodule_should_use_git_scm
- generator.expects(:run).with("git submodule add -b stable #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false)
- action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true, :branch => 'stable'
- end
-
- def test_plugin_with_no_options_should_skip_method
- generator.expects(:run).never
- action :plugin, 'rest_auth', {}
- end
-
def test_add_source_adds_source_to_gemfile
run_generator
action :add_source, 'http://gems.github.com'
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index a15943dfc6..70ef37ee0f 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -32,7 +32,6 @@ DEFAULT_APP_FILES = %w(
test/unit
vendor
vendor/assets
- vendor/plugins
tmp/cache
tmp/cache/assets
)
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index 06b658e7bd..f57737172d 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -178,20 +178,6 @@ module TestHelpers
end
end
- def plugin(name, string = "")
- dir = "#{app_path}/vendor/plugins/#{name}"
- FileUtils.mkdir_p(dir)
-
- File.open("#{dir}/init.rb", 'w') do |f|
- f.puts "::#{name.upcase} = 'loaded'"
- f.puts string
- end
-
- Bukkit.new(dir).tap do |bukkit|
- yield bukkit if block_given?
- end
- end
-
def engine(name)
dir = "#{app_path}/random/#{name}"
FileUtils.mkdir_p(dir)
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 400cae98b2..2813f689c5 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -151,46 +151,6 @@ module RailtiesTest
assert_equal "foo", last_response.body
end
- test "engine can load its own plugins" do
- @plugin.write "lib/bukkits.rb", <<-RUBY
- module Bukkits
- class Engine < ::Rails::Engine
- end
- end
- RUBY
-
- @plugin.write "vendor/plugins/yaffle/init.rb", <<-RUBY
- config.yaffle_loaded = true
- RUBY
-
- boot_rails
-
- assert Bukkits::Engine.config.yaffle_loaded
- end
-
- test "engine does not load plugins that already exists in application" do
- @plugin.write "lib/bukkits.rb", <<-RUBY
- module Bukkits
- class Engine < ::Rails::Engine
- end
- end
- RUBY
-
- @plugin.write "vendor/plugins/yaffle/init.rb", <<-RUBY
- config.engine_yaffle_loaded = true
- RUBY
-
- app_file "vendor/plugins/yaffle/init.rb", <<-RUBY
- config.app_yaffle_loaded = true
- RUBY
-
- warnings = capture(:stderr) { boot_rails }
-
- assert !warnings.empty?
- assert !Bukkits::Engine.config.respond_to?(:engine_yaffle_loaded)
- assert Rails.application.config.app_yaffle_loaded
- end
-
test "it loads its environment file" do
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
diff --git a/railties/test/railties/plugin_ordering_test.rb b/railties/test/railties/plugin_ordering_test.rb
deleted file mode 100644
index 1cfaf557e9..0000000000
--- a/railties/test/railties/plugin_ordering_test.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require "isolation/abstract_unit"
-
-module RailtiesTest
- class PluginOrderingTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- $arr = []
- plugin "a_plugin", "$arr << :a"
- plugin "b_plugin", "$arr << :b"
- plugin "c_plugin", "$arr << :c"
- end
-
- def teardown
- teardown_app
- end
-
- def boot_rails
- super
- require "#{app_path}/config/environment"
- end
-
- test "plugins are loaded alphabetically by default" do
- boot_rails
- assert_equal [:a, :b, :c], $arr
- end
-
- test "if specified, only those plugins are loaded" do
- add_to_config "config.plugins = [:b_plugin]"
- boot_rails
- assert_equal [:b], $arr
- end
-
- test "the plugins are initialized in the order they are specified" do
- add_to_config "config.plugins = [:b_plugin, :a_plugin]"
- boot_rails
- assert_equal [:b, :a], $arr
- end
-
- test "if :all is specified, the remaining plugins are loaded in alphabetical order" do
- add_to_config "config.plugins = [:c_plugin, :all]"
- boot_rails
- assert_equal [:c, :a, :b], $arr
- end
-
- test "if :all is at the beginning, it represents the plugins not otherwise specified" do
- add_to_config "config.plugins = [:all, :b_plugin]"
- boot_rails
- assert_equal [:a, :c, :b], $arr
- end
-
- test "plugin order array is strings" do
- add_to_config "config.plugins = %w( c_plugin all )"
- boot_rails
- assert_equal [:c, :a, :b], $arr
- end
-
- test "can require lib file from a different plugin" do
- plugin "foo", "require 'bar'" do |plugin|
- plugin.write "lib/foo.rb", "$foo = true"
- end
-
- plugin "bar", "require 'foo'" do |plugin|
- plugin.write "lib/bar.rb", "$bar = true"
- end
-
- add_to_config "config.plugins = [:foo, :bar]"
-
- boot_rails
-
- assert $foo
- assert $bar
- end
- end
-end
diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb
deleted file mode 100644
index f307d53cf7..0000000000
--- a/railties/test/railties/plugin_test.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-require "isolation/abstract_unit"
-require "railties/shared_tests"
-
-module RailtiesTest
- class PluginTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
- include SharedTests
-
- def setup
- build_app
-
- @plugin = plugin "bukkits", "::LEVEL = config.log_level" do |plugin|
- plugin.write "lib/bukkits.rb", "class Bukkits; end"
- plugin.write "lib/another.rb", "class Another; end"
- end
- end
-
- def teardown
- teardown_app
- end
-
- test "Rails::Plugin itself does not respond to config" do
- boot_rails
- assert !Rails::Plugin.respond_to?(:config)
- end
-
- test "cannot inherit from Rails::Plugin" do
- boot_rails
- assert_raise RuntimeError do
- class Foo < Rails::Plugin; end
- end
- end
-
- test "plugin can load the file with the same name in lib" do
- boot_rails
- require "bukkits"
- assert_equal "Bukkits", Bukkits.name
- end
-
- test "plugin gets added to dependency list" do
- boot_rails
- assert_equal "Another", Another.name
- end
-
- test "plugin constants get reloaded if config.reload_plugins is set to true" do
- add_to_config <<-RUBY
- config.reload_plugins = true
- RUBY
-
- boot_rails
-
- assert_equal "Another", Another.name
- ActiveSupport::Dependencies.clear
- @plugin.delete("lib/another.rb")
- assert_raises(NameError) { Another }
- end
-
- test "plugin constants are not reloaded by default" do
- boot_rails
- assert_equal "Another", Another.name
- ActiveSupport::Dependencies.clear
- @plugin.delete("lib/another.rb")
- assert_nothing_raised { Another }
- end
-
- test "it loads the plugin's init.rb file" do
- boot_rails
- assert_equal "loaded", BUKKITS
- end
-
- test "the init.rb file has access to the config object" do
- boot_rails
- assert_equal :debug, LEVEL
- end
-
- test "plugin_init_is_run_before_application_ones" do
- plugin "foo", "$foo = true" do |plugin|
- plugin.write "lib/foo.rb", "module Foo; end"
- end
-
- app_file 'config/initializers/foo.rb', <<-RUBY
- raise "no $foo" unless $foo
- raise "no Foo" unless Foo
- RUBY
-
- boot_rails
- assert $foo
- end
-
- test "plugin should work without init.rb" do
- @plugin.delete("init.rb")
-
- boot_rails
-
- require "bukkits"
- assert_nothing_raised { Bukkits }
- end
-
- test "plugin cannot declare an engine for it" do
- @plugin.write "lib/bukkits.rb", <<-RUBY
- class Bukkits
- class Engine < Rails::Engine
- end
- end
- RUBY
-
- @plugin.write "init.rb", <<-RUBY
- require "bukkits"
- RUBY
-
- rescued = false
-
- begin
- boot_rails
- rescue Exception => e
- rescued = true
- assert_equal '"bukkits" is a Railtie/Engine and cannot be installed as a plugin', e.message
- end
-
- assert rescued, "Expected boot rails to fail"
- end
- end
-end
diff --git a/railties/test/railties/shared_tests.rb b/railties/test/railties/shared_tests.rb
index a15dae2a0a..3630a0937c 100644
--- a/railties/test/railties/shared_tests.rb
+++ b/railties/test/railties/shared_tests.rb
@@ -61,15 +61,6 @@ module RailtiesTest
end
RUBY
- yaffle = plugin "acts_as_yaffle", "::LEVEL = config.log_level" do |plugin|
- plugin.write "lib/acts_as_yaffle.rb", "class ActsAsYaffle; end"
- end
-
- yaffle.write "db/migrate/1_create_yaffles.rb", <<-RUBY
- class CreateYaffles < ActiveRecord::Migration
- end
- RUBY
-
add_to_config "ActiveRecord::Base.timestamped_migrations = false"
boot_rails
@@ -87,14 +78,10 @@ module RailtiesTest
output = `bundle exec rake railties:install:migrations`.split("\n")
- assert File.exists?("#{app_path}/db/migrate/4_create_yaffles.acts_as_yaffle.rb")
assert_no_match(/2_create_users/, output.join("\n"))
- yaffle_migration_order = output.index(output.detect{|o| /Copied migration 4_create_yaffles.acts_as_yaffle.rb from acts_as_yaffle/ =~ o })
bukkits_migration_order = output.index(output.detect{|o| /NOTE: Migration 3_create_sessions.rb from bukkits has been skipped/ =~ o })
- assert_not_nil yaffle_migration_order, "Expected migration to be copied"
assert_not_nil bukkits_migration_order, "Expected migration to be skipped"
- assert_equal(railties.index('acts_as_yaffle') > railties.index('bukkits'), yaffle_migration_order > bukkits_migration_order)
migrations_count = Dir["#{app_path}/db/migrate/*.rb"].length
output = `bundle exec rake railties:install:migrations`