|
36 | 36 | describe 'one-level deep has_many relationship' do
|
37 | 37 | let(:include_query) { 'comments' }
|
38 | 38 |
|
39 |
| - context 'unauthorized for include_has_many_resource for Comment', pending: 'Compatibility with JR 0.10' do |
| 39 | + context 'unauthorized for include_has_many_resource for Comment' do |
40 | 40 | before do
|
41 | 41 | disallow_operation(
|
42 | 42 | 'include_has_many_resource',
|
|
73 | 73 | describe 'one-level deep has_one relationship' do
|
74 | 74 | let(:include_query) { 'author' }
|
75 | 75 |
|
76 |
| - context 'unauthorized for include_has_one_resource for article.author', pending: 'Compatibility with JR 0.10' do |
| 76 | + context 'unauthorized for include_has_one_resource for article.author' do |
77 | 77 | before do
|
78 | 78 | disallow_operation(
|
79 | 79 | 'include_has_one_resource',
|
|
108 | 108 | describe 'multiple one-level deep relationships' do
|
109 | 109 | let(:include_query) { 'author,comments' }
|
110 | 110 |
|
111 |
| - context 'unauthorized for include_has_one_resource for article.author', pending: 'Compatibility with JR 0.10' do |
| 111 | + context 'unauthorized for include_has_one_resource for article.author' do |
112 | 112 | before do
|
113 | 113 | disallow_operation(
|
114 | 114 | 'include_has_one_resource',
|
|
121 | 121 | it { is_expected.to be_forbidden }
|
122 | 122 | end
|
123 | 123 |
|
124 |
| - context 'unauthorized for include_has_many_resource for Comment', pending: 'Compatibility with JR 0.10' do |
| 124 | + context 'unauthorized for include_has_many_resource for Comment' do |
125 | 125 | before do
|
126 | 126 | allow_operation('include_has_one_resource', source_record: an_instance_of(Article), related_record: an_instance_of(User), authorizer: chained_authorizer)
|
127 | 127 | disallow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer)
|
|
156 | 156 | describe 'a deep relationship' do
|
157 | 157 | let(:include_query) { 'author.comments' }
|
158 | 158 |
|
159 |
| - context 'unauthorized for first relationship', pending: 'Compatibility with JR 0.10' do |
| 159 | + context 'unauthorized for first relationship' do |
160 | 160 | before do
|
161 | 161 | disallow_operation(
|
162 | 162 | 'include_has_one_resource',
|
|
172 | 172 | context 'authorized for first relationship' do
|
173 | 173 | before { allow_operation('include_has_one_resource', source_record: an_instance_of(Article), related_record: an_instance_of(User), authorizer: chained_authorizer) }
|
174 | 174 |
|
175 |
| - context 'unauthorized for second relationship', pending: 'Compatibility with JR 0.10' do |
176 |
| - before { disallow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
| 175 | + context 'unauthorized for second relationship' do |
| 176 | + # FIXME: Why is include_has_many_resource called with `source_record` being an instance of Article and not User? |
| 177 | + # We're fetching comments made by some specific User here, so the `source_record` should be an instance of User, right? |
| 178 | + before { disallow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer) } |
| 179 | + # before { disallow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
177 | 180 |
|
178 | 181 | it { is_expected.to be_forbidden }
|
179 | 182 | end
|
180 | 183 |
|
181 | 184 | context 'authorized for second relationship' do
|
182 |
| - before { allow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
| 185 | + # FIXME: Why is include_has_many_resource called with `source_record` being an instance of Article and not User? |
| 186 | + # We're fetching comments made by some specific User here, so the `source_record` should be an instance of User, right? |
| 187 | + before { allow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer) } |
| 188 | + # before { allow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
183 | 189 |
|
184 | 190 | it { is_expected.to be_successful }
|
185 | 191 |
|
|
203 | 209 |
|
204 | 210 | describe 'a deep relationship with empty relations' do
|
205 | 211 | context 'first level has_one is nil' do
|
| 212 | + # FIXME: Why is the `include_has_many_resource` even being called here? |
| 213 | + # There should not be any comments assigned via `non_existing_article -> comments` query. |
| 214 | + # Article.non_existing_article `has_one` relation returns `none` so we shouldn't get any Comment records, either |
| 215 | + before { allow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer) } |
206 | 216 | let(:include_query) { 'non-existing-article.comments' }
|
207 | 217 |
|
208 | 218 | it { is_expected.to be_successful }
|
|
211 | 221 | context 'first level has_many is empty' do
|
212 | 222 | let(:include_query) { 'empty-articles.comments' }
|
213 | 223 |
|
214 |
| - context 'unauthorized for first relationship', pending: 'Compatibility with JR 0.10' do |
| 224 | + context 'unauthorized for first relationship' do |
215 | 225 | before { disallow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Article, authorizer: chained_authorizer) }
|
216 | 226 |
|
217 | 227 | it { is_expected.to be_forbidden }
|
218 | 228 | end
|
219 | 229 |
|
220 | 230 | context 'authorized for first relationship' do
|
| 231 | + # FIXME: Why is the `include_has_many_resource` being called here with `record_class: Comment`? |
| 232 | + # There should not be any comments assigned via `empty_articles -> comments` query. |
| 233 | + # Article.empty_articles `has_many` relation returns `none` so we shouldn't get any Comment records, either |
| 234 | + before { allow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer) } |
221 | 235 | before { allow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Article, authorizer: chained_authorizer) }
|
222 | 236 |
|
223 | 237 | it { is_expected.to be_successful }
|
|
285 | 299 | before { allow_operation('include_has_one_resource', source_record: an_instance_of(Article), related_record: an_instance_of(User), authorizer: chained_authorizer) }
|
286 | 300 |
|
287 | 301 | context 'authorized for second relationship' do
|
288 |
| - before { allow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
| 302 | + # FIXME: Why is include_has_many_resource called with `source_record` being an instance of Article and not User? |
| 303 | + # We're fetching comments made by some specific User here, so the `source_record` should be an instance of User, right? |
| 304 | + before { allow_operation('include_has_many_resource', source_record: an_instance_of(Article), record_class: Comment, authorizer: chained_authorizer) } |
| 305 | + # before { allow_operation('include_has_many_resource', source_record: an_instance_of(User), record_class: Comment, authorizer: chained_authorizer) } |
289 | 306 |
|
290 | 307 | it { is_expected.to be_successful }
|
291 | 308 |
|
|
0 commit comments