metaforce 0.5.3 → 1.0.0a
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/Gemfile +1 -11
- data/LICENSE +22 -0
- data/README.md +91 -96
- data/Rakefile +6 -14
- data/examples/example.rb +51 -0
- data/lib/metaforce/abstract_client.rb +76 -0
- data/lib/metaforce/client.rb +27 -0
- data/lib/metaforce/config.rb +41 -19
- data/lib/metaforce/job/crud.rb +13 -0
- data/lib/metaforce/job/deploy.rb +87 -0
- data/lib/metaforce/job/retrieve.rb +92 -0
- data/lib/metaforce/job.rb +183 -0
- data/lib/metaforce/login.rb +39 -0
- data/lib/metaforce/manifest.rb +18 -93
- data/lib/metaforce/metadata/client/crud.rb +86 -0
- data/lib/metaforce/metadata/client/file.rb +113 -0
- data/lib/metaforce/metadata/client.rb +7 -225
- data/lib/metaforce/services/client.rb +45 -86
- data/lib/metaforce/version.rb +1 -1
- data/lib/metaforce.rb +27 -7
- data/metaforce.gemspec +19 -16
- data/spec/fixtures/package.xml +1 -1
- data/spec/fixtures/payload.zip +0 -0
- data/spec/fixtures/requests/{describe_layout → foo}/invalid_session.xml +0 -0
- data/spec/fixtures/requests/send_email/success.xml +1 -0
- data/spec/lib/client_spec.rb +34 -0
- data/spec/lib/config_spec.rb +8 -50
- data/spec/lib/job/deploy_spec.rb +53 -0
- data/spec/lib/job/retrieve_spec.rb +28 -0
- data/spec/lib/job_spec.rb +95 -0
- data/spec/lib/login_spec.rb +18 -0
- data/spec/lib/manifest_spec.rb +22 -168
- data/spec/lib/metadata/client_spec.rb +84 -179
- data/spec/lib/metaforce_spec.rb +20 -0
- data/spec/lib/services/client_spec.rb +22 -35
- data/spec/spec_helper.rb +24 -3
- data/spec/support/client.rb +38 -0
- data/wsdl/26.0/metadata.xml +4750 -0
- data/wsdl/26.0/partner.xml +3340 -0
- metadata +114 -77
- data/Guardfile +0 -9
- data/bin/metaforce +0 -6
- data/lib/metaforce/core_extensions/string.rb +0 -31
- data/lib/metaforce/core_extensions.rb +0 -1
- data/lib/metaforce/custom_actions.rb +0 -29
- data/lib/metaforce/error.rb +0 -3
- data/lib/metaforce/login_details.rb +0 -28
- data/lib/metaforce/metadata/crud.rb +0 -103
- data/lib/metaforce/metadata/file.rb +0 -74
- data/lib/metaforce/metadata/transaction.rb +0 -100
- data/lib/metaforce/metadata.rb +0 -4
- data/lib/metaforce/rake/deploy.rb +0 -35
- data/lib/metaforce/rake/retrieve.rb +0 -39
- data/lib/metaforce/rake/tests.rb +0 -62
- data/lib/metaforce/rake.rb +0 -43
- data/lib/metaforce/services.rb +0 -1
- data/lib/metaforce/tasks/README.md +0 -62
- data/lib/metaforce/tasks/metaforce.rake +0 -5
- data/lib/metaforce/thor/metaforce.rb +0 -117
- data/lib/metaforce/types.rb +0 -249
- data/spec/.gitignore +0 -1
- data/spec/fixtures/sample/Rakefile +0 -2
- data/spec/fixtures/sample/metaforce.yml +0 -13
- data/spec/fixtures/sample/src/classes/TestClass.cls +0 -2
- data/spec/fixtures/sample/src/classes/TestClass.cls-meta.xml +0 -5
- data/spec/fixtures/sample/src/package.xml +0 -8
- data/spec/lib/core_extensions/string_spec.rb +0 -23
- data/spec/lib/metadata/crud_spec.rb +0 -66
- data/spec/lib/metadata/file_spec.rb +0 -17
- data/spec/lib/metadata/transaction_spec.rb +0 -68
@@ -1,50 +1,37 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Metaforce::Services::Client do
|
4
|
-
|
5
|
-
context "when given invalid credentials" do
|
4
|
+
let(:client) { described_class.new(:session_id => 'foobar', :server_url => 'https://na12-api.salesforce.com/services/Soap/u/23.0/00DU0000000Ilbh') }
|
6
5
|
|
7
|
-
|
8
|
-
savon.expects(:login).with(:username => 'invalid', :password => 'password').returns(:failure)
|
9
|
-
expect { Metaforce::Services::Client.new(:username => 'invalid', :password => 'password') }.to raise_error
|
10
|
-
end
|
6
|
+
it_behaves_like 'a client'
|
11
7
|
|
12
|
-
|
13
|
-
context
|
14
|
-
|
15
|
-
|
16
|
-
savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
|
17
|
-
session = Metaforce::Services::Client.new(:username => 'valid', :password => 'password').session
|
18
|
-
session.should eq({ :session_id => "00DU0000000Ilbh!AQoAQHVcube9Z6CRlbR9Eg8ZxpJlrJ6X8QDbnokfyVZItFKzJsLHIRGiqhzJkYsNYRkd3UVA9.s82sbjEbZGUqP3mG6TP_P8",
|
19
|
-
:metadata_server_url => "https://na12-api.salesforce.com/services/Soap/m/23.0/00DU0000000Albh",
|
20
|
-
:services_url=>"https://na12-api.salesforce.com/services/Soap/u/23.0/00DU0000000Ilbh" })
|
8
|
+
describe '.describe_layout' do
|
9
|
+
context 'without a record type id' do
|
10
|
+
before do
|
11
|
+
savon.expects(:describe_layout).with('sObjectType' => 'Account').returns(:success)
|
21
12
|
end
|
22
13
|
|
14
|
+
subject { client.describe_layout('Account') }
|
15
|
+
it { should be_a Hash }
|
23
16
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
session.should eq({ :session_id => "00DU0000000Ilbh!AQoAQHVcube9Z6CRlbR9Eg8ZxpJlrJ6X8QDbnokfyVZItFKzJsLHIRGiqhzJkYsNYRkd3UVA9.s82sbjEbZGUqP3mG6TP_P8",
|
29
|
-
:metadata_server_url => "https://na12-api.salesforce.com/services/Soap/m/23.0/00DU0000000Albh",
|
30
|
-
:services_url=>"https://na12-api.salesforce.com/services/Soap/u/23.0/00DU0000000Ilbh" })
|
17
|
+
|
18
|
+
context 'with a record type id' do
|
19
|
+
before do
|
20
|
+
savon.expects(:describe_layout).with('sObjectType' => 'Account', 'recordTypeID' => '1234').returns(:success)
|
31
21
|
end
|
22
|
+
|
23
|
+
subject { client.describe_layout('Account', '1234') }
|
24
|
+
it { should be_a Hash }
|
32
25
|
end
|
33
26
|
end
|
34
27
|
|
35
|
-
describe
|
36
|
-
|
37
|
-
savon.expects(:
|
38
|
-
|
28
|
+
describe '.send_email' do
|
29
|
+
before do
|
30
|
+
savon.expects(:send_email).with(:messages => { :to_addresses => "foo@bar.com", :subject => "foo", :plain_text_body => "bar" },
|
31
|
+
:attributes! => { "ins0:messages" => { "xsi:type" => "ins0:SingleEmailMessage" } }).returns(:success)
|
39
32
|
end
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
# savon.expects(:describe_layout).with('sObjectType' => 'Account').returns(:invalid_session)
|
44
|
-
# savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
|
45
|
-
# savon.expects(:describe_layout).with('sObjectType' => 'Account').returns(:success)
|
46
|
-
# client.describe_layout('Account').should be_a(Hash)
|
47
|
-
end
|
48
|
-
end
|
34
|
+
subject { client.send_email(:to_addresses => 'foo@bar.com', subject: 'foo', plain_text_body: 'bar') }
|
35
|
+
it { should be_a Hash}
|
49
36
|
end
|
50
37
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler'
|
2
2
|
Bundler.require :default, :development
|
3
|
-
require
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
Dir['./spec/support/**/*.rb'].sort.each {|f| require f}
|
4
6
|
|
5
7
|
RSpec.configure do |config|
|
6
|
-
config.mock_with :mocha
|
7
8
|
config.include Savon::Spec::Macros
|
9
|
+
|
10
|
+
config.before(:suite) do
|
11
|
+
Metaforce::Job.disable_threading!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec::Matchers.define :set_default do |option|
|
16
|
+
chain :to do |value|
|
17
|
+
@value = value
|
18
|
+
end
|
19
|
+
|
20
|
+
match do |configuration|
|
21
|
+
@actual = configuration.send(option.to_sym)
|
22
|
+
@actual.should eq @value
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message_for_should do |configuration|
|
26
|
+
"Expected #{option} to be set to #{@value.inspect}, got #{@actual.inspect}"
|
27
|
+
end
|
8
28
|
end
|
9
29
|
|
10
30
|
Savon.configure do |config|
|
11
31
|
config.log = false
|
12
32
|
end
|
33
|
+
|
13
34
|
Savon::Spec::Fixture.path = File.join(File.dirname(__FILE__), 'fixtures/requests')
|
@@ -0,0 +1,38 @@
|
|
1
|
+
shared_examples 'a client' do
|
2
|
+
describe 'when the session id expires' do
|
3
|
+
let(:exception) { Savon::SOAP::Fault.new(HTTPI::Response.new(403, {}, '')) }
|
4
|
+
|
5
|
+
before do
|
6
|
+
client.send(:client).should_receive(:request).once.and_raise(exception)
|
7
|
+
exception.stub(:message).and_return('INVALID_SESSION_ID')
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'and no authentication handler is present' do
|
11
|
+
before do
|
12
|
+
client.stub(:authentication_handler).and_return(nil)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'raises the exception' do
|
16
|
+
expect { client.send(:request, :foo) }.to raise_error(exception)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'and an authentication handler is present' do
|
21
|
+
let(:handler) do
|
22
|
+
proc { |client, options| options = { session_id: 'foo' } }
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
client.stub(:authentication_handler).and_return(handler)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'calls the authentication handler and resends the request' do
|
30
|
+
response = double('response')
|
31
|
+
response.stub(:body).and_return(Hashie::Mash.new(:foo_response => {:result => ''}))
|
32
|
+
client.send(:client).should_receive(:request).once.and_return(response)
|
33
|
+
handler.should_receive(:call).and_call_original
|
34
|
+
client.send(:request, :foo)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|