Skip to content

Commit 01477e9

Browse files
kyreevesshishirmk
authored andcommitted
fix relationship id_hash method
1 parent 699630d commit 01477e9

2 files changed

Lines changed: 2 additions & 20 deletions

File tree

lib/fast_jsonapi/relationship.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def ids_hash(ids)
7777
id_hash(ids, record_type) # ids variable is just a single id here
7878
end
7979

80-
def id_hash(id, associated_record_type, default_return=false)
80+
def id_hash(id, record_type, default_return=false)
8181
if id.present?
8282
{ id: id.to_s, type: record_type }
8383
else
84-
default_return ? { id: nil, type: associated_record_type } : nil
84+
default_return ? { id: nil, type: record_type } : nil
8585
end
8686
end
8787

spec/lib/serialization_core_spec.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@
1717
expect(result_hash).to be nil
1818
end
1919

20-
# it 'returns the correct hash when ids_hash_from_record_and_relationship is called for a polymorphic association' do
21-
# relationship = { name: :groupees, relationship_type: :has_many, object_method_name: :groupees, polymorphic: {} }
22-
# results = GroupSerializer.send :ids_hash_from_record_and_relationship, group, relationship
23-
# expect(results).to include({ id: "1", type: :person }, { id: "2", type: :group })
24-
# end
25-
26-
# it 'returns correct hash when ids_hash is called' do
27-
# inputs = [{ids: %w(1 2 3), record_type: :movie}, {ids: %w(x y z), record_type: 'person'}]
28-
# inputs.each do |hash|
29-
# results = MovieSerializer.send(:ids_hash, hash[:ids], hash[:record_type])
30-
# expect(results.map{|h| h[:id]}).to eq hash[:ids]
31-
# expect(results[0][:type]).to eq hash[:record_type]
32-
# end
33-
34-
# result = MovieSerializer.send(:ids_hash, [], 'movie')
35-
# expect(result).to be_empty
36-
# end
37-
3820
it 'returns correct hash when attributes_hash is called' do
3921
attributes_hash = MovieSerializer.send(:attributes_hash, movie)
4022
attribute_names = attributes_hash.keys.sort

0 commit comments

Comments
 (0)