diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-14 21:35:52 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-14 21:35:52 -0300 |
commit | f85371f69d9fbc197c39b3c05b05d109952bde6e (patch) | |
tree | 9fcc2c3f98b00aaea9b222bb07cd24e24fbfe0ce /activerecord/test | |
parent | ec6bb3320991df57c00a30c61a03cb5b44942404 (diff) | |
parent | 8f6e5986acddf1c126bebf27774d7c7866bb4fa7 (diff) | |
download | rails-f85371f69d9fbc197c39b3c05b05d109952bde6e.tar.gz rails-f85371f69d9fbc197c39b3c05b05d109952bde6e.tar.bz2 rails-f85371f69d9fbc197c39b3c05b05d109952bde6e.zip |
Merge pull request #14871 from kassio/kb-fixes-namespaced-habtm
Fix how to compute class name on habtm namespaced.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 12 | ||||
-rw-r--r-- | activerecord/test/models/publisher.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/publisher/article.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/publisher/magazine.rb | 3 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 11 |
5 files changed, 31 insertions, 0 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 cfdfff6af9..878f1877db 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 @@ -22,6 +22,9 @@ require 'models/sponsor' require 'models/country' require 'models/treaty' require 'models/vertex' +require 'models/publisher' +require 'models/publisher/article' +require 'models/publisher/magazine' require 'active_support/core_ext/string/conversions' class ProjectWithAfterCreateHook < ActiveRecord::Base @@ -848,4 +851,13 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase def test_custom_join_table assert_equal 'edges', Vertex.reflect_on_association(:sources).join_table end + + def test_namespaced_habtm + magazine = Publisher::Magazine.create + article = Publisher::Article.create + magazine.articles << article + magazine.save + + assert_includes magazine.articles, article + end end diff --git a/activerecord/test/models/publisher.rb b/activerecord/test/models/publisher.rb new file mode 100644 index 0000000000..0d4a7f9235 --- /dev/null +++ b/activerecord/test/models/publisher.rb @@ -0,0 +1,2 @@ +module Publisher +end diff --git a/activerecord/test/models/publisher/article.rb b/activerecord/test/models/publisher/article.rb new file mode 100644 index 0000000000..03a277bbdd --- /dev/null +++ b/activerecord/test/models/publisher/article.rb @@ -0,0 +1,3 @@ +class Publisher::Article < ActiveRecord::Base + has_and_belongs_to_many :magazines +end diff --git a/activerecord/test/models/publisher/magazine.rb b/activerecord/test/models/publisher/magazine.rb new file mode 100644 index 0000000000..82e1a14008 --- /dev/null +++ b/activerecord/test/models/publisher/magazine.rb @@ -0,0 +1,3 @@ +class Publisher::Magazine < ActiveRecord::Base + has_and_belongs_to_many :articles +end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index da3074e90f..a78074d530 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -62,6 +62,14 @@ ActiveRecord::Schema.define do t.string :name end + create_table :articles, force: true do |t| + end + + create_table :articles_magazines, force: true do |t| + t.references :article + t.references :magazine + end + create_table :audit_logs, force: true do |t| t.column :message, :string, null: false t.column :developer_id, :integer, null: false @@ -385,6 +393,9 @@ ActiveRecord::Schema.define do t.column :custom_lock_version, :integer end + create_table :magazines, force: true do |t| + end + create_table :mateys, id: false, force: true do |t| t.column :pirate_id, :integer t.column :target_id, :integer |