diff options
Diffstat (limited to 'activerecord')
5 files changed, 21 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb index 634dee2289..44e2ee141e 100644 --- a/activerecord/lib/active_record/associations/alias_tracker.rb +++ b/activerecord/lib/active_record/associations/alias_tracker.rb @@ -50,7 +50,7 @@ module ActiveRecord end def pluralize(table_name) - ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name + ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name.to_s end private diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb index 55d9a328a7..e5e9ca6131 100644 --- a/activerecord/test/cases/associations/inner_join_association_test.rb +++ b/activerecord/test/cases/associations/inner_join_association_test.rb @@ -10,7 +10,7 @@ require 'models/tagging' require 'models/tag' class InnerJoinAssociationTest < ActiveRecord::TestCase - fixtures :authors, :posts, :comments, :categories, :categories_posts, :categorizations, + fixtures :authors, :essays, :posts, :comments, :categories, :categories_posts, :categorizations, :taggings, :tags def test_construct_finder_sql_applies_aliases_tables_on_association_conditions diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index 49a1c117bc..8e23ab78be 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -13,6 +13,9 @@ require 'models/vertex' require 'models/edge' require 'models/book' require 'models/citation' +require 'models/aircraft' +require 'models/engine' +require 'models/car' class AssociationsJoinModelTest < ActiveRecord::TestCase self.use_transactional_fixtures = false unless supports_savepoints? @@ -704,6 +707,15 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase assert_equal [9, 10, new_comment.id], authors(:david).sti_post_comments.map(&:id).sort end + def test_has_many_with_pluralize_table_names_false + engine = Engine.create(:car_id => 1) + Aircraft.pluralize_table_names = false + aircraft = Aircraft.create!(:name => "Airbus 380", :id => 1) + assert_equal aircraft.engines, [engine] + ensure + ActiveRecord::Base.pluralize_table_names = true + end + private # create dynamic Post models to allow different dependency options def find_post_with_dependency(post_id, association, association_name, dependency) diff --git a/activerecord/test/models/aircraft.rb b/activerecord/test/models/aircraft.rb new file mode 100644 index 0000000000..0c47aab539 --- /dev/null +++ b/activerecord/test/models/aircraft.rb @@ -0,0 +1,3 @@ +class Aircraft < ActiveRecord::Base + has_many :engines, :foreign_key => "car_id" +end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index d56cdd57b2..4fe311b441 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -40,6 +40,10 @@ ActiveRecord::Schema.define do t.references :account end + create_table :aircraft, :force => true do |t| + t.string :name + end + create_table :audit_logs, :force => true do |t| t.column :message, :string, :null=>false t.column :developer_id, :integer, :null=>false |