aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-20 04:17:48 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-20 04:17:48 +0000
commit3fc4771996be40c7bd4c3128ead1b860b2d676f9 (patch)
tree49600c355590bc95afb0ea383d01de39ce6be75a
parentde6ffba80673543d39ec7ef851fe9d1f7ab3a148 (diff)
downloadrails-3fc4771996be40c7bd4c3128ead1b860b2d676f9.tar.gz
rails-3fc4771996be40c7bd4c3128ead1b860b2d676f9.tar.bz2
rails-3fc4771996be40c7bd4c3128ead1b860b2d676f9.zip
Test session table pluralization. Closes #6459.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5585 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/test/rails_generator_test.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/railties/test/rails_generator_test.rb b/railties/test/rails_generator_test.rb
index 6af5a2a8e8..970cf6b3fc 100644
--- a/railties/test/rails_generator_test.rb
+++ b/railties/test/rails_generator_test.rb
@@ -40,6 +40,10 @@ class RailsGeneratorTest < Test::Unit::TestCase
BUILTINS = %w(controller mailer model scaffold)
CAPITALIZED_BUILTINS = BUILTINS.map { |b| b.capitalize }
+ def setup
+ ActiveRecord::Base.pluralize_table_names = true
+ end
+
def test_sources
expected = [:lib, :vendor, :plugins, :user, :RubyGems, :builtin]
expected.delete(:gem) unless Object.const_defined?(:Gem)
@@ -96,7 +100,6 @@ class RailsGeneratorTest < Test::Unit::TestCase
end
def test_named_generator_attributes
- ActiveRecord::Base.pluralize_table_names = true
g = Rails::Generator::Base.instance('working', %w(admin/foo bar baz))
assert_equal 'admin/foo', g.name
assert_equal %w(admin), g.class_path
@@ -104,7 +107,7 @@ class RailsGeneratorTest < Test::Unit::TestCase
assert_equal 'Admin::Foo', g.class_name
assert_equal 'foo', g.singular_name
assert_equal 'foos', g.plural_name
- assert_equal "admin_#{g.singular_name}", g.file_name
+ assert_equal g.singular_name, g.file_name
assert_equal "admin_#{g.plural_name}", g.table_name
assert_equal %w(bar baz), g.args
end
@@ -112,16 +115,23 @@ class RailsGeneratorTest < Test::Unit::TestCase
def test_named_generator_attributes_without_pluralized
ActiveRecord::Base.pluralize_table_names = false
g = Rails::Generator::Base.instance('working', %w(admin/foo bar baz))
- assert_equal g.singular_name, g.table_name
+ assert_equal "admin_#{g.singular_name}", g.table_name
+ end
+
+ def test_session_migration_generator_with_pluralization
+ g = Rails::Generator::Base.instance('session_migration')
+ assert_equal 'session'.pluralize, g.send(:default_session_table_name)
+ ActiveRecord::Base.pluralize_table_names = false
+ assert_equal 'session', g.send(:default_session_table_name)
end
-
+
def test_scaffold_controller_name
# Default behaviour is use the model name
g = Rails::Generator::Base.instance('scaffold', %w(Product))
- assert_equal "Product", g.controller_name
-
+ assert_equal "Products", g.controller_name
+
# When we specify a controller name make sure it sticks!!
g = Rails::Generator::Base.instance('scaffold', %w(Product Admin))
assert_equal "Admin", g.controller_name
- end
+ end
end