Skip to content

Commit

Permalink
add .describe to SObject (#36)
Browse files Browse the repository at this point in the history
* add .describe to SObject

* bump minor version
  • Loading branch information
rferg authored Apr 18, 2023
1 parent e971ea0 commit 5360b68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Not released

## 0.12.0

* Add `.describe` to `SObject` to allow convenient metadata fetching (https://github.com/Beyond-Finance/active_force/pull/36)

## 0.11.4
* Properly escape single quote (https://github.com/Beyond-Finance/active_force/pull/29)
* Fix `Time` value formatting in `.where` (https://github.com/Beyond-Finance/active_force/pull/28)
Expand Down
4 changes: 4 additions & 0 deletions lib/active_force/sobject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def self.query
ActiveForce::ActiveQuery.new self
end

def self.describe
sfdc_client.describe(table_name)
end

attr_accessor :build_attributes
def self.build mash, association_mapping={}
return unless mash
Expand Down
2 changes: 1 addition & 1 deletion lib/active_force/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ActiveForce
VERSION = '0.11.4'
VERSION = '0.12.0'
end
19 changes: 19 additions & 0 deletions spec/active_force/sobject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ class IceCream < ActiveForce::SObject
end
end

describe '.describe' do
subject { Whizbang.describe }

let(:describe_response) { { 'fields' => [] } }

before do
allow(client).to receive(:describe).and_return(describe_response)
end

it 'passes table_name to sfdc_client.describe' do
subject
expect(client).to have_received(:describe).with(Whizbang.table_name)
end

it 'returns response from describe' do
expect(subject).to eq(describe_response)
end
end

describe "CRUD" do
let(:instance){ Whizbang.new(id: '1') }

Expand Down

0 comments on commit 5360b68

Please sign in to comment.