From 0c1a54ca05cf4cf2586632c4758f9654bdb4b824 Mon Sep 17 00:00:00 2001 From: Billy Frey Date: Tue, 24 Sep 2024 20:14:30 -0600 Subject: [PATCH] add a couple tests --- spec/active_force/sobject/includes_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/active_force/sobject/includes_spec.rb b/spec/active_force/sobject/includes_spec.rb index 65cd54c..6370038 100644 --- a/spec/active_force/sobject/includes_spec.rb +++ b/spec/active_force/sobject/includes_spec.rb @@ -43,6 +43,13 @@ module ActiveForce expect(territory.quota.id).to eq "321" end + context 'when nested select statement' do + it 'formulates the correct SOQL query' do + soql = Salesforce::Territory.select(:id, :quota_id, quota: :id).includes(:quota).where(id: '123').to_s + expect(soql).to eq "SELECT Id, QuotaId, QuotaId.Id FROM Territory WHERE (Id = '123')" + end + end + context 'with namespaced SObjects' do it 'queries the API for the associated record' do soql = Salesforce::Territory.includes(:quota).where(id: '123').to_s @@ -156,6 +163,13 @@ module ActiveForce end context 'has_many' do + context 'when nested select statement' do + it 'formulates the correct SOQL query' do + soql = Account.select(opportunities: :id).includes(:opportunities).where(id: '123').to_s + expect(soql).to eq "SELECT Id, OwnerId, (SELECT Id FROM Opportunities) FROM Account WHERE (Id = '123')" + end + end + context 'with standard objects' do it 'formulates the correct SOQL query' do soql = Account.includes(:opportunities).where(id: '123').to_s