Skip to content
Browse files

Test session table pluralization. Closes #6459.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5585 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent de6ffba commit 3fc4771996be40c7bd4c3128ead1b860b2d676f9 @jeremy jeremy committed
Showing with 17 additions and 7 deletions.
  1. +17 −7 railties/test/rails_generator_test.rb
View
24 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 @@ def test_generator_spec
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 @@ def test_named_generator_attributes
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 @@ def test_named_generator_attributes
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

0 comments on commit 3fc4771

Please sign in to comment.
Something went wrong with that request. Please try again.