@@ -55,62 +55,72 @@ def <(other)
55
55
56
56
test "resolve association returns the location of the target class of a has_many association" do
57
57
@server . execute (
58
- "association_target_location " ,
58
+ "association_target " ,
59
59
{ model_name : "Organization" , association_name : :memberships } ,
60
60
)
61
61
location = response [ :result ] [ :location ]
62
+ name = response [ :result ] [ :name ]
63
+ assert_equal "Membership" , name
62
64
assert_match %r{test/dummy/app/models/membership.rb:3$} , location
63
65
end
64
66
65
67
test "resolve association returns the location of the target class of a belongs_to association" do
66
68
@server . execute (
67
- "association_target_location " ,
69
+ "association_target " ,
68
70
{ model_name : "Membership" , association_name : :organization } ,
69
71
)
70
72
location = response [ :result ] [ :location ]
73
+ name = response [ :result ] [ :name ]
74
+ assert_equal "Organization" , name
71
75
assert_match %r{test/dummy/app/models/organization.rb:3$} , location
72
76
end
73
77
74
78
test "resolve association returns the location of the target class of a has_one association" do
75
79
@server . execute (
76
- "association_target_location " ,
80
+ "association_target " ,
77
81
{ model_name : "User" , association_name : :profile } ,
78
82
)
79
83
location = response [ :result ] [ :location ]
84
+ name = response [ :result ] [ :name ]
85
+ assert_equal "Profile" , name
80
86
assert_match %r{test/dummy/app/models/profile.rb:3$} , location
81
87
end
82
88
83
89
test "resolve association returns the location of the target class of a has_and_belongs_to_many association" do
84
90
@server . execute (
85
- "association_target_location " ,
91
+ "association_target " ,
86
92
{ model_name : "Profile" , association_name : :labels } ,
87
93
)
88
94
location = response [ :result ] [ :location ]
95
+ name = response [ :result ] [ :name ]
96
+ assert_equal "Label" , name
89
97
assert_match %r{test/dummy/app/models/label.rb:3$} , location
90
98
end
91
99
92
100
test "resolve association handles invalid model name" do
93
101
@server . execute (
94
- "association_target_location " ,
102
+ "association_target " ,
95
103
{ model_name : "NotHere" , association_name : :labels } ,
96
104
)
97
105
assert_nil ( response . fetch ( :result ) )
98
106
end
99
107
100
108
test "resolve association handles invalid association name" do
101
109
@server . execute (
102
- "association_target_location " ,
110
+ "association_target " ,
103
111
{ model_name : "Membership" , association_name : :labels } ,
104
112
)
105
113
assert_nil ( response . fetch ( :result ) )
106
114
end
107
115
108
116
test "resolve association handles class_name option" do
109
117
@server . execute (
110
- "association_target_location " ,
118
+ "association_target " ,
111
119
{ model_name : "User" , association_name : :location } ,
112
120
)
113
121
location = response [ :result ] [ :location ]
122
+ name = response [ :result ] [ :name ]
123
+ assert_equal "Country" , name
114
124
assert_match %r{test/dummy/app/models/country.rb:3$} , location
115
125
end
116
126
0 commit comments