|
9 | 9 | JSONAPI.configuration.json_key_format = :underscored_key |
10 | 10 | end |
11 | 11 |
|
12 | | - let(:fields) { (UserResource.fields - %i(id posts)).map(&:to_s) } |
13 | | - let(:relationships) { %w(posts) } |
| 12 | + let(:fields) { (UserResource.fields - %i(id profile posts)).map(&:to_s) } |
| 13 | + let(:relationships) { %w(profile posts) } |
14 | 14 | let(:attributes) { { first_name: 'Yehuda', last_name: 'Katz' } } |
15 | 15 |
|
16 | 16 | let(:user_params) do |
|
30 | 30 |
|
31 | 31 | context 'with "include"' do |
32 | 32 | it 'returns only the required relationships in the "included" member' do |
33 | | - get :index, include: :posts |
| 33 | + get :index, include: 'profile,posts' |
34 | 34 | expect(response).to have_http_status :ok |
35 | 35 | expect(response).to have_primary_data('users') |
36 | 36 | expect(response).to have_data_attributes(fields) |
|
205 | 205 | expect(response).to have_meta_record_count(User.count) |
206 | 206 |
|
207 | 207 | expect(json['links']['first']).to be_present |
208 | | - expect(json['links']['previous']).to be_present |
| 208 | + expect(json['links']['prev']).to be_present |
209 | 209 | expect(json['links']['next']).to be_present |
210 | 210 | expect(json['links']['last']).to be_present |
211 | 211 | end |
|
221 | 221 | expect(response).to have_meta_record_count(User.count) |
222 | 222 |
|
223 | 223 | expect(json['links']['first']).to be_present |
224 | | - expect(json['links']['previous']).to be_present |
| 224 | + expect(json['links']['prev']).to be_present |
225 | 225 | expect(json['links']['last']).to be_present |
226 | 226 | end |
227 | 227 | end |
|
266 | 266 | expect(response).to have_meta_record_count(User.count) |
267 | 267 |
|
268 | 268 | expect(json['links']['first']).to be_present |
269 | | - expect(json['links']['previous']).to be_present |
| 269 | + expect(json['links']['prev']).to be_present |
270 | 270 | expect(json['links']['next']).to be_present |
271 | 271 | expect(json['links']['last']).to be_present |
272 | 272 | end |
|
282 | 282 | expect(response).to have_meta_record_count(User.count) |
283 | 283 |
|
284 | 284 | expect(json['links']['first']).to be_present |
285 | | - expect(json['links']['previous']).to be_present |
| 285 | + expect(json['links']['prev']).to be_present |
286 | 286 | expect(json['links']['last']).to be_present |
287 | 287 | end |
288 | 288 | end |
|
481 | 481 | end |
482 | 482 | end |
483 | 483 | end |
| 484 | + |
| 485 | + describe 'use of JSONAPI::Resources\' default actions' do |
| 486 | + let(:user) { User.first } |
| 487 | + |
| 488 | + describe '#show_relationship' do |
| 489 | + it do |
| 490 | + get :show_relationship, user_id: user.id, relationship: 'profile' |
| 491 | + expect(response).to have_http_status :ok |
| 492 | + expect(response).to have_primary_data('profiles') |
| 493 | + end |
| 494 | + end |
| 495 | + end |
484 | 496 | end |
0 commit comments