@@ -11,7 +11,7 @@ class JoinManagerTest < ActiveSupport::TestCase
11
11
# end
12
12
13
13
def test_no_added_joins
14
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource )
14
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource )
15
15
16
16
records = PostResource . records ( { } )
17
17
records = join_manager . join ( records , { } )
@@ -22,7 +22,7 @@ def test_no_added_joins
22
22
23
23
def test_add_single_join
24
24
filters = { 'tags' => [ '1' ] }
25
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource , filters : filters )
25
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource , filters : filters )
26
26
records = PostResource . records ( { } )
27
27
records = join_manager . join ( records , { } )
28
28
assert_equal 'SELECT "posts".* FROM "posts" LEFT OUTER JOIN "posts_tags" ON "posts_tags"."post_id" = "posts"."id" LEFT OUTER JOIN "tags" ON "tags"."id" = "posts_tags"."tag_id"' , sql_for_compare ( records . to_sql )
@@ -32,7 +32,7 @@ def test_add_single_join
32
32
33
33
def test_add_single_sort_join
34
34
sort_criteria = [ { field : 'tags.name' , direction : :desc } ]
35
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource , sort_criteria : sort_criteria )
35
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource , sort_criteria : sort_criteria )
36
36
records = PostResource . records ( { } )
37
37
records = join_manager . join ( records , { } )
38
38
@@ -44,7 +44,7 @@ def test_add_single_sort_join
44
44
def test_add_single_sort_and_filter_join
45
45
filters = { 'tags' => [ '1' ] }
46
46
sort_criteria = [ { field : 'tags.name' , direction : :desc } ]
47
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource , sort_criteria : sort_criteria , filters : filters )
47
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource , sort_criteria : sort_criteria , filters : filters )
48
48
records = PostResource . records ( { } )
49
49
records = join_manager . join ( records , { } )
50
50
assert_equal 'SELECT "posts".* FROM "posts" LEFT OUTER JOIN "posts_tags" ON "posts_tags"."post_id" = "posts"."id" LEFT OUTER JOIN "tags" ON "tags"."id" = "posts_tags"."tag_id"' , sql_for_compare ( records . to_sql )
@@ -58,7 +58,7 @@ def test_add_sibling_joins
58
58
'author' => [ '1' ]
59
59
}
60
60
61
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource , filters : filters )
61
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource , filters : filters )
62
62
records = PostResource . records ( { } )
63
63
records = join_manager . join ( records , { } )
64
64
@@ -70,7 +70,7 @@ def test_add_sibling_joins
70
70
71
71
72
72
def test_add_joins_source_relationship
73
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource ,
73
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource ,
74
74
source_relationship : PostResource . _relationship ( :comments ) )
75
75
records = PostResource . records ( { } )
76
76
records = join_manager . join ( records , { } )
@@ -81,7 +81,7 @@ def test_add_joins_source_relationship
81
81
82
82
83
83
def test_add_joins_source_relationship_with_custom_apply
84
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : Api ::V10 ::PostResource ,
84
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : Api ::V10 ::PostResource ,
85
85
source_relationship : Api ::V10 ::PostResource . _relationship ( :comments ) )
86
86
records = Api ::V10 ::PostResource . records ( { } )
87
87
records = join_manager . join ( records , { } )
@@ -100,7 +100,7 @@ def test_add_nested_scoped_joins
100
100
'author' => [ '1' ]
101
101
}
102
102
103
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
103
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
104
104
records = Api ::V10 ::PostResource . records ( { } )
105
105
records = join_manager . join ( records , { } )
106
106
@@ -117,7 +117,7 @@ def test_add_nested_scoped_joins
117
117
'comments.tags' => [ '1' ]
118
118
}
119
119
120
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
120
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
121
121
records = Api ::V10 ::PostResource . records ( { } )
122
122
records = join_manager . join ( records , { } )
123
123
@@ -135,7 +135,7 @@ def test_add_nested_joins_with_fields
135
135
'author.foo' => [ '1' ]
136
136
}
137
137
138
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
138
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : Api ::V10 ::PostResource , filters : filters )
139
139
records = Api ::V10 ::PostResource . records ( { } )
140
140
records = join_manager . join ( records , { } )
141
141
@@ -149,14 +149,14 @@ def test_add_nested_joins_with_fields
149
149
def test_add_joins_with_sub_relationship
150
150
relationships = %w( author author.comments tags )
151
151
152
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : Api ::V10 ::PostResource , relationships : relationships ,
152
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : Api ::V10 ::PostResource , relationships : relationships ,
153
153
source_relationship : Api ::V10 ::PostResource . _relationship ( :comments ) )
154
154
records = Api ::V10 ::PostResource . records ( { } )
155
155
records = join_manager . join ( records , { } )
156
156
157
157
assert_hash_equals ( { alias : 'comments' , join_type : :inner } , join_manager . source_join_details )
158
158
assert_hash_equals ( { alias : 'comments' , join_type : :inner } , join_manager . join_details_by_relationship ( Api ::V10 ::PostResource . _relationship ( :comments ) ) )
159
- assert_hash_equals ( { alias : 'tags' , join_type : :left } , join_manager . join_details_by_relationship ( Api ::V10 ::CommentResource . _relationship ( :tags ) ) )
159
+ assert_hash_equals ( { alias : 'tags' , join_type : :left } , join_manager . join_details_by_relationship ( Api ::V10 ::PostResource . _relationship ( :tags ) ) )
160
160
assert_hash_equals ( { alias : 'comments_people' , join_type : :left } , join_manager . join_details_by_relationship ( Api ::V10 ::PersonResource . _relationship ( :comments ) ) )
161
161
end
162
162
@@ -168,7 +168,7 @@ def test_add_joins_with_sub_relationship_and_filters
168
168
169
169
relationships = %w( author author.comments tags )
170
170
171
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PostResource ,
171
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PostResource ,
172
172
filters : filters ,
173
173
relationships : relationships ,
174
174
source_relationship : PostResource . _relationship ( :comments ) )
@@ -177,13 +177,13 @@ def test_add_joins_with_sub_relationship_and_filters
177
177
178
178
assert_hash_equals ( { alias : 'comments' , join_type : :inner } , join_manager . source_join_details )
179
179
assert_hash_equals ( { alias : 'comments' , join_type : :inner } , join_manager . join_details_by_relationship ( PostResource . _relationship ( :comments ) ) )
180
- assert_hash_equals ( { alias : 'people' , join_type : :left } , join_manager . join_details_by_relationship ( CommentResource . _relationship ( :author ) ) )
181
- assert_hash_equals ( { alias : 'tags' , join_type : :left } , join_manager . join_details_by_relationship ( CommentResource . _relationship ( :tags ) ) )
180
+ assert_hash_equals ( { alias : 'people' , join_type : :left } , join_manager . join_details_by_relationship ( PostResource . _relationship ( :author ) ) )
181
+ assert_hash_equals ( { alias : 'tags' , join_type : :left } , join_manager . join_details_by_relationship ( PostResource . _relationship ( :tags ) ) )
182
182
assert_hash_equals ( { alias : 'comments_people' , join_type : :left } , join_manager . join_details_by_relationship ( PersonResource . _relationship ( :comments ) ) )
183
183
end
184
184
185
185
def test_polymorphic_join_belongs_to_just_source
186
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new (
186
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new (
187
187
resource_klass : PictureResource ,
188
188
source_relationship : PictureResource . _relationship ( :imageable )
189
189
)
@@ -200,7 +200,7 @@ def test_polymorphic_join_belongs_to_just_source
200
200
201
201
def test_polymorphic_join_belongs_to_filter
202
202
filters = { 'imageable' => [ 'Foo' ] }
203
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PictureResource , filters : filters )
203
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PictureResource , filters : filters )
204
204
205
205
records = PictureResource . records ( { } )
206
206
records = join_manager . join ( records , { } )
@@ -217,7 +217,7 @@ def test_polymorphic_join_belongs_to_filter_on_resource
217
217
}
218
218
219
219
relationships = %w( imageable file_properties )
220
- join_manager = JSONAPI ::ActiveRelation ::JoinManagerV10 . new ( resource_klass : PictureResource ,
220
+ join_manager = JSONAPI ::ActiveRelation ::JoinManager . new ( resource_klass : PictureResource ,
221
221
filters : filters ,
222
222
relationships : relationships )
223
223
0 commit comments