aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-11-09 15:07:56 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-11-09 15:07:56 -0800
commit049caa9e5a38ed8274a3d40a8b934012a87b464f (patch)
treef9d346387343f2c4b5241d2d7296993cbb47ed43 /activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
parent47704af54d51b240f733c596ebb39a033aa698cd (diff)
parentf43f56e16e99dae083cf1400a48c236d1af265d4 (diff)
downloadrails-049caa9e5a38ed8274a3d40a8b934012a87b464f.tar.gz
rails-049caa9e5a38ed8274a3d40a8b934012a87b464f.tar.bz2
rails-049caa9e5a38ed8274a3d40a8b934012a87b464f.zip
Merge pull request #17217 from codeodor/fix-17119
Ensure HABTM relationships produce valid class names (Fixes #17119)
Diffstat (limited to 'activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 859310575e..9a57683ee3 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -1,5 +1,6 @@
require "cases/helper"
require 'models/developer'
+require 'models/computer'
require 'models/project'
require 'models/company'
require 'models/customer'
@@ -80,7 +81,7 @@ end
class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects,
- :parrots, :pirates, :parrots_pirates, :treasures, :price_estimates, :tags, :taggings
+ :parrots, :pirates, :parrots_pirates, :treasures, :price_estimates, :tags, :taggings, :computers
def setup_data_for_habtm_case
ActiveRecord::Base.connection.execute('delete from countries_treaties')
@@ -883,4 +884,12 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
child.special_projects << SpecialProject.new("name" => "Special Project")
assert child.save, 'child object should be saved'
end
+
+ def test_habtm_with_reflection_using_class_name_and_fixtures
+ assert_not_nil Developer._reflections['shared_computers']
+ # Checking the fixture for named association is important here, because it's the only way
+ # we've been able to reproduce this bug
+ assert_not_nil File.read(File.expand_path("../../../fixtures/developers.yml", __FILE__)).index("shared_computers")
+ assert_equal developers(:david).shared_computers.first, computers(:laptop)
+ end
end