capsulecrm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +29 -0
- data/Rakefile +9 -0
- data/capsulecrm.gemspec +25 -0
- data/examples.rb +65 -0
- data/lib/capsulecrm.rb +40 -0
- data/lib/capsulecrm/address.rb +23 -0
- data/lib/capsulecrm/base.rb +175 -0
- data/lib/capsulecrm/child.rb +24 -0
- data/lib/capsulecrm/child_collection.rb +14 -0
- data/lib/capsulecrm/collection.rb +14 -0
- data/lib/capsulecrm/contact.rb +12 -0
- data/lib/capsulecrm/custom_field.rb +41 -0
- data/lib/capsulecrm/email.rb +15 -0
- data/lib/capsulecrm/organisation.rb +41 -0
- data/lib/capsulecrm/party.rb +64 -0
- data/lib/capsulecrm/person.rb +125 -0
- data/lib/capsulecrm/phone.rb +15 -0
- data/lib/capsulecrm/record_not_found.rb +1 -0
- data/lib/capsulecrm/version.rb +3 -0
- data/test/create_person_test.rb +36 -0
- data/test/fixtures/responses/create_person.yml +59 -0
- data/test/fixtures/responses/person_find_all.yml +28 -0
- data/test/fixtures/responses/person_find_all_with_limit.yml +26 -0
- data/test/fixtures/responses/person_find_all_with_offset.yml +28 -0
- data/test/fixtures/responses/person_find_by_id.yml +76 -0
- data/test/fixtures/responses/update_person.yml +85 -0
- data/test/fixtures/responses/update_person_without_changes.yml +28 -0
- data/test/person_dot_find_all_test.rb +48 -0
- data/test/person_dot_find_by_id_test.rb +57 -0
- data/test/test_helper.rb +51 -0
- data/test/update_person_test.rb +46 -0
- metadata +147 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party?limit=2
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
user-agent:
|
9
|
+
- CapsuleCRM ruby gem
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
content-type:
|
16
|
+
- "*/*"
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
date:
|
20
|
+
- Tue, 12 Apr 2011 12:31:20 GMT
|
21
|
+
content-length:
|
22
|
+
- "713"
|
23
|
+
set-cookie:
|
24
|
+
- "[SESSION-COOKIE]"
|
25
|
+
body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><parties size="2"><person><id>9719416</id><contacts><email><id>17716757</id><emailAddress>at@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Prof</title><firstName>Alan</firstName><lastName>Turing</lastName></person><person><id>10185304</id><contacts><email><id>18565226</id><emailAddress>cd@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Dr</title><firstName>Charles</firstName><lastName>Darwin</lastName></person></parties>
|
26
|
+
http_version: "1.1"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party?start=3
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
user-agent:
|
9
|
+
- CapsuleCRM ruby gem
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
content-type:
|
16
|
+
- "*/*"
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
date:
|
20
|
+
- Tue, 12 Apr 2011 12:31:21 GMT
|
21
|
+
content-length:
|
22
|
+
- "1833"
|
23
|
+
set-cookie:
|
24
|
+
- "[SESSION-COOKIE]"
|
25
|
+
body: |-
|
26
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><parties size="5"><organisation><id>10185222</id><contacts/><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/org_avatar_70.png</pictureURL><name>foo.com</name></organisation><person><id>10185308</id><contacts><email><id>18565231</id><emailAddress>mc@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Ms</title><firstName>Marie</firstName><lastName>Curie</lastName></person><person><id>10185261</id><contacts><address><id>18565115</id><type>Office</type><street>Deputy Prime Minister's Office
|
27
|
+
70 Whitehall</street><city>London</city><zip>SW1A 2AS</zip><country>United Kingdom</country></address><email><id>18565116</id><type>Work</type><emailAddress>dpm@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Mr</title><firstName>Nick</firstName><lastName>Clegg</lastName><jobTitle>Deputy Prime Minister</jobTitle><organisationId>10185256</organisationId><organisationName>UK Government</organisationName></person><person><id>9851220</id><contacts><email><id>18565224</id><emailAddress>tbl@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Prof</title><firstName>Tim</firstName><lastName>Berners-Lee</lastName></person><organisation><id>10185256</id><contacts><email><id>18583945</id><emailAddress>gov@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/org_avatar_70.png</pictureURL><name>UK Government</name></organisation></parties>
|
28
|
+
http_version: "1.1"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185256
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
user-agent:
|
9
|
+
- CapsuleCRM ruby gem
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
content-type:
|
16
|
+
- "*/*"
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
date:
|
20
|
+
- Tue, 12 Apr 2011 12:34:21 GMT
|
21
|
+
content-length:
|
22
|
+
- "333"
|
23
|
+
set-cookie:
|
24
|
+
- "[SESSION-COOKIE]"
|
25
|
+
body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><organisation><id>10185256</id><contacts><email><id>18583945</id><emailAddress>gov@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/org_avatar_70.png</pictureURL><name>UK Government</name></organisation>
|
26
|
+
http_version: "1.1"
|
27
|
+
- !ruby/struct:VCR::HTTPInteraction
|
28
|
+
request: !ruby/struct:VCR::Request
|
29
|
+
method: :get
|
30
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185257
|
31
|
+
body:
|
32
|
+
headers:
|
33
|
+
user-agent:
|
34
|
+
- CapsuleCRM ruby gem
|
35
|
+
response: !ruby/struct:VCR::Response
|
36
|
+
status: !ruby/struct:VCR::ResponseStatus
|
37
|
+
code: 200
|
38
|
+
message: OK
|
39
|
+
headers:
|
40
|
+
content-type:
|
41
|
+
- "*/*"
|
42
|
+
server:
|
43
|
+
- Apache
|
44
|
+
date:
|
45
|
+
- Tue, 12 Apr 2011 12:34:22 GMT
|
46
|
+
content-length:
|
47
|
+
- "897"
|
48
|
+
set-cookie:
|
49
|
+
- "[SESSION-COOKIE]"
|
50
|
+
body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><person><id>10185257</id><contacts><address><id>18565068</id><type>Office</type><street>10 Downing Street</street><city>London</city><zip>SW1A 2AA</zip><country>United Kingdom</country></address><email><id>18565066</id><type>Work</type><emailAddress>pm@example.com</emailAddress></email><phone><id>18566503</id><phoneNumber>12345 67890</phoneNumber></phone><website><id>18565067</id><webAddress>http://www.number10.gov.uk/</webAddress><webService>URL</webService><url>http://www.number10.gov.uk/</url></website></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Mr</title><firstName>David</firstName><lastName>Cameron</lastName><jobTitle>Prime Minister</jobTitle><organisationId>10185256</organisationId><organisationName>UK Government</organisationName></person>
|
51
|
+
http_version: "1.1"
|
52
|
+
- !ruby/struct:VCR::HTTPInteraction
|
53
|
+
request: !ruby/struct:VCR::Request
|
54
|
+
method: :get
|
55
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185256
|
56
|
+
body:
|
57
|
+
headers:
|
58
|
+
user-agent:
|
59
|
+
- CapsuleCRM ruby gem
|
60
|
+
response: !ruby/struct:VCR::Response
|
61
|
+
status: !ruby/struct:VCR::ResponseStatus
|
62
|
+
code: 200
|
63
|
+
message: OK
|
64
|
+
headers:
|
65
|
+
content-type:
|
66
|
+
- "*/*"
|
67
|
+
server:
|
68
|
+
- Apache
|
69
|
+
date:
|
70
|
+
- Tue, 12 Apr 2011 12:34:24 GMT
|
71
|
+
content-length:
|
72
|
+
- "333"
|
73
|
+
set-cookie:
|
74
|
+
- "[SESSION-COOKIE]"
|
75
|
+
body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><organisation><id>10185256</id><contacts><email><id>18583945</id><emailAddress>gov@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/org_avatar_70.png</pictureURL><name>UK Government</name></organisation>
|
76
|
+
http_version: "1.1"
|
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185261
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
user-agent:
|
9
|
+
- CapsuleCRM ruby gem
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
content-type:
|
16
|
+
- "*/*"
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
date:
|
20
|
+
- Tue, 12 Apr 2011 12:29:03 GMT
|
21
|
+
content-length:
|
22
|
+
- "709"
|
23
|
+
set-cookie:
|
24
|
+
- "[SESSION-COOKIE]"
|
25
|
+
body: |-
|
26
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><person><id>10185261</id><contacts><address><id>18565115</id><type>Office</type><street>Deputy Prime Minister's Office
|
27
|
+
70 Whitehall</street><city>London</city><zip>SW1A 2AS</zip><country>United Kingdom</country></address><email><id>18565116</id><type>Work</type><emailAddress>dpm@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Mr</title><firstName>kciN</firstName><lastName>Clegg</lastName><jobTitle>Deputy Prime Minister</jobTitle><organisationId>10185256</organisationId><organisationName>UK Government</organisationName></person>
|
28
|
+
http_version: "1.1"
|
29
|
+
- !ruby/struct:VCR::HTTPInteraction
|
30
|
+
request: !ruby/struct:VCR::Request
|
31
|
+
method: :put
|
32
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/person/10185261
|
33
|
+
body: |
|
34
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
35
|
+
<person>
|
36
|
+
<firstName>Nick</firstName>
|
37
|
+
</person>
|
38
|
+
|
39
|
+
headers:
|
40
|
+
content-type:
|
41
|
+
- text/xml
|
42
|
+
response: !ruby/struct:VCR::Response
|
43
|
+
status: !ruby/struct:VCR::ResponseStatus
|
44
|
+
code: 200
|
45
|
+
message: OK
|
46
|
+
headers:
|
47
|
+
content-type:
|
48
|
+
- text/plain; charset=UTF-8
|
49
|
+
server:
|
50
|
+
- Apache
|
51
|
+
date:
|
52
|
+
- Tue, 12 Apr 2011 12:29:05 GMT
|
53
|
+
content-length:
|
54
|
+
- "0"
|
55
|
+
set-cookie:
|
56
|
+
- "[SESSION-COOKIE]"
|
57
|
+
body:
|
58
|
+
http_version: "1.1"
|
59
|
+
- !ruby/struct:VCR::HTTPInteraction
|
60
|
+
request: !ruby/struct:VCR::Request
|
61
|
+
method: :get
|
62
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185261
|
63
|
+
body:
|
64
|
+
headers:
|
65
|
+
user-agent:
|
66
|
+
- CapsuleCRM ruby gem
|
67
|
+
response: !ruby/struct:VCR::Response
|
68
|
+
status: !ruby/struct:VCR::ResponseStatus
|
69
|
+
code: 200
|
70
|
+
message: OK
|
71
|
+
headers:
|
72
|
+
content-type:
|
73
|
+
- "*/*"
|
74
|
+
server:
|
75
|
+
- Apache
|
76
|
+
date:
|
77
|
+
- Tue, 12 Apr 2011 12:29:06 GMT
|
78
|
+
content-length:
|
79
|
+
- "709"
|
80
|
+
set-cookie:
|
81
|
+
- "[SESSION-COOKIE]"
|
82
|
+
body: |-
|
83
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><person><id>10185261</id><contacts><address><id>18565115</id><type>Office</type><street>Deputy Prime Minister's Office
|
84
|
+
70 Whitehall</street><city>London</city><zip>SW1A 2AS</zip><country>United Kingdom</country></address><email><id>18565116</id><type>Work</type><emailAddress>dpm@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Mr</title><firstName>Nick</firstName><lastName>Clegg</lastName><jobTitle>Deputy Prime Minister</jobTitle><organisationId>10185256</organisationId><organisationName>UK Government</organisationName></person>
|
85
|
+
http_version: "1.1"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: https://[API-TOKEN]:x@[ACCOUNT-NAME].capsulecrm.com:443/api/party/10185261
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
user-agent:
|
9
|
+
- CapsuleCRM ruby gem
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
content-type:
|
16
|
+
- "*/*"
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
date:
|
20
|
+
- Tue, 12 Apr 2011 12:29:07 GMT
|
21
|
+
content-length:
|
22
|
+
- "709"
|
23
|
+
set-cookie:
|
24
|
+
- "[SESSION-COOKIE]"
|
25
|
+
body: |-
|
26
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><person><id>10185261</id><contacts><address><id>18565115</id><type>Office</type><street>Deputy Prime Minister's Office
|
27
|
+
70 Whitehall</street><city>London</city><zip>SW1A 2AS</zip><country>United Kingdom</country></address><email><id>18565116</id><type>Work</type><emailAddress>dpm@example.com</emailAddress></email></contacts><pictureURL>https://d365sd3k9yw37.cloudfront.net/a/543325/theme/default/images/person_avatar_70.png</pictureURL><title>Mr</title><firstName>Nick</firstName><lastName>Clegg</lastName><jobTitle>Deputy Prime Minister</jobTitle><organisationId>10185256</organisationId><organisationName>UK Government</organisationName></person>
|
28
|
+
http_version: "1.1"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class PersonDotFindAllTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# nodoc
|
6
|
+
def setup
|
7
|
+
VCR.use_cassette 'person.find_all' do
|
8
|
+
@results = CapsuleCRM::Person.find :all
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# nodoc
|
14
|
+
def test_return_value_type
|
15
|
+
assert_equal CapsuleCRM::Collection, @results.class
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# nodoc
|
20
|
+
def test_return_value_size
|
21
|
+
assert_equal 6, @results.size
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# nodoc
|
26
|
+
def test_offset_parameter
|
27
|
+
VCR.use_cassette 'person.find_all_with_offset' do
|
28
|
+
@results = CapsuleCRM::Person.find :all, :offset => 3
|
29
|
+
assert_requested :get, /capsulecrm.*start=3/
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# nodoc
|
35
|
+
def test_limit_parameter
|
36
|
+
VCR.use_cassette 'person.find_all_with_limit' do
|
37
|
+
@results = CapsuleCRM::Person.find(:all, :limit => 2)
|
38
|
+
assert_requested :get, /capsulecrm.*limit=2/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# nodoc
|
44
|
+
def teardown
|
45
|
+
WebMock.reset!
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class PersonDotFindByIdTest < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def setup
|
5
|
+
VCR.use_cassette('person.find_by_id') do
|
6
|
+
@organisation = CapsuleCRM::Organisation.find organisations(:gov)
|
7
|
+
@person = CapsuleCRM::Person.find people(:pm)
|
8
|
+
@person.organisation # to record the request
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# nodoc
|
14
|
+
def test_attributes
|
15
|
+
assert_equal @person.title, 'Mr'
|
16
|
+
assert_equal @person.first_name, 'David'
|
17
|
+
assert_equal @person.last_name, 'Cameron'
|
18
|
+
assert_equal @person.job_title, 'Prime Minister'
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# nodoc
|
23
|
+
def test_organisation
|
24
|
+
assert_equal @organisation, @person.organisation
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# nodoc
|
29
|
+
def test_addresses
|
30
|
+
assert_equal CapsuleCRM::ChildCollection, @person.addresses.class
|
31
|
+
assert_equal 1, @person.addresses.size
|
32
|
+
@person.addresses.each { |address| assert address.is_a?(CapsuleCRM::Address) }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# nodoc
|
37
|
+
def test_emails
|
38
|
+
assert_equal CapsuleCRM::ChildCollection, @person.emails.class
|
39
|
+
assert_equal 1, @person.emails.size
|
40
|
+
@person.emails.each { |email| assert email.is_a?(CapsuleCRM::Email) }
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# nodoc
|
45
|
+
def test_phone_numbers
|
46
|
+
assert_equal CapsuleCRM::ChildCollection, @person.phone_numbers.class
|
47
|
+
assert_equal 1, @person.phone_numbers.size
|
48
|
+
@person.phone_numbers.each { |pn| assert pn.is_a?(CapsuleCRM::Phone) }
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def teardown
|
53
|
+
WebMock.reset!
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ruby-debug'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'webmock/test_unit'
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
|
8
|
+
# .gemspec does this usually
|
9
|
+
$: << File.expand_path('../../lib', __FILE__)
|
10
|
+
require 'capsulecrm'
|
11
|
+
|
12
|
+
# initialization - credentials only matter for VCR's first run
|
13
|
+
CapsuleCRM.account_name = ENV['CAPSULE_ACCOUNT'] || 'foo'
|
14
|
+
CapsuleCRM.api_token = ENV['CAPSULE_TOKEN'] || 'bar'
|
15
|
+
CapsuleCRM.initialize!
|
16
|
+
|
17
|
+
|
18
|
+
# nodoc
|
19
|
+
VCR.config do |c|
|
20
|
+
c.cassette_library_dir = 'test/fixtures/responses'
|
21
|
+
c.stub_with :webmock
|
22
|
+
c.filter_sensitive_data('[API-TOKEN]') { CapsuleCRM.api_token }
|
23
|
+
c.filter_sensitive_data('[ACCOUNT-NAME]') { CapsuleCRM.account_name }
|
24
|
+
c.filter_sensitive_data('[SESSION-COOKIE]') do |interaction|
|
25
|
+
interaction.response.headers['set-cookie'].first
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# nodoc
|
31
|
+
class Test::Unit::TestCase
|
32
|
+
|
33
|
+
# nodoc
|
34
|
+
def organisations(key)
|
35
|
+
ids = {
|
36
|
+
:gov => 10185256
|
37
|
+
}
|
38
|
+
ids[key]
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# nodoc
|
43
|
+
def people(key)
|
44
|
+
ids = {
|
45
|
+
:dpm => 10185261,
|
46
|
+
:pm => 10185257
|
47
|
+
}
|
48
|
+
ids[key]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class UpdatePersonTest < Test::Unit::TestCase
|
3
|
+
|
4
|
+
# nodoc
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
# nodoc
|
10
|
+
def test_with_changes
|
11
|
+
VCR.use_cassette('update_person') do
|
12
|
+
|
13
|
+
# get the person, cache the first name
|
14
|
+
person = CapsuleCRM::Person.find people(:dpm)
|
15
|
+
first_name = person.first_name
|
16
|
+
new_name = first_name.reverse
|
17
|
+
|
18
|
+
# change the name and update
|
19
|
+
person.first_name = new_name
|
20
|
+
assert person.save
|
21
|
+
|
22
|
+
# reload and check updates were saved
|
23
|
+
person = CapsuleCRM::Person.find person.id
|
24
|
+
assert_equal new_name, person.first_name
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# nodoc
|
31
|
+
def test_without_changes
|
32
|
+
VCR.use_cassette('update_person_without_changes') do
|
33
|
+
person = CapsuleCRM::Person.find people(:dpm)
|
34
|
+
assert person.save
|
35
|
+
assert_requested :put, /capsulecrm/, :times => 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# nodoc
|
41
|
+
def teardown
|
42
|
+
WebMock.reset!
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|