metaforce 0.5.3 → 1.0.0a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metaforce::Job::Retrieve do
|
4
|
+
let(:client) { double('metadata client') }
|
5
|
+
let(:job) { described_class.new client }
|
6
|
+
|
7
|
+
describe '.result' do
|
8
|
+
let(:response) { Hashie::Mash.new(success: true) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
client.should_receive(:status).with(job.id, :retrieve).and_return(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { job.result }
|
15
|
+
it { should eq response }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.zip_file' do
|
19
|
+
let(:response) { Hashie::Mash.new(success: true, zip_file: 'foobar') }
|
20
|
+
|
21
|
+
before do
|
22
|
+
client.should_receive(:status).with(job.id, :retrieve).and_return(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
subject { job.zip_file }
|
26
|
+
it { should eq "~\x8A\e" }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metaforce::Job do
|
4
|
+
let(:client) { double('client') }
|
5
|
+
let(:job) { described_class.new(client) }
|
6
|
+
|
7
|
+
describe '.perform' do
|
8
|
+
it 'starts a heart beat' do
|
9
|
+
job.should_receive(:start_heart_beat)
|
10
|
+
job.perform
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.on_complete' do
|
15
|
+
it 'allows the user to register an on_complete callback' do
|
16
|
+
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Completed'))
|
17
|
+
called = false
|
18
|
+
block = lambda { |job| called = true }
|
19
|
+
job.on_complete &block
|
20
|
+
job.perform
|
21
|
+
expect(called).to be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.on_error' do
|
26
|
+
it 'allows the user to register an on_error callback' do
|
27
|
+
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Error'))
|
28
|
+
called = false
|
29
|
+
block = lambda { |job| called = true }
|
30
|
+
job.on_error &block
|
31
|
+
job.perform
|
32
|
+
expect(called).to be_true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.status' do
|
37
|
+
before do
|
38
|
+
client.should_receive(:status)
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { job.status }
|
42
|
+
it { should be_nil }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.done?' do
|
46
|
+
subject { job.done? }
|
47
|
+
|
48
|
+
context 'when done' do
|
49
|
+
before do
|
50
|
+
client.should_receive(:status).and_return(Hashie::Mash.new(done: true))
|
51
|
+
end
|
52
|
+
|
53
|
+
it { should be_true }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when not done' do
|
57
|
+
before do
|
58
|
+
client.should_receive(:status).and_return(Hashie::Mash.new(done: false))
|
59
|
+
end
|
60
|
+
|
61
|
+
it { should be_false }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.state' do
|
66
|
+
subject { job.state }
|
67
|
+
|
68
|
+
context 'when done' do
|
69
|
+
before do
|
70
|
+
client.should_receive(:status).twice.and_return(Hashie::Mash.new(done: true, state: 'Completed'))
|
71
|
+
end
|
72
|
+
|
73
|
+
it { should eq 'Completed' }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when not done' do
|
77
|
+
before do
|
78
|
+
client.should_receive(:status).once.and_return(Hashie::Mash.new(done: false))
|
79
|
+
end
|
80
|
+
|
81
|
+
it { should be_false }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
%w[Queued InProgress Completed Error].each do |state|
|
86
|
+
describe ".#{state.underscore}?" do
|
87
|
+
before do
|
88
|
+
client.should_receive(:status).twice.and_return(Hashie::Mash.new(done: true, state: state))
|
89
|
+
end
|
90
|
+
|
91
|
+
subject { job.send(:"#{state.underscore}?") }
|
92
|
+
it { should be_true }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metaforce::Login do
|
4
|
+
let(:klass) { described_class.new('foo', 'bar', 'whizbang') }
|
5
|
+
|
6
|
+
describe '.login' do
|
7
|
+
before do
|
8
|
+
savon.expects(:login).with(:username => 'foo', :password => 'barwhizbang').returns(:success)
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { klass.login }
|
12
|
+
it { should be_a Hash }
|
13
|
+
its([:session_id]) { should eq '00DU0000000Ilbh!AQoAQHVcube9Z6CRlbR9Eg8ZxpJlrJ6X8QDbnokfyVZItFKzJsLH' \
|
14
|
+
'IRGiqhzJkYsNYRkd3UVA9.s82sbjEbZGUqP3mG6TP_P8' }
|
15
|
+
its([:metadata_server_url]) { should eq 'https://na12-api.salesforce.com/services/Soap/m/23.0/00DU0000000Albh' }
|
16
|
+
its([:server_url]) { should eq 'https://na12-api.salesforce.com/services/Soap/u/23.0/00DU0000000Ilbh' }
|
17
|
+
end
|
18
|
+
end
|
data/spec/lib/manifest_spec.rb
CHANGED
@@ -1,181 +1,35 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Metaforce::Manifest do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@package_hash = {
|
11
|
-
:apex_class => ['TestClass', 'AnotherClass'],
|
4
|
+
let(:package_xml) { File.open(File.join(File.dirname(__FILE__), '../fixtures/package.xml'), 'r').read }
|
5
|
+
let(:package_hash) do
|
6
|
+
{ :apex_class => ['TestClass', 'AnotherClass'],
|
12
7
|
:apex_component => ['Component'],
|
13
|
-
:static_resource => ['Assets']
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
describe ".new" do
|
18
|
-
context "when given a hash" do
|
19
|
-
describe ".to_xml" do
|
20
|
-
|
21
|
-
it "returns a string containing xml" do
|
22
|
-
package = Metaforce::Manifest.new(@package_hash)
|
23
|
-
response = package.to_xml
|
24
|
-
response.should eq(@package_xml)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
context "when given a string" do
|
30
|
-
describe ".to_hash" do
|
31
|
-
|
32
|
-
it "returns the xml content as a hash" do
|
33
|
-
package = Metaforce::Manifest.new(@package_xml)
|
34
|
-
response = package.to_hash
|
35
|
-
response.should eq(@package_hash)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".add" do
|
43
|
-
|
44
|
-
it "can add additional components" do
|
45
|
-
package = Metaforce::Manifest.new(@package_hash)
|
46
|
-
package.add(:apex_class, 'AdditionalClass')
|
47
|
-
response = package.to_hash
|
48
|
-
@package_hash = {
|
49
|
-
:apex_class => ['TestClass', 'AnotherClass', 'AdditionalClass'],
|
50
|
-
:apex_component => ['Component'],
|
51
|
-
:static_resource => ['Assets']
|
52
|
-
}
|
53
|
-
response.should eq(@package_hash)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "can add additional components from an array" do
|
57
|
-
package = Metaforce::Manifest.new(@package_hash)
|
58
|
-
package.add(:apex_class, ['class1', 'class2'])
|
59
|
-
response = package.to_hash
|
60
|
-
@package_hash = {
|
61
|
-
:apex_class => ['TestClass', 'AnotherClass', 'class1', 'class2'],
|
62
|
-
:apex_component => ['Component'],
|
63
|
-
:static_resource => ['Assets']
|
64
|
-
}
|
65
|
-
response.should eq(@package_hash)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "strips directories and extensions" do
|
69
|
-
package = Metaforce::Manifest.new(@package_hash)
|
70
|
-
package.add(:apex_class, 'src/classes/AdditionalClass.cls')
|
71
|
-
response = package.to_hash
|
72
|
-
@package_hash = {
|
73
|
-
:apex_class => ['TestClass', 'AnotherClass', 'AdditionalClass'],
|
74
|
-
:apex_component => ['Component'],
|
75
|
-
:static_resource => ['Assets']
|
76
|
-
}
|
77
|
-
response.should eq(@package_hash)
|
78
|
-
end
|
79
|
-
|
8
|
+
:static_resource => ['Assets'] }
|
80
9
|
end
|
10
|
+
let(:package) { package_xml }
|
11
|
+
let(:manifest) { described_class.new(package) }
|
81
12
|
|
82
|
-
describe
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
package.remove(:apex_class, 'TestClass')
|
87
|
-
response = package.to_hash
|
88
|
-
@package_hash = {
|
89
|
-
:apex_class => ['AnotherClass'],
|
90
|
-
:apex_component => ['Component'],
|
91
|
-
:static_resource => ['Assets']
|
92
|
-
}
|
93
|
-
response.should eq(@package_hash)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "can remove components in an array" do
|
97
|
-
package = Metaforce::Manifest.new(@package_hash)
|
98
|
-
package.remove(:apex_class, ['TestClass', 'AnotherClass'])
|
99
|
-
response = package.to_hash
|
100
|
-
@package_hash = {
|
101
|
-
:apex_component => ['Component'],
|
102
|
-
:static_resource => ['Assets']
|
103
|
-
}
|
104
|
-
response.should eq(@package_hash)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "strips directories and extensions" do
|
108
|
-
package = Metaforce::Manifest.new(@package_hash)
|
109
|
-
package.remove(:apex_class, 'src/classes/TestClass.cls')
|
110
|
-
response = package.to_hash
|
111
|
-
@package_hash = {
|
112
|
-
:apex_class => ['AnotherClass'],
|
113
|
-
:apex_component => ['Component'],
|
114
|
-
:static_resource => ['Assets']
|
115
|
-
}
|
116
|
-
response.should eq(@package_hash)
|
117
|
-
end
|
118
|
-
|
13
|
+
describe '.to_xml' do
|
14
|
+
let(:package) { package_hash }
|
15
|
+
subject { manifest.to_xml }
|
16
|
+
it { should eq package_xml }
|
119
17
|
end
|
120
18
|
|
121
|
-
describe
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
package.only(['classes/TestClass'])
|
126
|
-
response = package.to_hash
|
127
|
-
@package_hash = {
|
128
|
-
:apex_class => ['TestClass']
|
129
|
-
}
|
130
|
-
response.should eq(@package_hash)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "ignores file extensions" do
|
134
|
-
package = Metaforce::Manifest.new(@package_hash)
|
135
|
-
package.only(['classes/TestClass.cls', 'components/Component.component'])
|
136
|
-
response = package.to_hash
|
137
|
-
@package_hash = {
|
138
|
-
:apex_class => ['TestClass'],
|
139
|
-
:apex_component => ['Component']
|
140
|
-
}
|
141
|
-
response.should eq(@package_hash)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "strips any leading directories" do
|
145
|
-
package = Metaforce::Manifest.new(@package_hash)
|
146
|
-
package.only(['src/classes/TestClass.cls', 'src/components/Component.component'])
|
147
|
-
response = package.to_hash
|
148
|
-
@package_hash = {
|
149
|
-
:apex_class => ['TestClass'],
|
150
|
-
:apex_component => ['Component']
|
151
|
-
}
|
152
|
-
response.should eq(@package_hash)
|
153
|
-
end
|
154
|
-
|
155
|
-
it "ignores case of folder" do
|
156
|
-
package = Metaforce::Manifest.new(@package_hash)
|
157
|
-
package.only(['src/Classes/TestClass.cls', 'src/Components/Component.component'])
|
158
|
-
response = package.to_hash
|
159
|
-
@package_hash = {
|
160
|
-
:apex_class => ['TestClass'],
|
161
|
-
:apex_component => ['Component']
|
162
|
-
}
|
163
|
-
response.should eq(@package_hash)
|
164
|
-
end
|
165
|
-
|
19
|
+
describe '.to_hash' do
|
20
|
+
let(:package) { package_xml }
|
21
|
+
subject { manifest.to_hash }
|
22
|
+
it { should eq package_hash }
|
166
23
|
end
|
167
24
|
|
168
|
-
describe
|
169
|
-
|
170
|
-
it
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
{ :members => ["Assets"], :name => "StaticResource" }
|
177
|
-
])
|
25
|
+
describe '.to_package' do
|
26
|
+
subject { manifest.to_package }
|
27
|
+
it do
|
28
|
+
should eq [
|
29
|
+
{ :members => ['TestClass', 'AnotherClass'], :name => 'ApexClass' },
|
30
|
+
{ :members => ['Component'], :name => 'ApexComponent' },
|
31
|
+
{ :members => ['Assets'], :name => 'StaticResource' }
|
32
|
+
]
|
178
33
|
end
|
179
|
-
|
180
34
|
end
|
181
35
|
end
|
@@ -1,230 +1,135 @@
|
|
1
|
-
require
|
2
|
-
require "tempfile"
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Metaforce::Metadata::Client do
|
4
|
+
let(:client) { described_class.new(:session_id => 'foobar', :metadata_server_url => 'https://na12-api.salesforce.com/services/Soap/u/23.0/00DU0000000Ilbh') }
|
5
5
|
|
6
|
-
|
7
|
-
savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:client) do
|
11
|
-
Metaforce::Metadata::Client.new(:username => 'valid', :password => 'password')
|
12
|
-
end
|
13
|
-
|
14
|
-
describe ".list" do
|
15
|
-
|
16
|
-
it "returns an array" do
|
17
|
-
savon.expects(:list_metadata).with(:queries => [ :type => "ApexClass"]).returns(:objects)
|
18
|
-
client.list(:type => "ApexClass").should be_an(Array)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns an empty array when no results are returned" do
|
22
|
-
savon.expects(:list_metadata).with(:queries => [ :type => "ApexClass"]).returns(:no_result)
|
23
|
-
client.list(:type => "ApexClass").should be_an(Array)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "accepts a symbol" do
|
27
|
-
savon.expects(:list_metadata).with(:queries => [ :type => "ApexClass"]).returns(:no_result)
|
28
|
-
client.list(:apex_class).should be_an(Array)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "accepts a string" do
|
32
|
-
savon.expects(:list_metadata).with(:queries => [ :type => "ApexClass"]).returns(:no_result)
|
33
|
-
client.list("ApexClass").should be_an(Array)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should respond to dynamically defined list methods" do
|
39
|
-
savon.expects(:describe_metadata).returns(:success)
|
40
|
-
savon.expects(:list_metadata).with(:queries => [ :type => "ApexClass"]).returns(:no_result)
|
41
|
-
client.list_apex_class.should be_an(Array)
|
6
|
+
it_behaves_like 'a client'
|
42
7
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
context "when given valid information" do
|
48
|
-
|
49
|
-
it "returns a hash" do
|
50
|
-
savon.expects(:describe_metadata).returns(:success)
|
51
|
-
client.describe.should be_a(Hash)
|
8
|
+
describe '.list_metadata' do
|
9
|
+
context 'with a single symbol' do
|
10
|
+
before do
|
11
|
+
savon.expects(:list_metadata).with(:queries => [{:type => 'ApexClass'}]).returns(:objects)
|
52
12
|
end
|
53
13
|
|
54
|
-
|
55
|
-
|
56
|
-
client.describe.should be_a(Hash)
|
57
|
-
expect { client.describe }.to_not raise_error
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe ".metadata_objects" do
|
64
|
-
it "returns the :metadata_objects key from the describe call" do
|
65
|
-
savon.expects(:describe_metadata).returns(:success)
|
66
|
-
client.metadata_objects.should be_a(Array)
|
14
|
+
subject { client.list_metadata(:apex_class) }
|
15
|
+
it { should be_an Array }
|
67
16
|
end
|
68
|
-
end
|
69
17
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
it "returns a hash" do
|
74
|
-
savon.expects(:describe_metadata).returns(:success)
|
75
|
-
client.describe!.should be_a(Hash)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "doesn't cache the response" do
|
79
|
-
savon.expects(:describe_metadata).returns(:success)
|
80
|
-
client.describe!.should be_a(Hash)
|
81
|
-
savon.expects(:describe_metadata).returns(:success)
|
82
|
-
expect { client.describe! }.to_not raise_error
|
18
|
+
context 'with a single string' do
|
19
|
+
before do
|
20
|
+
savon.expects(:list_metadata).with(:queries => [{:type => 'ApexClass'}]).returns(:objects)
|
83
21
|
end
|
84
22
|
|
23
|
+
subject { client.list_metadata('ApexClass') }
|
24
|
+
it { should be_an Array }
|
85
25
|
end
|
86
26
|
end
|
87
27
|
|
88
|
-
describe
|
89
|
-
context
|
90
|
-
|
91
|
-
|
92
|
-
expect { client.status("badId") }.to raise_error
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
context "when given an id of a result that has completed" do
|
97
|
-
|
98
|
-
it "returns a hash and the :done key contains true" do
|
99
|
-
savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
|
100
|
-
status = client.status("04sU0000000WNWoIAO")
|
101
|
-
status.should be_a(Hash)
|
102
|
-
status[:done].should eq(true)
|
28
|
+
describe '.describe' do
|
29
|
+
context 'with no version' do
|
30
|
+
before do
|
31
|
+
savon.expects(:describe_metadata).with(nil).returns(:success)
|
103
32
|
end
|
104
33
|
|
34
|
+
subject { client.describe }
|
35
|
+
it { should be_a Hash }
|
105
36
|
end
|
106
|
-
context "when given an id of a result that has not completed" do
|
107
37
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
status.should be_a(Hash)
|
112
|
-
status[:done].should eq(false)
|
38
|
+
context 'with a version' do
|
39
|
+
before do
|
40
|
+
savon.expects(:describe_metadata).with(:api_version => '18.0').returns(:success)
|
113
41
|
end
|
114
42
|
|
43
|
+
subject { client.describe('18.0') }
|
44
|
+
it { should be_a Hash }
|
115
45
|
end
|
116
|
-
|
46
|
+
end
|
117
47
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
48
|
+
describe '.status' do
|
49
|
+
context 'with a single id' do
|
50
|
+
before do
|
51
|
+
savon.expects(:check_status).with(:ids => ['1234']).returns(:done)
|
122
52
|
end
|
123
53
|
|
54
|
+
subject { client.status '1234' }
|
55
|
+
it { should be_a Hash }
|
124
56
|
end
|
125
57
|
end
|
126
58
|
|
127
|
-
describe
|
128
|
-
|
129
|
-
|
130
|
-
it "returns true" do
|
131
|
-
savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
|
132
|
-
client.done?("04sU0000000WNWoIAO").should eq(true)
|
133
|
-
end
|
134
|
-
|
59
|
+
describe '._deploy' do
|
60
|
+
before do
|
61
|
+
savon.expects(:deploy).with(:zip_file => 'foobar', :deploy_options => {}).returns(:in_progress)
|
135
62
|
end
|
136
|
-
context "when given an id of a result that has not completed" do
|
137
63
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
64
|
+
subject { client._deploy('foobar') }
|
65
|
+
it { should be_a Hash }
|
66
|
+
end
|
142
67
|
|
143
|
-
|
68
|
+
describe '.deploy' do
|
69
|
+
subject { client.deploy File.expand_path('../../path/to/zip') }
|
70
|
+
it { should be_a Metaforce::Job::Deploy }
|
144
71
|
end
|
145
72
|
|
146
|
-
describe
|
73
|
+
describe '._retrieve' do
|
74
|
+
let(:options) { double('options') }
|
147
75
|
|
148
|
-
before
|
149
|
-
|
76
|
+
before do
|
77
|
+
savon.expects(:retrieve).with(:retrieve_request => options).returns(:in_progress)
|
150
78
|
end
|
151
|
-
|
152
|
-
context "when given a directory to deploy" do
|
153
|
-
|
154
|
-
it "deploys the directory and returns a transaction" do
|
155
|
-
savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
|
156
|
-
savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
|
157
|
-
deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
|
158
|
-
deployment.should be_a(Metaforce::Transaction)
|
159
|
-
deployment.id.should eq("04sU0000000WNWoIAO")
|
160
|
-
end
|
161
79
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
savon.expects(:deploy).with(:zip_file => '', :deploy_options => { :run_all_tests => true }).returns(:in_progress)
|
166
|
-
savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
|
167
|
-
expect {
|
168
|
-
client.deploy('', :options => { :run_all_tests => true })
|
169
|
-
}.to_not raise_error
|
170
|
-
end
|
80
|
+
subject { client._retrieve(options) }
|
81
|
+
it { should be_a Hash }
|
82
|
+
end
|
171
83
|
|
84
|
+
describe '.retrieve' do
|
85
|
+
subject { client.retrieve }
|
86
|
+
it { should be_a Metaforce::Job::Retrieve }
|
172
87
|
end
|
173
88
|
|
174
|
-
describe
|
89
|
+
describe '.retrieve_unpackaged' do
|
90
|
+
let(:manifest) { Metaforce::Manifest.new(:custom_object => ['Account']) }
|
91
|
+
subject { client.retrieve_unpackaged(manifest) }
|
92
|
+
it { should be_a Metaforce::Job::Retrieve }
|
93
|
+
end
|
175
94
|
|
176
|
-
|
177
|
-
|
95
|
+
describe '._create' do
|
96
|
+
before do
|
97
|
+
savon.expects(:create).with(:metadata => [{:full_name => 'component', :label => 'test', :content => "Zm9vYmFy\n"}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'ins0:ApexComponent'}}).returns(:in_progress)
|
178
98
|
end
|
179
99
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
before(:each) do
|
184
|
-
savon.expects(:retrieve).with(:retrieve_request => { :api_version => Metaforce.configuration.api_version, :single_package => true, :unpackaged => { :types => manifest.to_package } }).returns(:in_progress)
|
185
|
-
savon.expects(:check_status).with(:ids => ['04sU0000000WkdIIAS']).returns(:done)
|
186
|
-
savon.expects(:check_retrieve_status).with(:ids => ['04sU0000000WkdIIAS']).returns(:success)
|
187
|
-
end
|
188
|
-
|
189
|
-
it "returns a valid retrieve result" do
|
190
|
-
retrieval = client.retrieve_unpackaged(manifest)
|
191
|
-
retrieval.done?
|
192
|
-
result = retrieval.result
|
193
|
-
result.should be_a(Hash)
|
194
|
-
end
|
100
|
+
subject { client._create(:apex_component, :full_name => 'component', :label => 'test', :content => 'foobar') }
|
101
|
+
it { should be_a Hash }
|
102
|
+
end
|
195
103
|
|
104
|
+
describe '._delete' do
|
105
|
+
context 'with a single name' do
|
106
|
+
before do
|
107
|
+
savon.expects(:delete).with(:metadata => [{:full_name => 'component'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'ins0:ApexComponent'}}).returns(:in_progress)
|
196
108
|
end
|
197
109
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
savon.expects(:check_status).with(:ids => ['04sU0000000WkdIIAS']).returns(:done)
|
202
|
-
savon.expects(:check_retrieve_status).with(:ids => ['04sU0000000WkdIIAS']).returns(:success)
|
203
|
-
end
|
204
|
-
|
205
|
-
it "returns a valid retrieve result" do
|
206
|
-
retrieval = client.retrieve_unpackaged(File.expand_path('../../../fixtures/sample/src/package.xml', __FILE__))
|
207
|
-
retrieval.done?
|
208
|
-
result = retrieval.result
|
209
|
-
result.should be_a(Hash)
|
210
|
-
end
|
110
|
+
subject { client._delete(:apex_component, 'component') }
|
111
|
+
it { should be_a Hash }
|
112
|
+
end
|
211
113
|
|
114
|
+
context 'with multiple' do
|
115
|
+
before do
|
116
|
+
savon.expects(:delete).with(:metadata => [{:full_name => 'component1'}, {:full_name => 'component2'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'ins0:ApexComponent'}}).returns(:in_progress)
|
212
117
|
end
|
213
118
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
it "merges the options" do
|
221
|
-
expect {
|
222
|
-
retrieval = client.retrieve_unpackaged(File.expand_path('../../../fixtures/sample/src/package.xml', __FILE__), :options => { :extra => true })
|
223
|
-
}.to_not raise_error
|
224
|
-
end
|
119
|
+
subject { client._delete(:apex_component, 'component1', 'component2') }
|
120
|
+
it { should be_a Hash }
|
121
|
+
end
|
122
|
+
end
|
225
123
|
|
226
|
-
|
124
|
+
describe '._update' do
|
125
|
+
before do
|
126
|
+
savon.expects(:update).with(:metadata => {:current_name => 'old_component', :metadata => [{:full_name => 'component', :label => 'test', :content => "Zm9vYmFy\n"}], :attributes! => {:metadata => {'xsi:type' => 'ins0:ApexComponent'}}}).returns(:in_progress)
|
227
127
|
end
|
228
128
|
|
129
|
+
subject { client._update(:apex_component, 'old_component', :full_name => 'component', :label => 'test', :content => 'foobar') }
|
130
|
+
it { should be_a Hash }
|
229
131
|
end
|
230
132
|
end
|
133
|
+
|
134
|
+
|
135
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metaforce do
|
4
|
+
describe '#new' do
|
5
|
+
let(:klass) { described_class.new(session_id: 'foobar') }
|
6
|
+
subject { klass }
|
7
|
+
|
8
|
+
it { should be_a Metaforce::Client }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#login' do
|
12
|
+
let(:args) { {:username => 'foo', :password => 'foobar', :security_token => 'whizbang'} }
|
13
|
+
|
14
|
+
it 'proxies the login call' do
|
15
|
+
Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
|
16
|
+
Metaforce::Login.any_instance.should_receive(:login)
|
17
|
+
described_class.login args
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|