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

Make base_uri changeable with environment variables #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/pardot/client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Pardot
class Client
include HTTParty
base_uri 'https://pi.pardot.com'
base_uri ENV.fetch('PARDOT_URL', 'https://pi.pardot.com')
format :xml

include Authentication
Expand Down
22 changes: 22 additions & 0 deletions spec/pardot/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ def create_client
@client = Pardot::Client.new '[email protected]', 'foo', 'bar'
end

describe '#base_uri' do
context 'without PARDOT_URL' do
before do
ENV.delete('PARDOT_URL')
end

it 'return default value' do
expect(Pardot::Client.base_uri).to eq('https://pi.pardot.com')
end
end

context 'with PARDOT_URL' do
before do
ENV['PARDOT_URL'] = 'https://pi.demo.pardot.com'
end

it 'return ENV value' do
expect(Pardot::Client.base_uri).to eq('https://pi.pardot.com')
end
end
end

describe 'client with Salesforce access_token' do
it 'should set properties' do
@client = Pardot::Client.new nil, nil, nil, 3, 'access_token_value', '0Uv000000000001CAA'
Expand Down