Skip to content

Commit

Permalink
add a couple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bfrey08 committed Sep 25, 2024
1 parent 077c80e commit 0c1a54c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/active_force/sobject/includes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c1a54c

Please sign in to comment.