aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/credits.erb.textile2
-rw-r--r--railties/guides/source/layouts_and_rendering.textile2
-rw-r--r--railties/guides/source/rails_application_templates.textile232
-rw-r--r--railties/guides/source/security.textile2
-rw-r--r--railties/lib/commands/server.rb1
-rw-r--r--railties/lib/console_app.rb2
-rw-r--r--railties/lib/initializer.rb33
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb3
-rw-r--r--railties/lib/rails/gem_dependency.rb21
-rw-r--r--railties/lib/rails/plugin.rb3
-rw-r--r--railties/lib/tasks/gems.rake18
-rw-r--r--railties/lib/tasks/misc.rake6
-rw-r--r--railties/test/abstract_unit.rb1
-rw-r--r--railties/test/boot_test.rb1
-rw-r--r--railties/test/gem_dependency_test.rb43
-rw-r--r--railties/test/plugin_loader_test.rb4
-rw-r--r--railties/test/plugin_test_helper.rb3
-rw-r--r--railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification29
-rw-r--r--railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification41
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile0
-rw-r--r--railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification41
-rw-r--r--railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb1
-rw-r--r--railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification49
-rw-r--r--railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb1
26 files changed, 514 insertions, 27 deletions
diff --git a/railties/guides/source/credits.erb.textile b/railties/guides/source/credits.erb.textile
index b09a931fd6..512f4b0809 100644
--- a/railties/guides/source/credits.erb.textile
+++ b/railties/guides/source/credits.erb.textile
@@ -8,7 +8,7 @@ p. We'd like to thank the following people for their tireless contributions to t
<h3 class="section">Rails Documentation Team</h3>
<% author('Mike Gunderloy', 'mgunderloy') do %>
- Mike Gunderloy is a consultant with "ActionRails":http://www.actionrails.com and also a member of the "Rails activism team":http://rubyonrails.org/activists . He brings 25 years of experience in a variety of languages to bear on his current work with Rails. His near-daily links and other blogging can be found at "A Fresh Cup":http://afreshcup.com and he "twitters":http://twitter.com/MikeG1 too much.
+ Mike Gunderloy is a consultant with "ActionRails":http://www.actionrails.com. He brings 25 years of experience in a variety of languages to bear on his current work with Rails. His near-daily links and other blogging can be found at "A Fresh Cup":http://afreshcup.com and he "twitters":http://twitter.com/MikeG1 too much.
<% end %>
<% author('Pratik Naik', 'lifo') do %>
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index 809d2b2172..d7573e6314 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -447,7 +447,7 @@ redirect_to :back
h5. Getting a Different Redirect Status Code
-Rails uses HTTP status code 302 (permanent redirect) when you call +redirect_to+. If you'd like to use a different status code (perhaps 301, temporary redirect), you can do so by using the +:status+ option:
+Rails uses HTTP status code 302 (temporary redirect) when you call +redirect_to+. If you'd like to use a different status code (perhaps 301, permanent redirect), you can do so by using the +:status+ option:
<ruby>
redirect_to photos_path, :status => 301
diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile
index 49cd5bf5f5..3068d0fd7f 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/railties/guides/source/rails_application_templates.textile
@@ -1,18 +1,238 @@
h2. Rails Application Templates
-This guide covers the Rails application templates, By referring to this guide, you will be able to:
+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.
+
+By referring to this guide, you will be able to:
-* Use existing templates to generate a customized Rails application
-* Write your own reusable Rails application templates
+* Use templates to generate/customize Rails applications
+* Write your own reusable application templates using the Rails template API
endprologue.
-h3. Introduction
+h3. Usage
-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.
+To apply a template, you need to provide the Rails generator with the location of the template you wish to apply, using -m option :
+
+<shell>
+$ rails blog -m ~/template.rb
+</shell>
+
+It's also possible to apply a template using a URL :
+
+<shell>
+$ rails blog -m http://gist.github.com/31208.txt
+</shell>
+
+Alternatively, you can use the rake task +rails:template+ to apply a template to an existing Rails application :
+
+<shell>
+$ rake rails:template LOCATION=~/template.rb
+</shell>
+
+h3. Template API
+
+Rails templates API is very self explanatory and easy to understand. Here's an example of a typical Rails template :
+
+<ruby>
+# template.rb
+run "rm public/index.html"
+generate(:scaffold, "person name:string")
+route "map.root :controller => 'people'"
+rake("db:migrate")
+
+git :init
+git :add => "."
+git :commit => "-a -m 'Initial commit'"
+</ruby>
+
+The following sections outlines the primary methods provided by the API :
+
+h4. gem(name, options = {})
+
+Adds a +config.gem+ entry for the supplied gem to the generated application’s +config/environment.rb+.
+
+For example, if your application depends on the gems +bj+ and +hpricot+ :
+
+<ruby>
+gem "bj"
+gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+</ruby>
+
+Please note that this will NOT install the gems for you. So you may want to run the +rake gems:install+ task too :
+
+<ruby>
+rake "gems:install"
+</ruby>
+
+And let Rails take care of installing the required gems if they’re not already installed.
+
+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 'wtfsvn' :svn => 'svn://crap.com/wtf/trunk'
+</ruby>
+
+h4. vendor/lib/file/initializer(filename, data = nil, &block)
+
+Adds an initializer to the generated application’s +config/initializers+ directory.
+
+Lets say you like using +Object#not_nil?+ and +Object#not_blank?+ :
+
+<ruby>
+initializer 'bloatlol.rb', <<-CODE
+class Object
+ def not_nil?
+ !nil?
+ end
+
+ def not_blank?
+ !blank?
+ end
+end
+CODE
+</ruby>
+
+Similarly +lib()+ creates a file in the +lib/+ directory and +vendor()+ creates a file in the +vendor/+ directory.
+
+There is even +file()+, which accepts a relative path from +RAILS_ROOT+ and creates all the directories/file needed :
+
+<ruby>
+file 'app/components/foo.rb', <<-CODE
+class Foo
+end
+CODE
+</ruby>
+
+That’ll create +app/components+ directory and put +foo.rb+ in there.
+
+h4. rakefile(filename, data = nil, &block)
+
+Creates a new rake file under +lib/tasks+ with the supplied tasks :
+
+<ruby>
+rakefile("bootstrap.rake") do
+ <<-TASK
+ namespace :boot do
+ task :strap do
+ puts "i like boots!"
+ end
+ end
+ TASK
+end
+</ruby>
+
+The above creates +lib/tasks/bootstrap.rake+ with a +boot:strap+ rake task.
+
+h4. generate(what, args)
+
+Runs the supplied rails generator with given arguments. For example, I love to scaffold some whenever I’m playing with Rails :
+
+<ruby>
+generate(:scaffold, "person", "name:string", "address:text", "age:number")
+</ruby>
+
+h4. run(command)
+
+Executes an arbitrary command. Just like the backticks. Let's say you want to remove the +public/index.html+ file :
+
+<ruby>
+run "rm public/index.html"
+</ruby>
+
+h4. rake(command, options = {})
+
+Runs the supplied rake tasks in the Rails application. Let's say you want to migrate the database :
+
+<ruby>
+rake "db:migrate"
+</ruby>
+
+You can also run rake tasks with a different Rails environment :
+
+<ruby>
+rake "db:migrate", :env => 'production'
+</ruby>
+
+Or even use sudo :
+
+<ruby>
+rake "gems:install", :sudo => true
+</ruby>
+
+h4. route(routing_code)
+
+This adds a routing entry to the +config/routes.rb+ file. In above steps, we generated a person scaffold and also removed +public/index.html+. Now to make +PeopleController#index+ as the default page for the application :
+
+<ruby>
+route "map.root :controller => :person"
+</ruby>
+
+h4. inside(dir)
+
+I have my edge rails lying at +~/commit-rails/rails+. So every time i have to manually symlink edge from my new app. But now :
+
+<ruby>
+inside('vendor') do
+ run "ln -s ~/commit-rails/rails rails"
+end
+</ruby>
+
+So +inside()+ runs the command from the given directory.
+
+h4. ask(question)
+
++ask()+ gives you a chance to get some feedback from the user and use it in your templates. Lets say you want your user to name the new shiny library you’re adding :
+
+<ruby>
+lib_name = ask("What do you want to call the shiny library ?")
+lib_name << ".rb" unless lib_name.index(".rb")
+
+lib lib_name, <<-CODE
+class Shiny
+end
+CODE
+</ruby>
+
+h4. yes?(question) or no?(question)
+
+These methods let you ask questions from templates and decide the flow based on the user’s answer. Lets say you want to freeze rails only if the user want to :
+
+<ruby>
+rake("rails:freeze:gems") if yes?("Freeze rails gems ?")
+no?(question) acts just the opposite.
+</ruby>
+
+h4. git(:must => "-a love")
+
+Rails templates let you run any git command :
+
+<ruby>
+git :init
+git :add => "."
+git :commit => "-a -m 'Initial commit'"
+</ruby>
h3. Changelog
"Lighthouse ticket":http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/78
-* April 17, 2009: Initial version by "Pratik":credits.html#lifo
+* April 29, 2009: Initial version by "Pratik":credits.html#lifo
diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile
index 7b93fa7561..875c4ae6e5 100644
--- a/railties/guides/source/security.textile
+++ b/railties/guides/source/security.textile
@@ -967,7 +967,7 @@ Transfer-Encoding: chunked
Content-Type: text/html
</plain>
-Under certain circumstances this would present the malicious HTML to the victim. However, this seems to work with Keep-Alive connections, only (and many browsers are using one-time connections). But you can't rely on this. _(highlight)In any case this is a serious bug, and you should update your Rails to version 2.0.5 or 2.1.2 to eliminate Header Injection (and thus response splitting) risks._
+Under certain circumstances this would present the malicious HTML to the victim. However, this only seems to work with Keep-Alive connections (and many browsers are using one-time connections). But you can't rely on this. _(highlight)In any case this is a serious bug, and you should update your Rails to version 2.0.5 or 2.1.2 to eliminate Header Injection (and thus response splitting) risks._
h3. Additional Resources
diff --git a/railties/lib/commands/server.rb b/railties/lib/commands/server.rb
index ebe34a42cd..91ac7752ef 100644
--- a/railties/lib/commands/server.rb
+++ b/railties/lib/commands/server.rb
@@ -1,4 +1,3 @@
-require 'active_support'
require 'action_controller'
require 'fileutils'
diff --git a/railties/lib/console_app.rb b/railties/lib/console_app.rb
index d7d01d703f..5c8302634a 100644
--- a/railties/lib/console_app.rb
+++ b/railties/lib/console_app.rb
@@ -1,3 +1,5 @@
+require 'active_support'
+require 'active_support/core/all'
require 'active_support/test_case'
require 'action_controller'
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index a03be59a2b..71366a4480 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -5,12 +5,9 @@ require 'pathname'
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'railties_path'
require 'rails/version'
-require 'rails/plugin/locator'
-require 'rails/plugin/loader'
require 'rails/gem_dependency'
require 'rails/rack'
-
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
module Rails
@@ -159,6 +156,8 @@ module Rails
add_support_load_paths
+ check_for_unbuilt_gems
+
load_gems
load_plugins
@@ -244,6 +243,7 @@ module Rails
# Set the paths from which Rails will automatically load source files, and
# the load_once paths.
def set_autoload_paths
+ require 'active_support/dependencies'
ActiveSupport::Dependencies.load_paths = configuration.load_paths.uniq
ActiveSupport::Dependencies.load_once_paths = configuration.load_once_paths.uniq
@@ -263,6 +263,8 @@ module Rails
# list. By default, all frameworks (Active Record, Active Support,
# Action Pack, Action Mailer, and Active Resource) are loaded.
def require_frameworks
+ require 'active_support'
+ require 'active_support/core/all'
configuration.frameworks.each { |framework| require(framework.to_s) }
rescue LoadError => e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
@@ -289,10 +291,12 @@ module Rails
# Adds all load paths from plugins to the global set of load paths, so that
# code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies).
def add_plugin_load_paths
+ require 'active_support/dependencies'
plugin_loader.add_plugin_load_paths
end
def add_gem_load_paths
+ require 'rails/gem_dependency'
Rails::GemDependency.add_frozen_gem_path
unless @configuration.gems.empty?
require "rubygems"
@@ -306,6 +310,25 @@ module Rails
end
end
+ def check_for_unbuilt_gems
+ unbuilt_gems = @configuration.gems.select(&:frozen?).reject(&:built?)
+ if unbuilt_gems.size > 0
+ # don't print if the gems:build rake tasks are being run
+ unless $gems_build_rake_task
+ abort <<-end_error
+The following gems have native components that need to be built
+ #{unbuilt_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "}
+
+You're running:
+ ruby #{Gem.ruby_version} at #{Gem.ruby}
+ rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '}
+
+Run `rake gems:build` to build the unbuilt gems.
+ end_error
+ end
+ end
+ end
+
def check_gem_dependencies
unloaded_gems = @configuration.gems.reject { |g| g.loaded? }
if unloaded_gems.size > 0
@@ -568,7 +591,7 @@ Run `rake gems:install` to install the missing gems.
Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
configuration.middleware.insert_before(
- :"ActionDispatch::RewindableInput",
+ :"ActionDispatch::ParamsParser",
Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
end
@@ -1037,12 +1060,14 @@ Run `rake gems:install` to install the missing gems.
end
def default_plugin_locators
+ require 'rails/plugin/locator'
locators = []
locators << Plugin::GemLocator if defined? Gem
locators << Plugin::FileSystemLocator
end
def default_plugin_loader
+ require 'rails/plugin/loader'
Plugin::Loader
end
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index 923ed8b31d..1605429e8b 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -1,3 +1,6 @@
+require 'active_support/backtrace_cleaner'
+require 'rails/gem_dependency'
+
module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
ERB_METHOD_SIG = /:in `_run_erb_.*/
diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb
index 3062a77104..ee3d0d81ba 100644
--- a/railties/lib/rails/gem_dependency.rb
+++ b/railties/lib/rails/gem_dependency.rb
@@ -29,6 +29,15 @@ module Rails
end
end
+ def self.from_directory_name(directory_name)
+ directory_name_parts = File.basename(directory_name).split('-')
+ name = directory_name_parts[0..-2].join('-')
+ version = directory_name_parts.last
+ self.new(name, :version => version)
+ rescue ArgumentError => e
+ raise "Unable to determine gem name and version from '#{directory_name}'"
+ end
+
def initialize(name, options = {})
require 'rubygems' unless Object.const_defined?(:Gem)
@@ -101,8 +110,12 @@ module Rails
end
def built?
- # TODO: If Rubygems ever gives us a way to detect this, we should use it
- false
+ return false unless frozen?
+ specification.extensions.each do |ext|
+ makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile')
+ return false unless File.exists?(makefile)
+ end
+ true
end
def framework_gem?
@@ -155,9 +168,9 @@ module Rails
specification && File.exists?(unpacked_gem_directory)
end
- def build
+ def build(options={})
require 'rails/gem_builder'
- unless built?
+ if options[:force] || !built?
return unless File.exists?(unpacked_specification_filename)
spec = YAML::load_file(unpacked_specification_filename)
Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index dd840ef058..0f924724cd 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -1,6 +1,3 @@
-require 'active_support/core_ext/kernel/reporting'
-require 'active_support/dependencies'
-
module Rails
# The Plugin class should be an object which provides the following methods:
#
diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake
index ed07bf2016..efadb1da3b 100644
--- a/railties/lib/tasks/gems.rake
+++ b/railties/lib/tasks/gems.rake
@@ -20,8 +20,16 @@ namespace :gems do
desc "Build any native extensions for unpacked gems"
task :build do
$gems_build_rake_task = true
- Rake::Task['gems:unpack'].invoke
- current_gems.each &:build
+ frozen_gems.each &:build
+ end
+
+ namespace :build do
+ desc "Force the build of all gems"
+ task :force do
+ $gems_build_rake_task = true
+ Rake::Task['gems:unpack'].invoke
+ current_gems.each { |gem| gem.build(:force => true) }
+ end
end
desc "Installs all required gems."
@@ -53,6 +61,12 @@ def current_gems
gems
end
+def frozen_gems
+ Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*-*')].map do |gem_dir|
+ Rails::GemDependency.from_directory_name(gem_dir)
+ end
+end
+
def print_gem_status(gem, indent=1)
code = case
when gem.framework_gem? then 'R'
diff --git a/railties/lib/tasks/misc.rake b/railties/lib/tasks/misc.rake
index 9e6f96db5b..a2c338aa5b 100644
--- a/railties/lib/tasks/misc.rake
+++ b/railties/lib/tasks/misc.rake
@@ -12,10 +12,10 @@ end
desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.'
task :secret do
+ require 'active_support/secure_random'
puts ActiveSupport::SecureRandom.hex(64)
end
-require 'active_support'
namespace :time do
namespace :zones do
desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
@@ -30,6 +30,8 @@ namespace :time do
desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
task :local do
+ require 'active_support'
+ require 'active_support/core/time'
jan_offset = Time.now.beginning_of_year.utc_offset
jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset
offset = jan_offset < jul_offset ? jan_offset : jul_offset
@@ -38,6 +40,8 @@ namespace :time do
# to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600
def build_time_zone_list(method, offset = ENV['OFFSET'])
+ require 'active_support'
+ require 'active_support/core/time'
if offset
offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
sign = $1 == '-' ? -1 : 1
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb
index 0addcb8bf3..ffd60ee662 100644
--- a/railties/test/abstract_unit.rb
+++ b/railties/test/abstract_unit.rb
@@ -13,6 +13,7 @@ gem 'mocha', '>= 0.9.5'
require 'mocha'
require 'active_support'
+require 'active_support/core/all'
require 'active_support/test_case'
if defined?(RAILS_ROOT)
diff --git a/railties/test/boot_test.rb b/railties/test/boot_test.rb
index 08fcc82e6f..2dd68857c3 100644
--- a/railties/test/boot_test.rb
+++ b/railties/test/boot_test.rb
@@ -1,6 +1,7 @@
require 'abstract_unit'
require 'initializer'
require "#{File.dirname(__FILE__)}/../environments/boot"
+require 'rails/gem_dependency'
class BootTest < Test::Unit::TestCase
def test_boot_returns_if_booted
diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb
index d9cd5148a3..ff27af5572 100644
--- a/railties/test/gem_dependency_test.rb
+++ b/railties/test/gem_dependency_test.rb
@@ -1,4 +1,5 @@
require 'plugin_test_helper'
+require 'rails/gem_dependency'
class Rails::GemDependency
public :install_command, :unpack_command
@@ -144,4 +145,46 @@ class GemDependencyTest < Test::Unit::TestCase
end
end
+ def test_gem_ignores_development_dependencies
+ dummy_gem = Rails::GemDependency.new "dummy-gem-k"
+ dummy_gem.add_load_paths
+ dummy_gem.load
+ assert_equal 1, dummy_gem.dependencies.size
+ end
+
+ def test_gem_guards_against_duplicate_unpacks
+ dummy_gem = Rails::GemDependency.new "dummy-gem-a"
+ dummy_gem.stubs(:frozen?).returns(true)
+ dummy_gem.expects(:unpack_base).never
+ dummy_gem.unpack
+ end
+
+ def test_gem_does_not_unpack_framework_gems
+ dummy_gem = Rails::GemDependency.new "dummy-gem-a"
+ dummy_gem.stubs(:framework_gem?).returns(true)
+ dummy_gem.expects(:unpack_base).never
+ dummy_gem.unpack
+ end
+
+ def test_gem_from_directory_name
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem-1.1')
+ assert_equal 'dummy-gem', dummy_gem.name
+ assert_equal '= 1.1', dummy_gem.version_requirements.to_s
+ end
+
+ def test_gem_from_invalid_directory_name
+ assert_raises RuntimeError do
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem')
+ end
+ assert_raises RuntimeError do
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy')
+ end
+ end
+
+ def test_gem_determines_build_status
+ assert_equal true, Rails::GemDependency.new("dummy-gem-a").built?
+ assert_equal true, Rails::GemDependency.new("dummy-gem-i").built?
+ assert_equal false, Rails::GemDependency.new("dummy-gem-j").built?
+ end
+
end
diff --git a/railties/test/plugin_loader_test.rb b/railties/test/plugin_loader_test.rb
index b270748dd6..c647d7b478 100644
--- a/railties/test/plugin_loader_test.rb
+++ b/railties/test/plugin_loader_test.rb
@@ -132,8 +132,8 @@ class TestPluginLoader < Test::Unit::TestCase
@loader.send :add_engine_view_paths
- assert_equal [ File.join(plugin_fixture_path('engines/engine'), 'app', 'views') ], ActionController::Base.view_paths
- assert_equal [ File.join(plugin_fixture_path('engines/engine'), 'app', 'views') ], ActionMailer::Base.view_paths
+ assert_equal [ File.join(plugin_fixture_path('engines/engine'), 'app', 'views') ], ActionController::Base.view_paths.map { |p| p.to_s }
+ assert_equal [ File.join(plugin_fixture_path('engines/engine'), 'app', 'views') ], ActionMailer::Base.view_paths.map { |p| p.to_s }
end
def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
diff --git a/railties/test/plugin_test_helper.rb b/railties/test/plugin_test_helper.rb
index 93d50dc07f..adb62de665 100644
--- a/railties/test/plugin_test_helper.rb
+++ b/railties/test/plugin_test_helper.rb
@@ -3,6 +3,7 @@ $:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
require 'test/unit'
require 'active_support'
+require 'active_support/core/all'
require 'initializer'
require File.join(File.dirname(__FILE__), 'abstract_unit')
@@ -12,7 +13,7 @@ RAILS_ROOT = '.' unless defined?(RAILS_ROOT)
class Test::Unit::TestCase
private
def plugin_fixture_root_path
- File.join(File.dirname(__FILE__), 'fixtures', 'plugins')
+ File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'plugins'))
end
def only_load_the_following_plugins!(plugins)
diff --git a/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification
new file mode 100644
index 0000000000..b3f7930948
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification
@@ -0,0 +1,29 @@
+--- !ruby/object:Gem::Specification
+name: dummy-gem-h
+version: !ruby/object:Gem::Version
+ version: 1.3.0
+platform: ruby
+authors:
+- "Nobody"
+date: 2008-10-03 00:00:00 -04:00
+dependencies:
+files:
+- lib
+- lib/dummy-gem-h.rb
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+specification_version: 2
+summary: Dummy Gem H
diff --git a/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb b/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb
new file mode 100644
index 0000000000..0f91234936
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb
@@ -0,0 +1 @@
+DUMMY_GEM_H_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification
new file mode 100644
index 0000000000..50b4969da5
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification
@@ -0,0 +1,41 @@
+--- !ruby/object:Gem::Specification
+name: dummy-gem-i
+version: !ruby/object:Gem::Version
+ version: 1.3.0
+platform: ruby
+authors:
+- "Nobody"
+date: 2008-10-03 00:00:00 -04:00
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: dummy-gem-i
+ type: :runtime
+ version_requirement:
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: 1.0.0
+ version:
+extensions:
+- ext/dummy-gem-i/extconf.rb
+files:
+- lib
+- lib/dummy-gem-i.rb
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+specification_version: 2
+summary: Dummy Gem G
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile b/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile
diff --git a/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb b/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb
new file mode 100644
index 0000000000..2f9a376c2c
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb
@@ -0,0 +1 @@
+DUMMY_GEM_I_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification
new file mode 100644
index 0000000000..2c456546fc
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification
@@ -0,0 +1,41 @@
+--- !ruby/object:Gem::Specification
+name: dummy-gem-j
+version: !ruby/object:Gem::Version
+ version: 1.3.0
+platform: ruby
+authors:
+- "Nobody"
+date: 2008-10-03 00:00:00 -04:00
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: dummy-gem-j
+ type: :runtime
+ version_requirement:
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: 1.0.0
+ version:
+extensions:
+- ext/dummy-gem-j/extconf.rb
+files:
+- lib
+- lib/dummy-gem-j.rb
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+specification_version: 2
+summary: Dummy Gem G
diff --git a/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb b/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb
new file mode 100644
index 0000000000..8ecd363ff8
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb
@@ -0,0 +1 @@
+DUMMY_GEM_J_VERSION="1.0.0"
diff --git a/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification b/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification
new file mode 100644
index 0000000000..20edd0f856
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification
@@ -0,0 +1,49 @@
+--- !ruby/object:Gem::Specification
+name: dummy-gem-k
+version: !ruby/object:Gem::Version
+ version: 1.3.0
+platform: ruby
+authors:
+- "Nobody"
+date: 2008-10-03 00:00:00 -04:00
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: dummy-gem-k
+ type: :runtime
+ version_requirement:
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: 1.0.0
+ version:
+- !ruby/object:Gem::Dependency
+ name: dummy-gem-h
+ type: :development
+ version_requirement:
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: 1.0.0
+ version:
+files:
+- lib
+- lib/dummy-gem-k.rb
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ version: "0"
+ version:
+requirements: []
+specification_version: 2
+summary: Dummy Gem I
diff --git a/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb b/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb
new file mode 100644
index 0000000000..97fb1d69ce
--- /dev/null
+++ b/railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb
@@ -0,0 +1 @@
+DUMMY_GEM_K_VERSION="1.0.0"