From fd4278a8e4628a253920a8f2a1044fc8fef1e63e Mon Sep 17 00:00:00 2001 From: rferg Date: Fri, 12 Jan 2024 14:31:54 -0500 Subject: [PATCH] add some specs for has one arrays for relation model builder --- .../relation_model_builder_spec.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/active_force/association/relation_model_builder_spec.rb b/spec/active_force/association/relation_model_builder_spec.rb index fa5a6f9..040c243 100644 --- a/spec/active_force/association/relation_model_builder_spec.rb +++ b/spec/active_force/association/relation_model_builder_spec.rb @@ -70,6 +70,36 @@ module Association end end + context 'with a restforce collection value' do + let(:value) do + build_restforce_collection([ + build_restforce_sobject('Id' => 'first'), + build_restforce_sobject('Id' => 'second') + ]) + end + + it 'returns a child for the first value' do + actual = instance.build_relation_model + expect(actual).to be_a(HasOneChild) + expect(actual.id).to eq('first') + end + end + + context 'with an array value' do + let(:value) do + [ + build_restforce_sobject('Id' => 'first'), + build_restforce_sobject('Id' => 'second') + ] + end + + it 'returns a child for the first value' do + actual = instance.build_relation_model + expect(actual).to be_a(HasOneChild) + expect(actual.id).to eq('first') + end + end + context 'without a value' do let(:value){ nil }