([\w ]*?)<\/a>/s).uniq
end
end
rescue Exception
@@ -428,7 +429,20 @@ end_message
# If the directory is not in the status list, it
# has no modifications so we can simply remove it
system("svn rm #{destination}")
- end
+ end
+ elsif options[:git]
+ if options[:git][:new][relative_destination]
+ # file has been added, but not committed
+ system("git reset HEAD #{relative_destination}")
+ FileUtils.rm(destination)
+ elsif options[:git][:modified][relative_destination]
+ # file is committed and modified
+ system("git rm -f #{relative_destination}")
+ else
+ # If the directory is not in the status list, it
+ # has no modifications so we can simply remove it
+ system("git rm #{relative_destination}")
+ end
else
FileUtils.rm(destination)
end
@@ -465,6 +479,8 @@ end_message
# has no modifications so we can simply remove it
system("svn rm #{path}")
end
+ # I don't think git needs to remove directories?..
+ # or maybe they have special consideration...
else
FileUtils.rmdir(path)
end
@@ -537,7 +553,7 @@ end_message
def readme(*args)
logger.readme args.join(', ')
end
-
+
def migration_template(relative_source, relative_destination, options = {})
migration_directory relative_destination
logger.migration_template file_name
diff --git a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index 1dd72f34..2f2dd826 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -7,8 +7,9 @@ class AppGenerator < Rails::Generator::Base
Config::CONFIG['ruby_install_name'])
DATABASES = %w(mysql oracle postgresql sqlite2 sqlite3 frontbase)
+ DEFAULT_DATABASE = 'sqlite3'
- default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || "sqlite3"),
+ default_options :db => (ENV["RAILS_DEFAULT_DATABASE"] || DEFAULT_DATABASE),
:shebang => DEFAULT_SHEBANG, :freeze => false
mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
@@ -51,17 +52,17 @@ class AppGenerator < Rails::Generator::Base
m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
m.template "helpers/test_helper.rb", "test/test_helper.rb"
- # database.yml and .htaccess
+ # database.yml and routes.rb
m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
:app_name => @app_name,
:socket => options[:db] == "mysql" ? mysql_socket_location : nil
}
- m.template "configs/routes.rb", "config/routes.rb"
- m.template "configs/apache.conf", "public/.htaccess"
+ m.template "configs/routes.rb", "config/routes.rb"
# Initializers
m.template "configs/initializers/inflections.rb", "config/initializers/inflections.rb"
- m.template "configs/initializers/mime_types.rb", "config/initializers/mime_types.rb"
+ m.template "configs/initializers/mime_types.rb", "config/initializers/mime_types.rb"
+ m.template "configs/initializers/new_rails_defaults.rb", "config/initializers/new_rails_defaults.rb"
# Environments
m.file "environments/boot.rb", "config/boot.rb"
@@ -71,7 +72,7 @@ class AppGenerator < Rails::Generator::Base
m.file "environments/test.rb", "config/environments/test.rb"
# Scripts
- %w( about console destroy generate performance/benchmarker performance/profiler performance/request process/reaper process/spawner process/inspector runner server plugin ).each do |file|
+ %w( about console dbconsole destroy generate performance/benchmarker performance/profiler performance/request process/reaper process/spawner process/inspector runner server plugin ).each do |file|
m.file "bin/#{file}", "script/#{file}", script_options
end
@@ -119,8 +120,8 @@ class AppGenerator < Rails::Generator::Base
"Default: #{DEFAULT_SHEBANG}") { |v| options[:shebang] = v }
opt.on("-d", "--database=name", String,
- "Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).",
- "Default: mysql") { |v| options[:db] = v }
+ "Preconfigure for selected database (options: #{DATABASES.join('/')}).",
+ "Default: #{DEFAULT_DATABASE}") { |v| options[:db] = v }
opt.on("-f", "--freeze",
"Freeze Rails in vendor/rails from the gems generating the skeleton",
@@ -154,8 +155,6 @@ class AppGenerator < Rails::Generator::Base
test/fixtures
test/functional
test/integration
- test/mocks/development
- test/mocks/test
test/unit
vendor
vendor/plugins
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb
index da71b5f0..cda2659e 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb
@@ -1,10 +1,7 @@
class <%= class_name %>Controller < ApplicationController
-<% if options[:scaffold] -%>
- scaffold :<%= singular_name %>
-<% end -%>
<% for action in actions -%>
-
def <%= action %>
end
+
<% end -%>
end
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
index 935beafa..38e0ae71 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= class_name %>ControllerTest < ActionController::TestCase
# Replace this with your real tests.
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
index 61688aee..149b987d 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
@@ -1,4 +1,4 @@
-require "#{File.dirname(__FILE__)}<%= '/..' * class_nesting_depth %>/../test_helper"
+require 'test_helper'
class <%= class_name %>Test < ActionController::IntegrationTest
# fixtures :your, :models
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb
index 3ff4f039..dc1202d7 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb
@@ -11,12 +11,8 @@ class MailerGenerator < Rails::Generator::NamedBase
m.directory File.join('test/fixtures', file_path)
# Mailer class and unit test.
- m.template "mailer.rb", File.join('app/models',
- class_path,
- "#{file_name}.rb")
- m.template "unit_test.rb", File.join('test/unit',
- class_path,
- "#{file_name}_test.rb")
+ m.template "mailer.rb", File.join('app/models', class_path, "#{file_name}.rb")
+ m.template "unit_test.rb", File.join('test/unit', class_path, "#{file_name}_test.rb")
# View template and fixture for each action.
actions.each do |action|
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb
index 127495fc..ce15ae9d 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb
@@ -1,13 +1,15 @@
class <%= class_name %> < ActionMailer::Base
+
<% for action in actions -%>
def <%= action %>(sent_at = Time.now)
- @subject = '<%= class_name %>#<%= action %>'
- @body = {}
- @recipients = ''
- @from = ''
- @sent_on = sent_at
- @headers = {}
+ subject '<%= class_name %>#<%= action %>'
+ recipients ''
+ from ''
+ sent_on sent_at
+
+ body :greeting => 'Hi,'
end
<% end -%>
+
end
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
index dcd02062..0b4b2ec6 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= class_name %>Test < ActionMailer::TestCase
tests <%= class_name %>
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE b/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE
index 3e914a5d..b83c6579 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE
@@ -2,7 +2,7 @@ Description:
Stubs out a new database migration. Pass the migration name, either
CamelCased or under_scored, and an optional list of attribute pairs as arguments.
- A migration class is generated in db/migrate prefixed by the latest migration number.
+ A migration class is generated in db/migrate prefixed by a timestamp of the current date and time.
You can name your migration in either of these formats to generate add/remove
column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
@@ -10,12 +10,12 @@ Description:
Example:
`./script/generate migration AddSslFlag`
- With 4 existing migrations, this creates the AddSslFlag migration in
- db/migrate/005_add_ssl_flag.rb
+ If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration
+ db/migrate/20080514090912_add_ssl_flag.rb
`./script/generate migration AddTitleBodyToPost title:string body:text published:boolean`
- This will create the AddTitleBodyToPost in db/migrate/005_add_title_body_to_post.rb with
+ This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with
this in the Up migration:
add_column :posts, :title, :string
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
index 9bb3ca41..96bd34ad 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= class_name %>Test < ActiveSupport::TestCase
# Replace this with your real tests.
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
index b432f04f..1faf8ed9 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= class_name %>ObserverTest < Test::Unit::TestCase
# Replace this with your real tests.
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
index 19363a82..fbb69fcc 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
# Replace this with your real tests.
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
index c9ce49a6..e2902bf4 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
@@ -34,7 +34,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
m.class_collisions(class_path, "#{class_name}")
- # Controller, helper, views, and test directories.
+ # Controller, helper, views, test and stylesheets directories.
m.directory(File.join('app/models', class_path))
m.directory(File.join('app/controllers', controller_class_path))
m.directory(File.join('app/helpers', controller_class_path))
@@ -42,6 +42,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.directory(File.join('app/views/layouts', controller_class_path))
m.directory(File.join('test/functional', controller_class_path))
m.directory(File.join('test/unit', class_path))
+ m.directory(File.join('public/stylesheets', class_path))
for action in scaffold_views
m.template(
@@ -54,8 +55,6 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb"))
m.template('style.css', 'public/stylesheets/scaffold.css')
- m.dependency 'model', [name] + @args, :collision => :skip
-
m.template(
'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
)
@@ -64,6 +63,8 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
m.route_resources controller_file_name
+
+ m.dependency 'model', [name] + @args, :collision => :skip
end
end
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
index 2b1f6520..3b430a20 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
+require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
def test_should_get_index
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css
index 879e85b3..093c2099 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css
@@ -52,23 +52,3 @@ a:hover { color: #fff; background-color:#000; }
list-style: square;
}
-div.uploadStatus {
- margin: 5px;
-}
-
-div.progressBar {
- margin: 5px;
-}
-
-div.progressBar div.border {
- background-color: #fff;
- border: 1px solid gray;
- width: 100%;
-}
-
-div.progressBar div.background {
- background-color: #333;
- height: 18px;
- width: 0%;
-}
-
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb
index 8a65b50d..e2899755 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb
@@ -1,14 +1,13 @@
Editing <%= singular_name %>
-<%%= error_messages_for :<%= singular_name %> %>
-
<%% form_for(@<%= singular_name %>) do |f| %>
+ <%%= f.error_messages %>
+
<% for attribute in attributes -%>
- <%= attribute.column.human_name %>
+ <%%= f.label :<%= attribute.name %> %>
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
-
<% end -%>
<%%= f.submit "Update" %>
diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb
index 96f59900..c47e8117 100644
--- a/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb
+++ b/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb
@@ -1,14 +1,13 @@
New <%= singular_name %>
-<%%= error_messages_for :<%= singular_name %> %>
-
<%% form_for(@<%= singular_name %>) do |f| %>
+ <%%= f.error_messages %>
+
<% for attribute in attributes -%>
- <%= attribute.column.human_name %>
+ <%%= f.label :<%= attribute.name %> %>
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
-
<% end -%>
<%%= f.submit "Create" %>
diff --git a/vendor/rails/railties/lib/rails_generator/lookup.rb b/vendor/rails/railties/lib/rails_generator/lookup.rb
index 598cb79e..1f28c39d 100644
--- a/vendor/rails/railties/lib/rails_generator/lookup.rb
+++ b/vendor/rails/railties/lib/rails_generator/lookup.rb
@@ -1,3 +1,5 @@
+require 'pathname'
+
require File.dirname(__FILE__) + '/spec'
class Object
@@ -104,8 +106,10 @@ module Rails
if defined? ::RAILS_ROOT
sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators")
sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
- sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators")
- sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/rails_generators")
+ Rails.configuration.plugin_paths.each do |path|
+ relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT))
+ sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/**/{,rails_}generators")
+ end
end
sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
if Object.const_defined?(:Gem)
@@ -139,7 +143,7 @@ module Rails
private
# Lookup and cache every generator from the source list.
def cache
- @cache ||= sources.inject([]) { |cache, source| cache + source.map }
+ @cache ||= sources.inject([]) { |cache, source| cache + source.to_a }
end
# Clear the cache whenever the source list changes.
diff --git a/vendor/rails/railties/lib/rails_generator/options.rb b/vendor/rails/railties/lib/rails_generator/options.rb
index 042e0510..5f6aefa9 100644
--- a/vendor/rails/railties/lib/rails_generator/options.rb
+++ b/vendor/rails/railties/lib/rails_generator/options.rb
@@ -136,6 +136,13 @@ module Rails
opt
end
end
+ opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do
+ options[:git] = `git status`.inject({:new => {}, :modified => {}}) do |opt, e|
+ opt[:new][e.chomp[14..-1]] = true if e =~ /new file:/
+ opt[:modified][e.chomp[14..-1]] = true if e =~ /modified:/
+ opt
+ end
+ end
end
end
diff --git a/vendor/rails/railties/lib/rails_generator/scripts.rb b/vendor/rails/railties/lib/rails_generator/scripts.rb
index bd380aad..f857f68d 100644
--- a/vendor/rails/railties/lib/rails_generator/scripts.rb
+++ b/vendor/rails/railties/lib/rails_generator/scripts.rb
@@ -43,18 +43,21 @@ module Rails
def usage_message
usage = "\nInstalled Generators\n"
- Rails::Generator::Base.sources.inject({}) do |mem, source|
+ Rails::Generator::Base.sources.inject([]) do |mem, source|
+ # Using an association list instead of a hash to preserve order,
+ # for esthetic reasons more than anything else.
label = source.label.to_s.capitalize
- mem[label] ||= []
- mem[label] |= source.names
+ pair = mem.assoc(label)
+ mem << (pair = [label, []]) if pair.nil?
+ pair[1] |= source.names
mem
- end.each_pair do |label, names|
+ end.each do |label, names|
usage << " #{label}: #{names.join(', ')}\n" unless names.empty?
end
usage << < "f3f1be90053fa851... (some long string)"
-
module Rails
+ # A class for creating random secret keys. This class will do its best to create a
+ # random secret key that's as secure as possible, using whatever methods are
+ # available on the current platform. For example:
+ #
+ # generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name")
+ # generator.generate_secret # => "f3f1be90053fa851... (some long string)"
class SecretKeyGenerator
GENERATORS = [ :secure_random, :win32_api, :urandom, :openssl, :prng ].freeze
@@ -77,7 +76,12 @@ module Rails
OpenSSL::Random.seed(rand(0).to_s + Time.now.usec.to_s)
end
data = OpenSSL::BN.rand(2048, -1, false).to_s
- return OpenSSL::Digest::SHA512.new(data).hexdigest
+
+ if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
+ OpenSSL::Digest::SHA512.new(data).hexdigest
+ else
+ generate_secret_with_prng
+ end
end
# Generate a random secret key with /dev/urandom.
diff --git a/vendor/rails/railties/lib/source_annotation_extractor.rb b/vendor/rails/railties/lib/source_annotation_extractor.rb
index 88442265..591fd6f6 100644
--- a/vendor/rails/railties/lib/source_annotation_extractor.rb
+++ b/vendor/rails/railties/lib/source_annotation_extractor.rb
@@ -1,5 +1,26 @@
+# Implements the logic behind the rake tasks for annotations like
+#
+# rake notes
+# rake notes:optimize
+#
+# and friends. See rake -T notes and railties/lib/tasks/annotations.rake.
+#
+# Annotation objects are triplets :line, :tag, :text that
+# represent the line where the annotation lives, its tag, and its text. Note
+# the filename is not stored.
+#
+# Annotations are looked for in comments and modulus whitespace they have to
+# start with the tag optionally followed by a colon. Everything up to the end
+# of the line (or closing ERb comment tag) is considered to be their text.
class SourceAnnotationExtractor
class Annotation < Struct.new(:line, :tag, :text)
+
+ # Returns a representation of the annotation that looks like this:
+ #
+ # [126] [TODO] This algorithm is simple and clearly correct, make it faster.
+ #
+ # If +options+ has a flag :tag the tag is shown as in the example above.
+ # Otherwise the string contains just line and text.
def to_s(options={})
s = "[%3d] " % line
s << "[#{tag}] " if options[:tag]
@@ -7,6 +28,12 @@ class SourceAnnotationExtractor
end
end
+ # Prints all annotations with tag +tag+ under the root directories +app+, +lib+,
+ # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+,
+ # +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The +options+
+ # hash is passed to each annotation's +to_s+.
+ #
+ # This class method is the single entry point for the rake tasks.
def self.enumerate(tag, options={})
extractor = new(tag)
extractor.display(extractor.find, options)
@@ -18,10 +45,18 @@ class SourceAnnotationExtractor
@tag = tag
end
+ # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
+ # with their annotations. Only files with annotations are included, and only
+ # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
+ # are taken into account.
def find(dirs=%w(app lib test))
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
end
+ # Returns a hash that maps filenames under +dir+ (recursively) to arrays
+ # with their annotations. Only files with annotations are included, and only
+ # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
+ # are taken into account.
def find_in(dir)
results = {}
@@ -40,6 +75,9 @@ class SourceAnnotationExtractor
results
end
+ # If +file+ is the filename of a file that contains annotations this method returns
+ # a hash with a single entry that maps +file+ to an array of its annotations.
+ # Otherwise it returns an empty hash.
def extract_annotations_from(file, pattern)
lineno = 0
result = File.readlines(file).inject([]) do |list, line|
@@ -50,6 +88,8 @@ class SourceAnnotationExtractor
result.empty? ? {} : { file => result }
end
+ # Prints the mapping from filenames to annotations in +results+ ordered by filename.
+ # The +options+ hash is passed to each annotation's +to_s+.
def display(results, options={})
results.keys.sort.each do |file|
puts "#{file}:"
diff --git a/vendor/rails/railties/lib/tasks/databases.rake b/vendor/rails/railties/lib/tasks/databases.rake
index 2ecd09af..8077d0a4 100644
--- a/vendor/rails/railties/lib/tasks/databases.rake
+++ b/vendor/rails/railties/lib/tasks/databases.rake
@@ -5,22 +5,18 @@ namespace :db do
ActiveRecord::Base.configurations.each_value do |config|
# Skip entries that don't have a database key, such as the first entry here:
#
- # defaults: &defaults
- # adapter: mysql
+ # defaults: &defaults
+ # adapter: mysql
# username: root
- # password:
+ # password:
# host: localhost
- #
- # development:
+ #
+ # development:
# database: blog_development
# <<: *defaults
next unless config['database']
# Only connect to local databases
- if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
- create_database(config)
- else
- p "This task only creates local databases. #{config['database']} is on a remote host."
- end
+ local_database?(config) { create_database(config) }
end
end
end
@@ -40,21 +36,29 @@ namespace :db do
@charset = ENV['CHARSET'] || 'utf8'
@collation = ENV['COLLATION'] || 'utf8_general_ci'
begin
- ActiveRecord::Base.establish_connection(config.merge({'database' => nil}))
- ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation})
+ ActiveRecord::Base.establish_connection(config.merge('database' => nil))
+ ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation))
ActiveRecord::Base.establish_connection(config)
rescue
- $stderr.puts "Couldn't create database for #{config.inspect}"
+ $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)"
end
when 'postgresql'
- `createdb "#{config['database']}" -E utf8`
+ @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
+ begin
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
+ ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
+ ActiveRecord::Base.establish_connection(config)
+ rescue
+ $stderr.puts $!, *($!.backtrace)
+ $stderr.puts "Couldn't create database for #{config.inspect}"
+ end
when 'sqlite'
`sqlite "#{config['database']}"`
when 'sqlite3'
`sqlite3 "#{config['database']}"`
end
else
- p "#{config['database']} already exists"
+ $stderr.puts "#{config['database']} already exists"
end
end
@@ -65,20 +69,30 @@ namespace :db do
# Skip entries that don't have a database key
next unless config['database']
# Only connect to local databases
- if config['host'] == 'localhost' || config['host'].blank?
- drop_database(config)
- else
- p "This task only drops local databases. #{config['database']} is on a remote host."
- end
+ local_database?(config) { drop_database(config) }
end
end
end
desc 'Drops the database for the current RAILS_ENV'
task :drop => :environment do
- drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development'])
+ config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
+ begin
+ drop_database(config)
+ rescue Exception => e
+ puts "Couldn't drop #{config['database']} : #{e.inspect}"
+ end
end
+ def local_database?(config, &block)
+ if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
+ yield
+ else
+ puts "This task only modifies local databases. #{config['database']} is on a remote host."
+ end
+ end
+
+
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
task :migrate => :environment do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
@@ -92,13 +106,29 @@ namespace :db do
desc 'Resets your database using your migrations for the current environment'
task :reset => ["db:drop", "db:create", "db:migrate"]
+
+ desc 'Runs the "up" for a given migration VERSION.'
+ task :up => :environment do
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
+ raise "VERSION is required" unless version
+ ActiveRecord::Migrator.run(:up, "db/migrate/", version)
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
+ end
+
+ desc 'Runs the "down" for a given migration VERSION.'
+ task :down => :environment do
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
+ raise "VERSION is required" unless version
+ ActiveRecord::Migrator.run(:down, "db/migrate/", version)
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
+ end
end
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
task :rollback => :environment do
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
- version = ActiveRecord::Migrator.current_version - step
- ActiveRecord::Migrator.migrate('db/migrate/', version)
+ ActiveRecord::Migrator.rollback('db/migrate/', step)
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
desc 'Drops and recreates the database from db/schema.rb for the current environment.'
@@ -143,7 +173,7 @@ namespace :db do
pending_migrations.each do |pending_migration|
puts ' %4d %s' % [pending_migration.version, pending_migration.name]
end
- abort "Run `rake db:migrate` to update your database then try again."
+ abort %{Run "rake db:migrate" to update your database then try again.}
end
end
end
@@ -157,21 +187,21 @@ namespace :db do
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
end
end
-
+
desc "Search for a fixture given a LABEL or ID."
task :identify => :environment do
require "active_record/fixtures"
label, id = ENV["LABEL"], ENV["ID"]
raise "LABEL or ID required" if label.blank? && id.blank?
-
+
puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
-
+
Dir["#{RAILS_ROOT}/test/fixtures/**/*.yml"].each do |file|
if data = YAML::load(ERB.new(IO.read(file)).result)
data.keys.each do |key|
key_id = Fixtures.identify(key)
-
+
if key == label || key_id == id.to_i
puts "#{file}: #{key} (#{key_id})"
end
@@ -284,14 +314,9 @@ namespace :db do
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
when "postgresql"
- ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
- ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
- ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
- enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"]
-
ActiveRecord::Base.clear_active_connections!
- `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
- `createdb #{enc_option} -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
+ drop_database(abcs['test'])
+ create_database(abcs['test'])
when "sqlite","sqlite3"
dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
File.delete(dbfile) if File.exist?(dbfile)
@@ -331,9 +356,7 @@ namespace :db do
desc "Clear the sessions table"
task :clear => :environment do
- session_table = 'session'
- session_table = Inflector.pluralize(session_table) if ActiveRecord::Base.pluralize_table_names
- ActiveRecord::Base.connection.execute "DELETE FROM #{session_table}"
+ ActiveRecord::Base.connection.execute "DELETE FROM #{session_table_name}"
end
end
end
@@ -343,9 +366,10 @@ def drop_database(config)
when 'mysql'
ActiveRecord::Base.connection.drop_database config['database']
when /^sqlite/
- FileUtils.rm_f(File.join(RAILS_ROOT, config['database']))
+ FileUtils.rm(File.join(RAILS_ROOT, config['database']))
when 'postgresql'
- `dropdb "#{config['database']}"`
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
+ ActiveRecord::Base.connection.drop_database config['database']
end
end
diff --git a/vendor/rails/railties/lib/tasks/documentation.rake b/vendor/rails/railties/lib/tasks/documentation.rake
index 41e52f13..331b2450 100644
--- a/vendor/rails/railties/lib/tasks/documentation.rake
+++ b/vendor/rails/railties/lib/tasks/documentation.rake
@@ -65,11 +65,11 @@ namespace :doc do
options << '-T html'
files.include("#{plugin_base}/lib/**/*.rb")
- if File.exists?("#{plugin_base}/README")
+ if File.exist?("#{plugin_base}/README")
files.include("#{plugin_base}/README")
options << "--main '#{plugin_base}/README'"
end
- files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG")
+ files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG")
options << files.to_s
diff --git a/vendor/rails/railties/lib/tasks/framework.rake b/vendor/rails/railties/lib/tasks/framework.rake
index ebc24f46..71aea098 100644
--- a/vendor/rails/railties/lib/tasks/framework.rake
+++ b/vendor/rails/railties/lib/tasks/framework.rake
@@ -38,37 +38,33 @@ namespace :rails do
end
end
- desc "Lock to latest Edge Rails or a specific revision with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)"
+ desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0'
task :edge do
- $verbose = false
- `svn --version` rescue nil
- unless !$?.nil? && $?.success?
- $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails"
- exit 1
- end
-
- rm_rf "vendor/rails"
- mkdir_p "vendor/rails"
-
- svn_root = "http://dev.rubyonrails.org/svn/rails/"
+ require 'open-uri'
+ version = ENV["RELEASE"] || "edge"
+ target = "rails_#{version}.zip"
+ url = "http://dev.rubyonrails.org/archives/#{target}"
- if ENV['TAG']
- rails_svn = "#{svn_root}/tags/#{ENV['TAG']}"
- touch "vendor/rails/TAG_#{ENV['TAG']}"
- else
- rails_svn = "#{svn_root}/trunk"
-
- if ENV['REVISION'].nil?
- ENV['REVISION'] = /^r(\d+)/.match(%x{svn -qr HEAD log #{svn_root}})[1]
- puts "REVISION not set. Using HEAD, which is revision #{ENV['REVISION']}."
+ chdir 'vendor' do
+ puts "Downloading Rails from #{url}"
+ File.open('rails.zip', 'wb') do |dst|
+ open url do |src|
+ while chunk = src.read(4096)
+ dst << chunk
+ end
+ end
end
- touch "vendor/rails/REVISION_#{ENV['REVISION']}"
+ puts 'Unpacking Rails'
+ rm_rf 'rails'
+ `unzip rails.zip`
+ %w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner|
+ rm_f goner
+ end
end
- for framework in %w(railties actionpack activerecord actionmailer activesupport activeresource)
- system "svn export #{rails_svn}/#{framework} vendor/rails/#{framework}" + (ENV['REVISION'] ? " -r #{ENV['REVISION']}" : "")
- end
+ puts 'Updating current scripts, javascripts, and configuration settings'
+ Rake::Task['rails:update'].invoke
end
end
@@ -105,7 +101,7 @@ namespace :rails do
require 'railties_path'
project_dir = RAILS_ROOT + '/public/javascripts/'
scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
- scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exists?(project_dir + 'application.js')
+ scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js')
FileUtils.cp(scripts, project_dir)
end
diff --git a/vendor/rails/railties/lib/tasks/gems.rake b/vendor/rails/railties/lib/tasks/gems.rake
new file mode 100644
index 00000000..0321e60e
--- /dev/null
+++ b/vendor/rails/railties/lib/tasks/gems.rake
@@ -0,0 +1,64 @@
+desc "List the gems that this rails application depends on"
+task :gems => 'gems:base' do
+ Rails.configuration.gems.each do |gem|
+ code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " "
+ puts "[#{code}] #{gem.name} #{gem.requirement.to_s}"
+ end
+ puts
+ puts "I = Installed"
+ puts "F = Frozen"
+end
+
+namespace :gems do
+ task :base do
+ $rails_gem_installer = true
+ Rake::Task[:environment].invoke
+ end
+
+ desc "Build any native extensions for unpacked gems"
+ task :build do
+ $rails_gem_installer = true
+ require 'rails/gem_builder'
+ Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*')].each do |gem_dir|
+ spec_file = File.join(gem_dir, '.specification')
+ next unless File.exists?(spec_file)
+ specification = YAML::load_file(spec_file)
+ next unless ENV['GEM'].blank? || ENV['GEM'] == specification.name
+ Rails::GemBuilder.new(specification, gem_dir).build_extensions
+ puts "Built gem: '#{gem_dir}'"
+ end
+ end
+
+ desc "Installs all required gems for this application."
+ task :install => :base do
+ require 'rubygems'
+ require 'rubygems/gem_runner'
+ Rails.configuration.gems.each { |gem| gem.install unless gem.loaded? }
+ end
+
+ desc "Unpacks the specified gem into vendor/gems."
+ task :unpack => :base do
+ require 'rubygems'
+ require 'rubygems/gem_runner'
+ Rails.configuration.gems.each do |gem|
+ next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
+ gem.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) if gem.loaded?
+ end
+ end
+
+ namespace :unpack do
+ desc "Unpacks the specified gems and its dependencies into vendor/gems"
+ task :dependencies => :unpack do
+ require 'rubygems'
+ require 'rubygems/gem_runner'
+ Rails.configuration.gems.each do |gem|
+ next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
+ gem.dependencies.each do |dependency|
+ dependency.add_load_paths # double check that we have not already unpacked
+ next if dependency.frozen?
+ dependency.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems'))
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/rails/railties/lib/tasks/misc.rake b/vendor/rails/railties/lib/tasks/misc.rake
index e44ab2cf..61042595 100644
--- a/vendor/rails/railties/lib/tasks/misc.rake
+++ b/vendor/rails/railties/lib/tasks/misc.rake
@@ -8,3 +8,50 @@ desc 'Generate a crytographically secure secret key. This is typically used to g
task :secret do
puts Rails::SecretKeyGenerator.new(ENV['ID']).generate_secret
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'
+ task :all do
+ build_time_zone_list(:all)
+ end
+
+ desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
+ task :us do
+ build_time_zone_list(:us_zones)
+ end
+
+ desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
+ task :local do
+ 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
+ build_time_zone_list(:all, offset)
+ end
+
+ # 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'])
+ if offset
+ offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
+ sign = $1 == '-' ? -1 : 1
+ hours, minutes = $2.to_f, $3.to_f
+ ((hours * 3600) + (minutes.to_f * 60)) * sign
+ elsif offset.to_f.abs <= 13
+ offset.to_f * 3600
+ else
+ offset.to_f
+ end
+ end
+ previous_offset = nil
+ TimeZone.__send__(method).each do |zone|
+ if offset.nil? || offset == zone.utc_offset
+ puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset
+ puts zone.name
+ previous_offset = zone.utc_offset
+ end
+ end
+ puts "\n"
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/rails/railties/lib/tasks/testing.rake b/vendor/rails/railties/lib/tasks/testing.rake
index f495031b..cc2376cb 100644
--- a/vendor/rails/railties/lib/tasks/testing.rake
+++ b/vendor/rails/railties/lib/tasks/testing.rake
@@ -13,11 +13,11 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
# For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
test = "#{modified_test_path}/#{source_file}_test.rb"
- tests.push test if File.exists?(test)
+ tests.push test if File.exist?(test)
# For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
- FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exists?(test)
+ FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
return tests
@@ -38,7 +38,7 @@ module Kernel
end
end
-desc 'Test all units and functionals'
+desc 'Run all unit, functional and integration tests'
task :test do
errors = %w(test:units test:functionals test:integration).collect do |task|
begin
diff --git a/vendor/rails/railties/lib/test_help.rb b/vendor/rails/railties/lib/test_help.rb
index 3b91438c..22ce9ab6 100644
--- a/vendor/rails/railties/lib/test_help.rb
+++ b/vendor/rails/railties/lib/test_help.rb
@@ -18,3 +18,11 @@ ActionController::IntegrationTest.fixture_path = Test::Unit::TestCase.fixture_pa
def create_fixtures(*table_names)
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
end
+
+begin
+ require_library_or_gem 'ruby-debug'
+ Debugger.start
+ Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
+rescue LoadError
+ # ruby-debug wasn't available so neither can the debugging be
+end
\ No newline at end of file
diff --git a/vendor/rails/railties/test/boot_test.rb b/vendor/rails/railties/test/boot_test.rb
index 36fae307..7736a8f4 100644
--- a/vendor/rails/railties/test/boot_test.rb
+++ b/vendor/rails/railties/test/boot_test.rb
@@ -1,4 +1,4 @@
-require "#{File.dirname(__FILE__)}/abstract_unit"
+require 'abstract_unit'
require 'initializer'
require "#{File.dirname(__FILE__)}/../environments/boot"
@@ -36,6 +36,7 @@ class BootTest < Test::Unit::TestCase
def test_boot_vendor_rails_by_default
Rails.expects(:booted?).returns(false)
+ Rails.expects(:preinitialize)
File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(true)
Rails::VendorBoot.any_instance.expects(:run).returns('result')
assert_equal 'result', Rails.boot!
@@ -43,6 +44,7 @@ class BootTest < Test::Unit::TestCase
def test_boot_gem_rails_otherwise
Rails.expects(:booted?).returns(false)
+ Rails.expects(:preinitialize)
File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(false)
Rails::GemBoot.any_instance.expects(:run).returns('result')
assert_equal 'result', Rails.boot!
diff --git a/vendor/rails/railties/test/console_app_test.rb b/vendor/rails/railties/test/console_app_test.rb
index ac499e0f..6cfc907b 100644
--- a/vendor/rails/railties/test/console_app_test.rb
+++ b/vendor/rails/railties/test/console_app_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/abstract_unit'
+require 'abstract_unit'
require 'action_controller' # console_app uses 'action_controller/integration'
@@ -13,17 +13,20 @@ require 'console_app'
Test::Unit.run = false
class ConsoleAppTest < Test::Unit::TestCase
- def test_reload_should_fire_preparation_callbacks
- a = b = c = nil
+ uses_mocha 'console reload test' do
+ def test_reload_should_fire_preparation_callbacks
+ a = b = c = nil
- Dispatcher.to_prepare { a = b = c = 1 }
- Dispatcher.to_prepare { b = c = 2 }
- Dispatcher.to_prepare { c = 3 }
+ Dispatcher.to_prepare { a = b = c = 1 }
+ Dispatcher.to_prepare { b = c = 2 }
+ Dispatcher.to_prepare { c = 3 }
+ ActionController::Routing::Routes.expects(:reload)
- reload!
+ reload!
- assert_equal 1, a
- assert_equal 2, b
- assert_equal 3, c
+ assert_equal 1, a
+ assert_equal 2, b
+ assert_equal 3, c
+ end
end
end
diff --git a/vendor/rails/railties/test/fcgi_dispatcher_test.rb b/vendor/rails/railties/test/fcgi_dispatcher_test.rb
index 7949cb65..64d054d4 100644
--- a/vendor/rails/railties/test/fcgi_dispatcher_test.rb
+++ b/vendor/rails/railties/test/fcgi_dispatcher_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + "/abstract_unit"
+require 'abstract_unit'
uses_mocha 'fcgi dispatcher tests' do
@@ -59,11 +59,12 @@ class RailsFCGIHandlerTest < Test::Unit::TestCase
@handler.process!
end
- def test_restart_handler
+ def test_restart_handler_outside_request
@handler.expects(:dispatcher_log).with(:info, "asked to restart ASAP")
+ @handler.expects(:restart!).once
@handler.send(:restart_handler, nil)
- assert_equal :restart, @handler.when_ready
+ assert_equal nil, @handler.when_ready
end
def test_install_signal_handler_should_log_on_bad_signal
@@ -123,6 +124,24 @@ end
class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
+ class ::RailsFCGIHandler
+ attr_accessor :signal
+ alias_method :old_gc_countdown, :gc_countdown
+ def gc_countdown
+ signal ? Process.kill(signal, $$) : old_gc_countdown
+ end
+ end
+
+ class ::Dispatcher
+ class << self
+ attr_accessor :signal
+ alias_method :old_dispatch, :dispatch
+ def dispatch(cgi)
+ signal ? Process.kill(signal, $$) : old_dispatch
+ end
+ end
+ end
+
def setup
@log = StringIO.new
@handler = RailsFCGIHandler.new(@log)
@@ -131,7 +150,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
def test_interrupted_via_HUP_when_not_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- @handler.expects(:gc_countdown).returns { Process.kill 'HUP', $$ }
+ @handler.expects(:signal).times(2).returns('HUP')
@handler.expects(:reload!).once
@handler.expects(:close_connection).never
@@ -144,7 +163,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
def test_interrupted_via_HUP_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'HUP', $$ }
+ Dispatcher.expects(:signal).times(2).returns('HUP')
@handler.expects(:reload!).once
@handler.expects(:close_connection).never
@@ -157,7 +176,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
def test_interrupted_via_USR1_when_not_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- @handler.expects(:gc_countdown).returns { Process.kill 'USR1', $$ }
+ @handler.expects(:signal).times(2).returns('USR1')
@handler.expects(:exit_handler).never
@handler.expects(:reload!).never
@@ -171,7 +190,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
def test_interrupted_via_USR1_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'USR1', $$ }
+ Dispatcher.expects(:signal).times(2).returns('USR1')
@handler.expects(:reload!).never
@handler.expects(:close_connection).with(cgi).once
@@ -181,10 +200,25 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
assert_equal :exit, @handler.when_ready
end
+ def test_restart_via_USR2_when_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ @handler.expects(:signal).times(2).returns('USR2')
+ @handler.expects(:exit_handler).never
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).with(cgi).once
+ @handler.expects(:exit).never
+ @handler.expects(:restart!).once
+
+ @handler.process!
+ assert_equal :restart, @handler.when_ready
+ end
+
def test_interrupted_via_TERM
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'TERM', $$ }
+ Dispatcher.expects(:signal).times(2).returns('TERM')
@handler.expects(:reload!).never
@handler.expects(:close_connection).never
diff --git a/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml b/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml
new file mode 100644
index 00000000..fe80872a
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml
@@ -0,0 +1 @@
+# an empty YAML file - any content in here seems to get parsed as a string
\ No newline at end of file
diff --git a/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb b/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb
new file mode 100644
index 00000000..d4262f89
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb
@@ -0,0 +1 @@
+# intentionally empty
\ No newline at end of file
diff --git a/vendor/rails/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb b/vendor/rails/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb
new file mode 100644
index 00000000..d4262f89
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb
@@ -0,0 +1 @@
+# intentionally empty
\ No newline at end of file
diff --git a/vendor/rails/actionmailer/test/fixtures/first_mailer/share.rhtml b/vendor/rails/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/first_mailer/share.rhtml
rename to vendor/rails/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore
diff --git a/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_example_helper.rhtml b/vendor/rails/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/helper_mailer/use_example_helper.rhtml
rename to vendor/rails/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore
diff --git a/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.rhtml b/vendor/rails/railties/test/fixtures/lib/generators/missing_templates/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.rhtml
rename to vendor/rails/railties/test/fixtures/lib/generators/missing_templates/.gitignore
diff --git a/vendor/rails/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb b/vendor/rails/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
new file mode 100644
index 00000000..b33f2dad
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
@@ -0,0 +1,4 @@
+class AGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.rhtml b/vendor/rails/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.rhtml
rename to vendor/rails/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
diff --git a/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.rhtml b/vendor/rails/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.rhtml
rename to vendor/rails/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
diff --git a/vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml b/vendor/rails/railties/test/fixtures/plugins/default/empty/.gitignore
similarity index 100%
rename from vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml
rename to vendor/rails/railties/test/fixtures/plugins/default/empty/.gitignore
diff --git a/vendor/rails/railties/test/fixtures/plugins/default/stubby/about.yml b/vendor/rails/railties/test/fixtures/plugins/default/stubby/about.yml
new file mode 100644
index 00000000..d85a7cc0
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/plugins/default/stubby/about.yml
@@ -0,0 +1,2 @@
+author: Plugin Author
+version: 1.0.0
\ No newline at end of file
diff --git a/vendor/rails/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb b/vendor/rails/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
new file mode 100644
index 00000000..8fda8197
--- /dev/null
+++ b/vendor/rails/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
@@ -0,0 +1,4 @@
+class StubbyGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/vendor/rails/railties/test/gem_dependency_test.rb b/vendor/rails/railties/test/gem_dependency_test.rb
new file mode 100644
index 00000000..3ae01893
--- /dev/null
+++ b/vendor/rails/railties/test/gem_dependency_test.rb
@@ -0,0 +1,66 @@
+require 'plugin_test_helper'
+
+class Rails::GemDependency
+ public :install_command, :unpack_command
+end
+
+uses_mocha "Plugin Tests" do
+ class GemDependencyTest < Test::Unit::TestCase
+ def setup
+ @gem = Rails::GemDependency.new "hpricot"
+ @gem_with_source = Rails::GemDependency.new "hpricot", :source => "http://code.whytheluckystiff.net"
+ @gem_with_version = Rails::GemDependency.new "hpricot", :version => "= 0.6"
+ @gem_with_lib = Rails::GemDependency.new "aws-s3", :lib => "aws/s3"
+ end
+
+ def test_configuration_adds_gem_dependency
+ config = Rails::Configuration.new
+ config.gem "aws-s3", :lib => "aws/s3", :version => "0.4.0"
+ assert_equal [["install", "aws-s3", "--version", "= 0.4.0"]], config.gems.collect(&:install_command)
+ end
+
+ def test_gem_creates_install_command
+ assert_equal %w(install hpricot), @gem.install_command
+ end
+
+ def test_gem_with_source_creates_install_command
+ assert_equal %w(install hpricot --source http://code.whytheluckystiff.net), @gem_with_source.install_command
+ end
+
+ def test_gem_with_version_creates_install_command
+ assert_equal ["install", "hpricot", "--version", "= 0.6"], @gem_with_version.install_command
+ end
+
+ def test_gem_creates_unpack_command
+ assert_equal %w(unpack hpricot), @gem.unpack_command
+ end
+
+ def test_gem_with_version_unpack_install_command
+ assert_equal ["unpack", "hpricot", "--version", "= 0.6"], @gem_with_version.unpack_command
+ end
+
+ def test_gem_adds_load_paths
+ @gem.expects(:gem).with(@gem.name)
+ @gem.add_load_paths
+ end
+
+ def test_gem_with_version_adds_load_paths
+ @gem_with_version.expects(:gem).with(@gem_with_version.name, @gem_with_version.requirement.to_s)
+ @gem_with_version.add_load_paths
+ end
+
+ def test_gem_loading
+ @gem.expects(:gem).with(@gem.name)
+ @gem.expects(:require).with(@gem.name)
+ @gem.add_load_paths
+ @gem.load
+ end
+
+ def test_gem_with_lib_loading
+ @gem_with_lib.expects(:gem).with(@gem_with_lib.name)
+ @gem_with_lib.expects(:require).with(@gem_with_lib.lib)
+ @gem_with_lib.add_load_paths
+ @gem_with_lib.load
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/rails/railties/test/generator_lookup_test.rb b/vendor/rails/railties/test/generator_lookup_test.rb
new file mode 100644
index 00000000..b650f304
--- /dev/null
+++ b/vendor/rails/railties/test/generator_lookup_test.rb
@@ -0,0 +1,40 @@
+require 'plugin_test_helper'
+
+class GeneratorLookupTest < Test::Unit::TestCase
+ def setup
+ @fixture_dirs = %w{alternate default}
+ @configuration = Rails.configuration = Rails::Configuration.new
+ # We need to add our testing plugin directory to the plugin paths so
+ # the locator knows where to look for our plugins
+ @configuration.plugin_paths += @fixture_dirs.map{|fd| plugin_fixture_path(fd)}
+ @initializer = Rails::Initializer.new(@configuration)
+ @initializer.add_plugin_load_paths
+ @initializer.load_plugins
+ load 'rails_generator.rb'
+ require 'rails_generator/scripts'
+ end
+
+ def test_should_load_from_all_plugin_paths
+ assert Rails::Generator::Base.lookup('a_generator')
+ assert Rails::Generator::Base.lookup('stubby_generator')
+ end
+
+ def test_should_create_generator_source_for_each_directory_in_plugin_paths
+ sources = Rails::Generator::Base.sources
+ @fixture_dirs.each do |gen_dir|
+ expected_label = "plugins (fixtures/plugins/#{gen_dir})".to_sym
+ assert sources.any? {|source| source.label == expected_label }
+ end
+ end
+
+ def test_should_preserve_order_in_usage_message
+ msg = Rails::Generator::Scripts::Base.new.send(:usage_message)
+ positions = @fixture_dirs.map do |gen_dir|
+ pos = msg.index("Plugins (fixtures/plugins/#{gen_dir})")
+ assert_not_nil pos
+ pos
+ end
+ assert_equal positions.sort, positions
+ end
+
+end
diff --git a/vendor/rails/railties/test/generators/generator_test_helper.rb b/vendor/rails/railties/test/generators/generator_test_helper.rb
index 3af5886a..05dca340 100644
--- a/vendor/rails/railties/test/generators/generator_test_helper.rb
+++ b/vendor/rails/railties/test/generators/generator_test_helper.rb
@@ -1,73 +1,160 @@
-module GeneratorTestHelper
- # Instantiates the Generator
- def build_generator(name,params)
- Rails::Generator::Base.instance(name,params)
+require 'test/unit'
+require 'fileutils'
+
+# Mock out what we need from AR::Base
+module ActiveRecord
+ class Base
+ class << self
+ attr_accessor :pluralize_table_names
+ end
+ self.pluralize_table_names = true
end
- # Runs the create command (like the command line does)
- def run_generator(name,params)
- silence_generator do
- build_generator(name,params).command(:create).invoke!
+ module ConnectionAdapters
+ class Column
+ attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
+
+ def initialize(name, default, sql_type = nil)
+ @name = name
+ @default = default
+ @type = @sql_type = sql_type
+ end
+
+ def human_name
+ @name.humanize
+ end
+ end
+ end
+end
+
+# Mock up necessities from ActionView
+module ActionView
+ module Helpers
+ module ActionRecordHelper; end
+ class InstanceTag; end
+ end
+end
+
+# Set RAILS_ROOT appropriately fixture generation
+tmp_dir = "#{File.dirname(__FILE__)}/../fixtures/tmp"
+
+if defined? RAILS_ROOT
+ RAILS_ROOT.replace tmp_dir
+else
+ RAILS_ROOT = tmp_dir
+end
+FileUtils.mkdir_p RAILS_ROOT
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+require 'rails_generator'
+
+class GeneratorTestCase < Test::Unit::TestCase
+ include FileUtils
+
+ def setup
+ ActiveRecord::Base.pluralize_table_names = true
+
+ mkdir_p "#{RAILS_ROOT}/app/views/layouts"
+ mkdir_p "#{RAILS_ROOT}/config"
+ mkdir_p "#{RAILS_ROOT}/db"
+ mkdir_p "#{RAILS_ROOT}/test/fixtures"
+ mkdir_p "#{RAILS_ROOT}/public/stylesheets"
+
+ File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
+ f << "ActionController::Routing::Routes.draw do |map|\n\nend"
end
end
- # Silences the logger temporarily and returns the output as a String
+ def teardown
+ rm_rf "#{RAILS_ROOT}/app"
+ rm_rf "#{RAILS_ROOT}/test"
+ rm_rf "#{RAILS_ROOT}/config"
+ rm_rf "#{RAILS_ROOT}/db"
+ rm_rf "#{RAILS_ROOT}/public"
+ end
+
+ def test_truth
+ # don't complain, test/unit
+ end
+
+ # Instantiates the Generator.
+ def build_generator(name, params)
+ Rails::Generator::Base.instance(name, params)
+ end
+
+ # Runs the +create+ command (like the command line does).
+ def run_generator(name, params)
+ silence_generator do
+ build_generator(name, params).command(:create).invoke!
+ end
+ end
+
+ # Silences the logger temporarily and returns the output as a String.
def silence_generator
- logger_original=Rails::Generator::Base.logger
- myout=StringIO.new
- Rails::Generator::Base.logger=Rails::Generator::SimpleLogger.new(myout)
+ logger_original = Rails::Generator::Base.logger
+ myout = StringIO.new
+ Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(myout)
yield if block_given?
- Rails::Generator::Base.logger=logger_original
+ Rails::Generator::Base.logger = logger_original
myout.string
end
- # asserts that the given controller was generated.
+ # Asserts that the given controller was generated.
# It takes a name or symbol without the _controller part and an optional super class.
# The contents of the class source file is passed to a block.
- def assert_generated_controller_for(name,parent="ApplicationController")
- assert_generated_class "app/controllers/#{name.to_s.underscore}_controller",parent do |body|
+ def assert_generated_controller_for(name, parent = "ApplicationController")
+ assert_generated_class "app/controllers/#{name.to_s.underscore}_controller", parent do |body|
yield body if block_given?
end
end
- # asserts that the given model was generated.
+ # Asserts that the given model was generated.
# It takes a name or symbol and an optional super class.
- # the contents of the class source file is passed to a block.
- def assert_generated_model_for(name,parent="ActiveRecord::Base")
- assert_generated_class "app/models/#{name.to_s.underscore}",parent do |body|
+ # The contents of the class source file is passed to a block.
+ def assert_generated_model_for(name, parent = "ActiveRecord::Base")
+ assert_generated_class "app/models/#{name.to_s.underscore}", parent do |body|
yield body if block_given?
end
end
- # asserts that the given helper was generated.
- # It takes a name or symbol without the _helper part
- # the contents of the module source file is passed to a block.
+ # Asserts that the given helper was generated.
+ # It takes a name or symbol without the _helper part.
+ # The contents of the module source file is passed to a block.
def assert_generated_helper_for(name)
assert_generated_module "app/helpers/#{name.to_s.underscore}_helper" do |body|
yield body if block_given?
end
end
- # asserts that the given functional test was generated.
+ # Asserts that the given functional test was generated.
# It takes a name or symbol without the _controller_test part and an optional super class.
- # the contents of the class source file is passed to a block.
- def assert_generated_functional_test_for(name,parent="Test::Unit::TestCase")
+ # The contents of the class source file is passed to a block.
+ def assert_generated_functional_test_for(name, parent = "ActionController::TestCase")
assert_generated_class "test/functional/#{name.to_s.underscore}_controller_test",parent do |body|
yield body if block_given?
end
end
- # asserts that the given unit test was generated.
+ # Asserts that the given unit test was generated.
# It takes a name or symbol without the _test part and an optional super class.
- # the contents of the class source file is passed to a block.
- def assert_generated_unit_test_for(name,parent="Test::Unit::TestCase")
- assert_generated_class "test/unit/#{name.to_s.underscore}_test",parent do |body|
+ # The contents of the class source file is passed to a block.
+ def assert_generated_unit_test_for(name, parent = "ActiveSupport::TestCase")
+ assert_generated_class "test/unit/#{name.to_s.underscore}_test", parent do |body|
yield body if block_given?
end
end
- # asserts that the given file was generated.
- # the contents of the file is passed to a block.
+ # Asserts that the given file was generated.
+ # The contents of the file is passed to a block.
def assert_generated_file(path)
assert_file_exists(path)
File.open("#{RAILS_ROOT}/#{path}") do |f|
@@ -77,79 +164,93 @@ module GeneratorTestHelper
# asserts that the given file exists
def assert_file_exists(path)
- assert File.exist?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist"
+ assert File.exist?("#{RAILS_ROOT}/#{path}"),
+ "The file '#{RAILS_ROOT}/#{path}' should exist"
end
- # asserts that the given class source file was generated.
+ # Asserts that the given class source file was generated.
# It takes a path without the .rb part and an optional super class.
- # the contents of the class source file is passed to a block.
- def assert_generated_class(path,parent=nil)
- path=~/\/?(\d+_)?(\w+)$/
- class_name=$2.camelize
+ # The contents of the class source file is passed to a block.
+ def assert_generated_class(path, parent = nil)
+ # FIXME: Sucky way to detect namespaced classes
+ if path.split('/').size > 3
+ path =~ /\/?(\d+_)?(\w+)\/(\w+)$/
+ class_name = "#{$2.camelize}::#{$3.camelize}"
+ else
+ path =~ /\/?(\d+_)?(\w+)$/
+ class_name = $2.camelize
+ end
+
assert_generated_file("#{path}.rb") do |body|
- assert body=~/class #{class_name}#{parent.nil? ? '':" < #{parent}"}/,"the file '#{path}.rb' should be a class"
+ assert_match /class #{class_name}#{parent.nil? ? '':" < #{parent}"}/, body, "the file '#{path}.rb' should be a class"
yield body if block_given?
end
end
- # asserts that the given module source file was generated.
+ # Asserts that the given module source file was generated.
# It takes a path without the .rb part.
- # the contents of the class source file is passed to a block.
+ # The contents of the class source file is passed to a block.
def assert_generated_module(path)
- path=~/\/?(\w+)$/
- module_name=$1.camelize
+ # FIXME: Sucky way to detect namespaced modules
+ if path.split('/').size > 3
+ path =~ /\/?(\w+)\/(\w+)$/
+ module_name = "#{$1.camelize}::#{$2.camelize}"
+ else
+ path =~ /\/?(\w+)$/
+ module_name = $1.camelize
+ end
+
assert_generated_file("#{path}.rb") do |body|
- assert body=~/module #{module_name}/,"the file '#{path}.rb' should be a module"
+ assert_match /module #{module_name}/, body, "the file '#{path}.rb' should be a module"
yield body if block_given?
end
end
- # asserts that the given css stylesheet file was generated.
+ # Asserts that the given CSS stylesheet file was generated.
# It takes a path without the .css part.
- # the contents of the stylesheet source file is passed to a block.
+ # The contents of the stylesheet source file is passed to a block.
def assert_generated_stylesheet(path)
assert_generated_file("public/stylesheets/#{path}.css") do |body|
yield body if block_given?
end
end
- # asserts that the given yaml file was generated.
+ # Asserts that the given YAML file was generated.
# It takes a path without the .yml part.
- # the parsed yaml tree is passed to a block.
+ # The parsed YAML tree is passed to a block.
def assert_generated_yaml(path)
assert_generated_file("#{path}.yml") do |body|
- assert yaml=YAML.load(body)
+ yaml = YAML.load(body)
+ assert yaml, 'YAML data missing'
yield yaml if block_given?
end
end
- # asserts that the given fixtures yaml file was generated.
+ # Asserts that the given fixtures yaml file was generated.
# It takes a fixture name without the .yml part.
- # the parsed yaml tree is passed to a block.
+ # The parsed YAML tree is passed to a block.
def assert_generated_fixtures_for(name)
assert_generated_yaml "test/fixtures/#{name.to_s.underscore}" do |yaml|
- assert_generated_timestamps(yaml)
yield yaml if block_given?
end
end
- # asserts that the given views were generated.
+ # Asserts that the given views were generated.
# It takes a controller name and a list of views (including extensions).
- # The body of each view is passed to a block
- def assert_generated_views_for(name,*actions)
+ # The body of each view is passed to a block.
+ def assert_generated_views_for(name, *actions)
actions.each do |action|
- assert_generated_file("app/views/#{name.to_s.underscore}/#{action.to_s}") do |body|
+ assert_generated_file("app/views/#{name.to_s.underscore}/#{action}") do |body|
yield body if block_given?
end
end
end
- # asserts that the given migration file was generated.
- # It takes the name of the migration as a parameter.
- # The migration body is passed to a block.
- def assert_generated_migration(name,parent="ActiveRecord::Migration")
- assert_generated_class "db/migrate/001_#{name.to_s.underscore}",parent do |body|
- assert body=~/timestamps/, "should have timestamps defined"
+ def assert_generated_migration(name, parent = "ActiveRecord::Migration")
+ file = Dir.glob("#{RAILS_ROOT}/db/migrate/*_#{name.to_s.underscore}.rb").first
+ file = file.match(/db\/migrate\/[0-9]+_\w+/).to_s
+ assert_generated_class file, parent do |body|
+ assert_match /timestamps/, body, "should have timestamps defined"
yield body if block_given?
end
end
@@ -161,35 +262,26 @@ module GeneratorTestHelper
assert !File.exist?(migration_file), "should not create migration #{migration_file}"
end
- # asserts that the given resource was added to the routes.
+ # Asserts that the given resource was added to the routes.
def assert_added_route_for(name)
assert_generated_file("config/routes.rb") do |body|
- assert body=~/map.resources :#{name.to_s.underscore}/,"should add route for :#{name.to_s.underscore}"
+ assert_match /map.resources :#{name.to_s.underscore}/, body,
+ "should add route for :#{name.to_s.underscore}"
end
end
- # asserts that the given methods are defined in the body.
+ # Asserts that the given methods are defined in the body.
# This does assume standard rails code conventions with regards to the source code.
# The body of each individual method is passed to a block.
- def assert_has_method(body,*methods)
+ def assert_has_method(body, *methods)
methods.each do |name|
- assert body=~/^ def #{name.to_s}\n((\n| .*\n)*) end/,"should have method #{name.to_s}"
- yield( name, $1 ) if block_given?
+ assert body =~ /^ def #{name}(\(.+\))?\n((\n| .*\n)*) end/, "should have method #{name}"
+ yield(name, $2) if block_given?
end
end
- # asserts that the given column is defined in the migration
- def assert_generated_column(body,name,type)
- assert body=~/t\.#{type.to_s} :#{name.to_s}/, "should have column #{name.to_s} defined"
+ # Asserts that the given column is defined in the migration.
+ def assert_generated_column(body, name, type)
+ assert_match /t\.#{type.to_s} :#{name.to_s}/, body, "should have column #{name.to_s} defined"
end
-
- private
- # asserts that the default timestamps are created in the fixture
- def assert_generated_timestamps(yaml)
- yaml.values.each do |v|
- ["created_at", "updated_at"].each do |field|
- assert v.keys.include?(field), "should have #{field} field by default"
- end
- end
- end
end
diff --git a/vendor/rails/railties/test/generators/rails_controller_generator_test.rb b/vendor/rails/railties/test/generators/rails_controller_generator_test.rb
new file mode 100644
index 00000000..0090d21b
--- /dev/null
+++ b/vendor/rails/railties/test/generators/rails_controller_generator_test.rb
@@ -0,0 +1,20 @@
+require 'generators/generator_test_helper'
+
+class RailsControllerGeneratorTest < GeneratorTestCase
+
+ def test_controller_generates_controller
+ run_generator('controller', %w(products))
+
+ assert_generated_controller_for :products
+ assert_generated_functional_test_for :products
+ assert_generated_helper_for :products
+ end
+
+ def test_controller_generates_namespaced_controller
+ run_generator('controller', %w(admin::products))
+
+ assert_generated_controller_for "admin::products"
+ assert_generated_functional_test_for "admin::products"
+ assert_generated_helper_for "admin::products"
+ end
+end
diff --git a/vendor/rails/railties/test/generators/rails_mailer_generator_test.rb b/vendor/rails/railties/test/generators/rails_mailer_generator_test.rb
new file mode 100644
index 00000000..de61e673
--- /dev/null
+++ b/vendor/rails/railties/test/generators/rails_mailer_generator_test.rb
@@ -0,0 +1,29 @@
+require 'generators/generator_test_helper'
+
+class RailsMailerGeneratorTest < GeneratorTestCase
+
+ def test_generates_mailer
+ run_generator('mailer', %w(Notifier reset_password))
+
+ assert_generated_model_for :notifier, 'ActionMailer::Base' do |model|
+ assert_has_method model, :reset_password do |name, body|
+ assert_equal [
+ "subject 'Notifier#reset_password'",
+ "recipients ''",
+ "from ''",
+ "sent_on sent_at",
+ "",
+ "body :greeting => 'Hi,'"
+ ],
+ body.split("\n").map{|line| line.sub(' '*4, '') }
+ end
+
+ assert_no_match /(self.default_url_options =|default_url_options\[.*\] =)/, model,
+ 'individual mailer models should not set default_url_options because the options are shared by all mailers'
+ end
+
+ assert_generated_views_for :notifier, 'reset_password.erb'
+ assert_generated_unit_test_for :notifier, 'ActionMailer::TestCase'
+ assert_generated_file "test/fixtures/notifier/reset_password"
+ end
+end
diff --git a/vendor/rails/railties/test/generators/rails_model_generator_test.rb b/vendor/rails/railties/test/generators/rails_model_generator_test.rb
index a1637c4c..0bfc3385 100644
--- a/vendor/rails/railties/test/generators/rails_model_generator_test.rb
+++ b/vendor/rails/railties/test/generators/rails_model_generator_test.rb
@@ -1,86 +1,9 @@
-require 'test/unit'
+require 'generators/generator_test_helper'
-# Optionally load RubyGems
-begin
- require 'rubygems'
-rescue LoadError
-end
-
-# Mock out what we need from AR::Base
-module ActiveRecord
- class Base
- class << self
- attr_accessor :pluralize_table_names
- end
- self.pluralize_table_names = true
- end
-
- module ConnectionAdapters
- class Column
- attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
- def initialize(name, default, sql_type=nil)
- @namename
- @default=default
- @type=@sql_type=sql_type
- end
-
- def human_name
- @name.humanize
- end
- end
- end
-end
-
-# Mock up necessities from ActionView
-module ActionView
- module Helpers
- module ActionRecordHelper; end
- class InstanceTag; end
- end
-end
-
-# Set RAILS_ROOT appropriately fixture generation
-tmp_dir="#{File.dirname(__FILE__)}/../fixtures/tmp"
-if defined?(RAILS_ROOT)
- RAILS_ROOT.replace(tmp_dir)
-else
- RAILS_ROOT=tmp_dir
-end
-Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
-require 'rails_generator'
-require "#{File.dirname(__FILE__)}/generator_test_helper"
-
-class RailsModelGeneratorTest < Test::Unit::TestCase
- include GeneratorTestHelper
-
- def setup
- ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
- File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
- f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
- end
- end
-
- def teardown
- FileUtils.rm_rf "#{RAILS_ROOT}/app"
- FileUtils.rm_rf "#{RAILS_ROOT}/test"
- FileUtils.rm_rf "#{RAILS_ROOT}/config"
- FileUtils.rm_rf "#{RAILS_ROOT}/db"
- FileUtils.rm_rf "#{RAILS_ROOT}/public"
- end
+class RailsModelGeneratorTest < GeneratorTestCase
def test_model_generates_resources
- run_generator('model', %w(Product))
+ run_generator('model', %w(Product name:string))
assert_generated_model_for :product
assert_generated_fixtures_for :products
@@ -88,7 +11,7 @@ class RailsModelGeneratorTest < Test::Unit::TestCase
end
def test_model_skip_migration_skips_migration
- run_generator('model', %w(Product --skip-migration))
+ run_generator('model', %w(Product name:string --skip-migration))
assert_generated_model_for :product
assert_generated_fixtures_for :products
diff --git a/vendor/rails/railties/test/generators/rails_resource_generator_test.rb b/vendor/rails/railties/test/generators/rails_resource_generator_test.rb
index 63cd284d..45e4850e 100644
--- a/vendor/rails/railties/test/generators/rails_resource_generator_test.rb
+++ b/vendor/rails/railties/test/generators/rails_resource_generator_test.rb
@@ -1,86 +1,9 @@
-require 'test/unit'
+require 'generators/generator_test_helper'
-# Optionally load RubyGems
-begin
- require 'rubygems'
-rescue LoadError
-end
-
-# Mock out what we need from AR::Base
-module ActiveRecord
- class Base
- class << self
- attr_accessor :pluralize_table_names
- end
- self.pluralize_table_names = true
- end
-
- module ConnectionAdapters
- class Column
- attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
- def initialize(name, default, sql_type=nil)
- @namename
- @default=default
- @type=@sql_type=sql_type
- end
-
- def human_name
- @name.humanize
- end
- end
- end
-end
-
-# Mock up necessities from ActionView
-module ActionView
- module Helpers
- module ActionRecordHelper; end
- class InstanceTag; end
- end
-end
-
-# Set RAILS_ROOT appropriately fixture generation
-tmp_dir="#{File.dirname(__FILE__)}/../fixtures/tmp"
-if defined?(RAILS_ROOT)
- RAILS_ROOT.replace(tmp_dir)
-else
- RAILS_ROOT=tmp_dir
-end
-Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
-require 'rails_generator'
-require "#{File.dirname(__FILE__)}/generator_test_helper"
-
-class RailsResourceGeneratorTest < Test::Unit::TestCase
- include GeneratorTestHelper
-
- def setup
- ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
- File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
- f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
- end
- end
-
- def teardown
- FileUtils.rm_rf "#{RAILS_ROOT}/app"
- FileUtils.rm_rf "#{RAILS_ROOT}/test"
- FileUtils.rm_rf "#{RAILS_ROOT}/config"
- FileUtils.rm_rf "#{RAILS_ROOT}/db"
- FileUtils.rm_rf "#{RAILS_ROOT}/public"
- end
+class RailsResourceGeneratorTest < GeneratorTestCase
def test_resource_generates_resources
- run_generator('scaffold', %w(Product))
+ run_generator('resource', %w(Product name:string))
assert_generated_controller_for :products
assert_generated_model_for :product
@@ -92,7 +15,7 @@ class RailsResourceGeneratorTest < Test::Unit::TestCase
end
def test_resource_skip_migration_skips_migration
- run_generator('resource', %w(Product --skip-migration))
+ run_generator('resource', %w(Product name:string --skip-migration))
assert_generated_controller_for :products
assert_generated_model_for :product
diff --git a/vendor/rails/railties/test/generators/rails_scaffold_generator_test.rb b/vendor/rails/railties/test/generators/rails_scaffold_generator_test.rb
index 16588aff..220f9e37 100644
--- a/vendor/rails/railties/test/generators/rails_scaffold_generator_test.rb
+++ b/vendor/rails/railties/test/generators/rails_scaffold_generator_test.rb
@@ -1,87 +1,7 @@
-require 'test/unit'
-
-# Optionally load RubyGems.
-begin
- require 'rubygems'
-rescue LoadError
-end
-
-# Mock out what we need from AR::Base.
-module ActiveRecord
- class Base
- class << self
- attr_accessor :pluralize_table_names
- end
- self.pluralize_table_names = true
- end
-
- module ConnectionAdapters
- class Column
- attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
-
- def initialize(name, default, sql_type = nil)
- @name=name
- @default=default
- @type=@sql_type=sql_type
- end
-
- def human_name
- @name.humanize
- end
- end
- end
-end
-
-# And what we need from ActionView
-module ActionView
- module Helpers
- module ActiveRecordHelper; end
- class InstanceTag; end
- end
-end
-
-
-# Must set before requiring generator libs.
-tmp_dir="#{File.dirname(__FILE__)}/../fixtures/tmp"
-if defined?(RAILS_ROOT)
- RAILS_ROOT.replace(tmp_dir)
-else
- RAILS_ROOT=tmp_dir
-end
-Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT)
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
-require 'rails_generator'
-require "#{File.dirname(__FILE__)}/generator_test_helper"
-
-class RailsScaffoldGeneratorTest < Test::Unit::TestCase
-
- include GeneratorTestHelper
-
- def setup
- ActiveRecord::Base.pluralize_table_names = true
- Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app")
- Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views")
- Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts")
- Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config")
- Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db")
- Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test")
- Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures")
- Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public")
- Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets")
- File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
- f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n"
- end
- end
-
- def teardown
- FileUtils.rm_rf "#{RAILS_ROOT}/app"
- FileUtils.rm_rf "#{RAILS_ROOT}/test"
- FileUtils.rm_rf "#{RAILS_ROOT}/config"
- FileUtils.rm_rf "#{RAILS_ROOT}/db"
- FileUtils.rm_rf "#{RAILS_ROOT}/public"
- end
+require 'generators/generator_test_helper'
+class RailsScaffoldGeneratorTest < GeneratorTestCase
+
def test_scaffolded_names
g = Rails::Generator::Base.instance('scaffold', %w(ProductLine))
assert_equal "ProductLines", g.controller_name
@@ -94,7 +14,7 @@ class RailsScaffoldGeneratorTest < Test::Unit::TestCase
def test_scaffold_generates_resources
- run_generator('scaffold', %w(Product))
+ run_generator('scaffold', %w(Product name:string))
assert_generated_controller_for :products do |f|
@@ -124,12 +44,13 @@ class RailsScaffoldGeneratorTest < Test::Unit::TestCase
assert_generated_helper_for :products
assert_generated_stylesheet :scaffold
assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb"
+
assert_generated_migration :create_products
assert_added_route_for :products
end
def test_scaffold_skip_migration_skips_migration
- run_generator('scaffold', %w(Product --skip-migration))
+ run_generator('scaffold', %w(Product name:string --skip-migration))
assert_generated_model_for :product
assert_generated_functional_test_for :products
@@ -173,6 +94,7 @@ class RailsScaffoldGeneratorTest < Test::Unit::TestCase
assert_generated_helper_for :products
assert_generated_stylesheet :scaffold
assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb"
+
assert_generated_migration :create_products do |t|
assert_generated_column t, :name, :string
assert_generated_column t, :supplier_id, :integer
diff --git a/vendor/rails/railties/test/initializer_test.rb b/vendor/rails/railties/test/initializer_test.rb
index 156f670e..0df0164c 100644
--- a/vendor/rails/railties/test/initializer_test.rb
+++ b/vendor/rails/railties/test/initializer_test.rb
@@ -1,6 +1,13 @@
-require "#{File.dirname(__FILE__)}/abstract_unit"
+require 'abstract_unit'
require 'initializer'
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
class ConfigurationMock < Rails::Configuration
attr_reader :environment_path
diff --git a/vendor/rails/railties/test/plugin_loader_test.rb b/vendor/rails/railties/test/plugin_loader_test.rb
index fe77de44..41bd6ec7 100644
--- a/vendor/rails/railties/test/plugin_loader_test.rb
+++ b/vendor/rails/railties/test/plugin_loader_test.rb
@@ -1,19 +1,28 @@
-require File.dirname(__FILE__) + '/plugin_test_helper'
+require 'plugin_test_helper'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
uses_mocha "Plugin Loader Tests" do
class TestPluginLoader < Test::Unit::TestCase
ORIGINAL_LOAD_PATH = $LOAD_PATH.dup
-
+
def setup
reset_load_path!
-
+
@configuration = Rails::Configuration.new
@configuration.plugin_paths << plugin_fixture_root_path
@initializer = Rails::Initializer.new(@configuration)
@valid_plugin_path = plugin_fixture_path('default/stubby')
@empty_plugin_path = plugin_fixture_path('default/empty')
-
+
+ @failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+
@loader = Rails::Plugin::Loader.new(@initializer)
end
@@ -25,33 +34,30 @@ uses_mocha "Plugin Loader Tests" do
@configuration.plugin_locators = [locator_class_1, locator_class_2]
assert_equal [:a, :b, :c, :d, :e, :f], @loader.send(:locate_plugins)
end
-
+
def test_should_memoize_the_result_of_locate_plugins_as_all_plugins
plugin_list = [:a, :b, :c]
@loader.expects(:locate_plugins).once.returns(plugin_list)
assert_equal plugin_list, @loader.all_plugins
assert_equal plugin_list, @loader.all_plugins # ensuring that locate_plugins isn't called again
end
-
+
def test_should_return_empty_array_if_configuration_plugins_is_empty
@configuration.plugins = []
assert_equal [], @loader.plugins
end
-
+
def test_should_find_all_availble_plugins_and_return_as_all_plugins
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.all_plugins, failure_tip
+ assert_plugins [:stubby, :plugin_with_no_lib_dir, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
end
def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
-
+
def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
@configuration.plugins = nil
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
@@ -59,82 +65,78 @@ uses_mocha "Plugin Loader Tests" do
only_load_the_following_plugins! plugin_names
assert_plugins plugin_names, @loader.plugins
end
-
+
def test_should_respect_the_order_of_plugins_given_in_configuration
plugin_names = [:stubby, :acts_as_chunky_bacon]
only_load_the_following_plugins! plugin_names
- assert_plugins plugin_names, @loader.plugins
+ assert_plugins plugin_names, @loader.plugins
end
-
+
def test_should_load_all_plugins_in_natural_order_when_all_is_used
only_load_the_following_plugins! [:all]
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, failure_tip
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
end
-
+
def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, failure_tip
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
end
-
+
def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
only_load_the_following_plugins! [:stubby, :all, :acts_as_chunky_bacon]
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, failure_tip
+ assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
end
def test_should_accept_plugin_names_given_as_strings
only_load_the_following_plugins! ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
- failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
- assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, failure_tip
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
end
-
+
def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
stubbed_application_lib_index_in_LOAD_PATHS = 5
@loader.stubs(:application_lib_index).returns(stubbed_application_lib_index_in_LOAD_PATHS)
-
+
@loader.add_plugin_load_paths
-
+
assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
- assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
- end
-
+ assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
+ end
+
def test_should_add_plugin_load_paths_to_Dependencies_load_paths
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
@loader.add_plugin_load_paths
-
+
assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
- assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+ assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
end
-
+
def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
@loader.add_plugin_load_paths
-
+
assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
- assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+ assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
end
-
+
def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array
plugin_load_paths = ["a", "b"]
plugin = stub(:load_paths => plugin_load_paths)
@loader.stubs(:plugins).returns([plugin])
-
+
@loader.add_plugin_load_paths
-
+
plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
end
-
+
private
-
+
def reset_load_path!
$LOAD_PATH.clear
- ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path }
+ ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path }
end
end
-
-end
\ No newline at end of file
+
+end
diff --git a/vendor/rails/railties/test/plugin_locator_test.rb b/vendor/rails/railties/test/plugin_locator_test.rb
index ccd270dd..5f1dd991 100644
--- a/vendor/rails/railties/test/plugin_locator_test.rb
+++ b/vendor/rails/railties/test/plugin_locator_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/plugin_test_helper'
+require 'plugin_test_helper'
uses_mocha "Plugin Locator Tests" do
@@ -47,12 +47,12 @@ uses_mocha "Plugin Locator Tests" do
end
def test_should_return_all_plugins_found_under_the_set_plugin_paths
- assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"], @locator.plugins.map(&:name)
+ assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
end
def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
@configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
- assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"], @locator.plugins.map(&:name)
+ assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
@configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
assert_equal ["a"], @locator.plugins.map(&:name)
@@ -66,4 +66,4 @@ uses_mocha "Plugin Locator Tests" do
end
end
-end # uses_mocha
\ No newline at end of file
+end # uses_mocha
diff --git a/vendor/rails/railties/test/plugin_test.rb b/vendor/rails/railties/test/plugin_test.rb
index 0f08c314..1445338f 100644
--- a/vendor/rails/railties/test/plugin_test.rb
+++ b/vendor/rails/railties/test/plugin_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/plugin_test_helper'
+require 'plugin_test_helper'
uses_mocha "Plugin Tests" do
@@ -130,12 +130,30 @@ uses_mocha "Plugin Tests" do
end
assert plugin.loaded?
end
+
+ def test_should_make_about_yml_available_as_about_method_on_plugin
+ plugin = plugin_for(@valid_plugin_path)
+ assert_equal "Plugin Author", plugin.about['author']
+ assert_equal "1.0.0", plugin.about['version']
+ end
+
+ def test_should_return_empty_hash_for_about_if_about_yml_is_missing
+ assert_equal({}, plugin_for(about_yml_plugin_path('plugin_without_about_yaml')).about)
+ end
+
+ def test_should_return_empty_hash_for_about_if_about_yml_is_malformed
+ assert_equal({}, plugin_for(about_yml_plugin_path('bad_about_yml')).about)
+ end
private
+ def about_yml_plugin_path(name)
+ File.join(File.dirname(__FILE__), 'fixtures', 'about_yml_plugins', name)
+ end
+
def plugin_for(path)
Rails::Plugin.new(path)
end
end
-end # uses_mocha
\ No newline at end of file
+end # uses_mocha
diff --git a/vendor/rails/railties/test/rails_generator_test.rb b/vendor/rails/railties/test/rails_generator_test.rb
index 51d02312..b2fc2f58 100644
--- a/vendor/rails/railties/test/rails_generator_test.rb
+++ b/vendor/rails/railties/test/rails_generator_test.rb
@@ -33,8 +33,16 @@ else
end
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-require 'rails_generator'
+require 'initializer'
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+require 'rails_generator'
class RailsGeneratorTest < Test::Unit::TestCase
BUILTINS = %w(controller integration_test mailer migration model observer plugin resource scaffold session_migration)
@@ -45,9 +53,9 @@ class RailsGeneratorTest < Test::Unit::TestCase
end
def test_sources
- expected = [:lib, :vendor,
- :plugins, :plugins, # /generators and /rails_generators
- :user,
+ expected = [:lib, :vendor,
+ "plugins (vendor/plugins)".to_sym, # /generators and /rails_generators
+ :user,
:RubyGems, :RubyGems, # gems named _generator, gems containing /rails_generator/ folder
:builtin]
expected.delete(:RubyGems) unless Object.const_defined?(:Gem)
@@ -74,9 +82,9 @@ class RailsGeneratorTest < Test::Unit::TestCase
end
def test_lookup_missing_generator
- assert_raise(MissingSourceFile) {
- Rails::Generator::Base.lookup('missing_generator').klass
- }
+ assert_raise Rails::Generator::GeneratorError do
+ Rails::Generator::Base.lookup('missing').klass
+ end
end
def test_lookup_missing_class
@@ -98,7 +106,7 @@ class RailsGeneratorTest < Test::Unit::TestCase
def test_generator_spec
spec = Rails::Generator::Base.lookup('working')
assert_equal 'working', spec.name
- assert_equal "#{RAILS_ROOT}/lib/generators/working", spec.path
+ assert_match(/#{spec.path}$/, "#{RAILS_ROOT}/lib/generators/working")
assert_equal :lib, spec.source
assert_nothing_raised { assert_match(/WorkingGenerator$/, spec.klass.name) }
end
diff --git a/vendor/rails/railties/test/rails_info_controller_test.rb b/vendor/rails/railties/test/rails_info_controller_test.rb
index b73ce5a0..17c7d9de 100644
--- a/vendor/rails/railties/test/rails_info_controller_test.rb
+++ b/vendor/rails/railties/test/rails_info_controller_test.rb
@@ -1,4 +1,4 @@
-require "#{File.dirname(__FILE__)}/abstract_unit"
+require 'abstract_unit'
require 'action_controller'
require 'action_controller/test_process'
diff --git a/vendor/rails/railties/test/rails_info_test.rb b/vendor/rails/railties/test/rails_info_test.rb
index a2120465..3e91e2f2 100644
--- a/vendor/rails/railties/test/rails_info_test.rb
+++ b/vendor/rails/railties/test/rails_info_test.rb
@@ -23,27 +23,21 @@ class InfoTest < Test::Unit::TestCase
end
assert !property_defined?('Test that this will not be defined')
end
-
+
def test_edge_rails_revision_extracted_from_svn_info
Rails::Info.property 'Test Edge Rails revision' do
Rails::Info.edge_rails_revision <<-EOS
-Path: .
-URL: http://www.rubyonrails.com/svn/rails/trunk
-Repository UUID: 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-Revision: 2881
-Node Kind: directory
-Schedule: normal
-Last Changed Author: sam
-Last Changed Rev: 2881
-Last Changed Date: 2005-11-04 21:04:41 -0600 (Fri, 04 Nov 2005)
-Properties Last Updated: 2005-10-28 19:30:00 -0500 (Fri, 28 Oct 2005)
+ commit 420c4b3d8878156d04f45e47050ddc62ae00c68c
+ Author: David Heinemeier Hansson
+ Date: Sun Apr 13 17:33:27 2008 -0500
+ Added Rails.public_path to control where HTML and assets are expected to be loaded from
EOS
end
-
- assert_property 'Test Edge Rails revision', '2881'
+
+ assert_property 'Test Edge Rails revision', '420c4b3d8878156d04f45e47050ddc62ae00c68c'
end
-
+
def test_property_with_block_swallows_exceptions_and_ignores_property
assert_nothing_raised do
Rails::Info.module_eval do
@@ -52,25 +46,25 @@ EOS
end
assert !property_defined?('Bogus')
end
-
+
def test_property_with_string
Rails::Info.module_eval do
property 'Hello', 'World'
end
assert_property 'Hello', 'World'
end
-
+
def test_property_with_block
Rails::Info.module_eval do
property('Goodbye') {'World'}
end
assert_property 'Goodbye', 'World'
end
-
+
def test_component_version
assert_property 'Active Support version', ActiveSupport::VERSION::STRING
end
-
+
def test_components_exist
Rails::Info.components.each do |component|
dir = File.dirname(__FILE__) + "/../../" + component.gsub('_', '')
@@ -78,28 +72,28 @@ EOS
end
end
-protected
- def svn_info=(info)
- Rails::Info.module_eval do
- class << self
- def svn_info
- info
+ protected
+ def svn_info=(info)
+ Rails::Info.module_eval do
+ class << self
+ def svn_info
+ info
+ end
end
end
end
- end
-
- def properties
- Rails::Info.properties
- end
- def property_defined?(property_name)
- properties.names.include? property_name
- end
-
- def assert_property(property_name, value)
- raise "Property #{property_name.inspect} not defined" unless
- property_defined? property_name
- assert_equal value, properties.value_for(property_name)
- end
+ def properties
+ Rails::Info.properties
+ end
+
+ def property_defined?(property_name)
+ properties.names.include? property_name
+ end
+
+ def assert_property(property_name, value)
+ raise "Property #{property_name.inspect} not defined" unless
+ property_defined? property_name
+ assert_equal value, properties.value_for(property_name)
+ end
end
diff --git a/vendor/rails/railties/test/secret_key_generation_test.rb b/vendor/rails/railties/test/secret_key_generation_test.rb
index 09343688..ea1b0dae 100644
--- a/vendor/rails/railties/test/secret_key_generation_test.rb
+++ b/vendor/rails/railties/test/secret_key_generation_test.rb
@@ -9,6 +9,15 @@ end
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
require 'rails_generator'
require 'rails_generator/secret_key_generator'
require 'rails_generator/generators/applications/app/app_generator'
diff --git a/vendor/rails/release.rb b/vendor/rails/release.rb
index 94d22195..2e1e8610 100755
--- a/vendor/rails/release.rb
+++ b/vendor/rails/release.rb
@@ -4,7 +4,7 @@ VERSION = ARGV.first
PACKAGES = %w(activesupport activerecord actionpack actionmailer activeresource)
# Checkout source
-`rm -rf release && svn export http://dev.rubyonrails.org/svn/rails/trunk release`
+# `rm -rf release && svn export http://dev.rubyonrails.org/svn/rails/trunk release`
# Create Rails packages
`cd release/railties && rake template=jamis package`
@@ -19,7 +19,4 @@ end
# Upload rails tgz/zip
`rubyforge add_release rails rails 'REL #{VERSION}' release/rails-#{VERSION}.tgz`
-`rubyforge add_release rails rails 'REL #{VERSION}' release/rails-#{VERSION}.zip`
-
-# Create SVN tag
-puts "Remember to create SVN tag"
+`rubyforge add_release rails rails 'REL #{VERSION}' release/rails-#{VERSION}.zip`
\ No newline at end of file