Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add .describe to SObject #36

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


* 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