aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_one_through_associations_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-04-22 04:16:44 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-04-22 04:16:44 +0900
commitf2151c3b3cc969ab95faccaae181ce10c4373cf7 (patch)
tree2a8680c0fbb5eb69fc2e0abe419da1be7138aaaf /activerecord/test/cases/associations/has_one_through_associations_test.rb
parentaa941c9ce19924589e508f6a1e4bc2d8361a89ae (diff)
downloadrails-f2151c3b3cc969ab95faccaae181ce10c4373cf7.tar.gz
rails-f2151c3b3cc969ab95faccaae181ce10c4373cf7.tar.bz2
rails-f2151c3b3cc969ab95faccaae181ce10c4373cf7.zip
Using existing models for building multiple has_one through tests
Follow up of #32514.
Diffstat (limited to 'activerecord/test/cases/associations/has_one_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_one_through_associations_test.rb28
1 files changed, 12 insertions, 16 deletions
diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb
index 003b82e50e..0309663943 100644
--- a/activerecord/test/cases/associations/has_one_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -22,10 +22,6 @@ require "models/customer"
require "models/carrier"
require "models/shop_account"
require "models/customer_carrier"
-require "models/game"
-require "models/game_board"
-require "models/game_collection"
-require "models/game_owner"
class HasOneThroughAssociationsTest < ActiveRecord::TestCase
fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations, :minivans,
@@ -69,21 +65,21 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
end
def test_building_multiple_associations_builds_through_record
- game_owner = GameOwner.create
- game_collection = GameCollection.create
- game_board_with_one_association = GameBoard.new(game_owner: game_owner)
- assert_nil game_board_with_one_association.game.id
- game_board_with_two_associations = GameBoard.new(game_owner: game_owner, game_collection: game_collection)
- assert_nil game_board_with_two_associations.game.id
+ member_type = MemberType.create!
+ member = Member.create!
+ member_detail_with_one_association = MemberDetail.new(member_type: member_type)
+ assert_predicate member_detail_with_one_association.member, :new_record?
+ member_detail_with_two_associations = MemberDetail.new(member_type: member_type, admittable: member)
+ assert_predicate member_detail_with_two_associations.member, :new_record?
end
def test_creating_multiple_associations_creates_through_record
- game_owner = GameOwner.create
- game_collection = GameCollection.create
- game_board_with_one_association = GameBoard.create(game_owner: game_owner)
- assert_not_nil game_board_with_one_association.game.id
- game_board_with_two_associations = GameBoard.create(game_owner: game_owner, game_collection: game_collection)
- assert_not_nil game_board_with_two_associations.game.id
+ member_type = MemberType.create!
+ member = Member.create!
+ member_detail_with_one_association = MemberDetail.create!(member_type: member_type)
+ assert_not_predicate member_detail_with_one_association.member, :new_record?
+ member_detail_with_two_associations = MemberDetail.create!(member_type: member_type, admittable: member)
+ assert_not_predicate member_detail_with_two_associations.member, :new_record?
end
def test_creating_association_sets_both_parent_ids_for_new