@@ -55,62 +55,72 @@ def <(other)
5555
5656 test "resolve association returns the location of the target class of a has_many association" do
5757 @server . execute (
58- "association_target_location " ,
58+ "association_target " ,
5959 { model_name : "Organization" , association_name : :memberships } ,
6060 )
6161 location = response [ :result ] [ :location ]
62+ name = response [ :result ] [ :name ]
63+ assert_equal "Membership" , name
6264 assert_match %r{test/dummy/app/models/membership.rb:3$} , location
6365 end
6466
6567 test "resolve association returns the location of the target class of a belongs_to association" do
6668 @server . execute (
67- "association_target_location " ,
69+ "association_target " ,
6870 { model_name : "Membership" , association_name : :organization } ,
6971 )
7072 location = response [ :result ] [ :location ]
73+ name = response [ :result ] [ :name ]
74+ assert_equal "Organization" , name
7175 assert_match %r{test/dummy/app/models/organization.rb:3$} , location
7276 end
7377
7478 test "resolve association returns the location of the target class of a has_one association" do
7579 @server . execute (
76- "association_target_location " ,
80+ "association_target " ,
7781 { model_name : "User" , association_name : :profile } ,
7882 )
7983 location = response [ :result ] [ :location ]
84+ name = response [ :result ] [ :name ]
85+ assert_equal "Profile" , name
8086 assert_match %r{test/dummy/app/models/profile.rb:3$} , location
8187 end
8288
8389 test "resolve association returns the location of the target class of a has_and_belongs_to_many association" do
8490 @server . execute (
85- "association_target_location " ,
91+ "association_target " ,
8692 { model_name : "Profile" , association_name : :labels } ,
8793 )
8894 location = response [ :result ] [ :location ]
95+ name = response [ :result ] [ :name ]
96+ assert_equal "Label" , name
8997 assert_match %r{test/dummy/app/models/label.rb:3$} , location
9098 end
9199
92100 test "resolve association handles invalid model name" do
93101 @server . execute (
94- "association_target_location " ,
102+ "association_target " ,
95103 { model_name : "NotHere" , association_name : :labels } ,
96104 )
97105 assert_nil ( response . fetch ( :result ) )
98106 end
99107
100108 test "resolve association handles invalid association name" do
101109 @server . execute (
102- "association_target_location " ,
110+ "association_target " ,
103111 { model_name : "Membership" , association_name : :labels } ,
104112 )
105113 assert_nil ( response . fetch ( :result ) )
106114 end
107115
108116 test "resolve association handles class_name option" do
109117 @server . execute (
110- "association_target_location " ,
118+ "association_target " ,
111119 { model_name : "User" , association_name : :location } ,
112120 )
113121 location = response [ :result ] [ :location ]
122+ name = response [ :result ] [ :name ]
123+ assert_equal "Country" , name
114124 assert_match %r{test/dummy/app/models/country.rb:3$} , location
115125 end
116126
0 commit comments