Skip to content

Commit 0b70657

Browse files
kyreevesshishirmk
authored andcommitted
update test for conditional relationships
1 parent 25c099e commit 0b70657

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

spec/lib/object_serializer_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ class BlahSerializer
361361
it 'returns optional relationship when relationship is included' do
362362
json = MovieOptionalRelationshipWithParamsSerializer.new(movie, { params: { admin: true }}).serialized_json
363363
serializable_hash = JSON.parse(json)
364-
expect(serializable_hash['data']['relationships'].has_key?('actors')).to be_truthy
364+
expect(serializable_hash['data']['relationships'].has_key?('owner')).to be_truthy
365365
end
366366

367367
it "doesn't return optional relationship when relationship is not included" do
368368
json = MovieOptionalRelationshipWithParamsSerializer.new(movie, { params: { admin: false }}).serialized_json
369369
serializable_hash = JSON.parse(json)
370-
expect(serializable_hash['data']['relationships'].has_key?('actors')).to be_falsey
370+
expect(serializable_hash['data']['relationships'].has_key?('owner')).to be_falsey
371371
end
372372
end
373373
end

spec/shared/contexts/movie_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class MovieOptionalRelationshipWithParamsSerializer
304304
include FastJsonapi::ObjectSerializer
305305
set_type :movie
306306
attributes :name
307-
has_many :actors, if: Proc.new { |record, params| params && params[:admin] == true }
307+
belongs_to :owner, record_type: :user, if: Proc.new { |record, params| params && params[:admin] == true }
308308
end
309309
end
310310

0 commit comments

Comments
 (0)