update test for conditional relationships

This commit is contained in:
Kyle Reeves 2018-06-26 16:10:41 -05:00 committed by Shishir Kakaraddi
parent 25c099e923
commit 0b70657a41
2 changed files with 3 additions and 3 deletions

View File

@ -361,13 +361,13 @@ describe FastJsonapi::ObjectSerializer do
it 'returns optional relationship when relationship is included' do
json = MovieOptionalRelationshipWithParamsSerializer.new(movie, { params: { admin: true }}).serialized_json
serializable_hash = JSON.parse(json)
expect(serializable_hash['data']['relationships'].has_key?('actors')).to be_truthy
expect(serializable_hash['data']['relationships'].has_key?('owner')).to be_truthy
end
it "doesn't return optional relationship when relationship is not included" do
json = MovieOptionalRelationshipWithParamsSerializer.new(movie, { params: { admin: false }}).serialized_json
serializable_hash = JSON.parse(json)
expect(serializable_hash['data']['relationships'].has_key?('actors')).to be_falsey
expect(serializable_hash['data']['relationships'].has_key?('owner')).to be_falsey
end
end
end

View File

@ -304,7 +304,7 @@ RSpec.shared_context 'movie class' do
include FastJsonapi::ObjectSerializer
set_type :movie
attributes :name
has_many :actors, if: Proc.new { |record, params| params && params[:admin] == true }
belongs_to :owner, record_type: :user, if: Proc.new { |record, params| params && params[:admin] == true }
end
end