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