update test for conditional relationships
This commit is contained in:
parent
25c099e923
commit
0b70657a41
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user