rock_rms 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/lib/rock_rms/client.rb +3 -0
- data/lib/rock_rms/error.rb +1 -1
- data/lib/rock_rms/resources/group.rb +35 -0
- data/lib/rock_rms/resources/group_member.rb +32 -0
- data/lib/rock_rms/resources/person.rb +16 -6
- data/lib/rock_rms/resources/phone_number.rb +15 -0
- data/lib/rock_rms/responses/campus.rb +34 -0
- data/lib/rock_rms/responses/group.rb +42 -0
- data/lib/rock_rms/responses/group_location.rb +34 -0
- data/lib/rock_rms/responses/location.rb +37 -0
- data/lib/rock_rms/responses/person.rb +29 -17
- data/lib/rock_rms/responses/phone_number.rb +27 -0
- data/lib/rock_rms/version.rb +1 -1
- data/spec/rock_rms/client_spec.rb +3 -3
- data/spec/rock_rms/resources/group_member_spec.rb +67 -0
- data/spec/rock_rms/resources/group_spec.rb +111 -0
- data/spec/rock_rms/resources/person_spec.rb +50 -0
- data/spec/rock_rms/resources/phone_number_spec.rb +34 -0
- data/spec/rock_rms/responses/campus_spec.rb +30 -0
- data/spec/rock_rms/responses/group_location_spec.rb +36 -0
- data/spec/rock_rms/responses/group_spec.rb +52 -0
- data/spec/rock_rms/responses/location_spec.rb +33 -0
- data/spec/rock_rms/responses/phone_number_spec.rb +25 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/client_factory.rb +12 -0
- data/spec/support/fixtures/campuses.json +23 -0
- data/spec/support/fixtures/create_group_member.json +1 -0
- data/spec/support/fixtures/families.json +45 -0
- data/spec/support/fixtures/group.json +43 -0
- data/spec/support/fixtures/group_locations.json +60 -0
- data/spec/support/fixtures/groups.json +32 -0
- data/spec/support/fixtures/groups_with_campus.json +53 -0
- data/spec/support/fixtures/groups_with_locations.json +92 -0
- data/spec/support/fixtures/groups_with_members.json +454 -0
- data/spec/support/fixtures/locations.json +42 -0
- data/spec/support/fixtures/people_search.json +36 -0
- data/spec/support/fixtures/phone_numbers.json +28 -0
- data/spec/support/fixtures_helper.rb +5 -0
- data/spec/support/rock_mock.rb +41 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3bf2fbd0092ad9afa7bc274f05201848d886b5f
|
4
|
+
data.tar.gz: 10715556852bd2472671646798a50ab35c78dd54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96eda68c2764ce38ecab7e8efcda03c6558c279c12f728bc9a927223ceb60bc40ce0ec971086475ce51d770f54036b8c933eec78d8c7ac1a9643d118b19a5536
|
7
|
+
data.tar.gz: 2862be265f417d8a922a6c45c123d2d8c85cb4347be3d2f279bfc949a0af56c8a3df5c20a424227ddbb8895d404678491e1e857c5b5a048dac1e79d05bba4277
|
data/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
⚠️ Code is highly subject to change. Consider this an alpha release.
|
2
|
-
|
3
1
|
### A Ruby wrapper for the Rock RMS API
|
4
2
|
|
5
3
|
To get a general overview of Rock RMS: https://www.rockrms.com
|
@@ -12,7 +10,7 @@ I'm a big fan of Rock so if you have problems using the gem or would like to see
|
|
12
10
|
Add this line to your application's Gemfile:
|
13
11
|
````ruby
|
14
12
|
# in your Gemfile
|
15
|
-
gem 'rock_rms', '~> 1.
|
13
|
+
gem 'rock_rms', '~> 1.1'
|
16
14
|
|
17
15
|
# then...
|
18
16
|
bundle install
|
data/lib/rock_rms/client.rb
CHANGED
@@ -10,8 +10,11 @@ module RockRMS
|
|
10
10
|
include RockRMS::Client::Batch
|
11
11
|
include RockRMS::Client::Donation
|
12
12
|
include RockRMS::Client::Fund
|
13
|
+
include RockRMS::Client::Group
|
14
|
+
include RockRMS::Client::GroupMember
|
13
15
|
include RockRMS::Client::PaymentMethod
|
14
16
|
include RockRMS::Client::Person
|
17
|
+
include RockRMS::Client::PhoneNumber
|
15
18
|
include RockRMS::Client::RecurringDonation
|
16
19
|
include RockRMS::Client::TransactionDetail
|
17
20
|
|
data/lib/rock_rms/error.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module Group
|
4
|
+
def list_groups(options = {})
|
5
|
+
RockRMS::Responses::Group.format(get(group_path, options))
|
6
|
+
end
|
7
|
+
|
8
|
+
def find_group(id)
|
9
|
+
RockRMS::Responses::Group.format(get(group_path(id)))
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_groups_for_person(person_id, options = {})
|
13
|
+
opts = options.dup
|
14
|
+
opts['$filter'] = Array(opts['$filter'])
|
15
|
+
.push("Members/any(m: m/PersonId eq #{person_id})")
|
16
|
+
.join(' and ')
|
17
|
+
opts['$expand'] ||= 'Members'
|
18
|
+
|
19
|
+
list_groups(opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def list_families_for_person(person_id, options = {})
|
23
|
+
RockRMS::Responses::Group.format(
|
24
|
+
get("Groups/GetFamilies/#{person_id}", options)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def group_path(id = nil)
|
31
|
+
id ? "Groups/#{id}" : 'Groups'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module GroupMember
|
4
|
+
def create_group_member(group_id:,
|
5
|
+
group_member_status:,
|
6
|
+
group_role_id:,
|
7
|
+
person_id:)
|
8
|
+
post(
|
9
|
+
group_member_path,
|
10
|
+
{
|
11
|
+
IsSystem: false,
|
12
|
+
GroupId: group_id,
|
13
|
+
GroupMemberStatus: group_member_status,
|
14
|
+
GroupRoleId: group_role_id,
|
15
|
+
PersonId: person_id
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_group_member(id)
|
21
|
+
delete(group_member_path(id))
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def group_member_path(id = nil)
|
27
|
+
id ? "GroupMembers/#{id}" : 'GroupMembers'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -3,22 +3,32 @@ module RockRMS
|
|
3
3
|
module Person
|
4
4
|
def list_people(options = {})
|
5
5
|
res = get(people_path, options)
|
6
|
-
RockRMS::Person.format(res)
|
6
|
+
RockRMS::Responses::Person.format(res)
|
7
7
|
end
|
8
8
|
|
9
9
|
def find_person(id)
|
10
10
|
res = get(people_path(id))
|
11
|
-
RockRMS::Person.format(res)
|
11
|
+
RockRMS::Responses::Person.format(res)
|
12
12
|
end
|
13
13
|
|
14
14
|
def find_person_by_email(email)
|
15
15
|
res = get("People/GetByEmail/#{email}")
|
16
|
-
RockRMS::Person.format(res)
|
16
|
+
RockRMS::Responses::Person.format(res)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
NAME_SEARCH_DEFAULTS = {
|
20
|
+
includeHtml: false,
|
21
|
+
includeDetails: true,
|
22
|
+
includeBusinesses: false,
|
23
|
+
includeDeceased: false
|
24
|
+
}.freeze
|
25
|
+
|
26
|
+
def find_person_by_name(full_name, options = {})
|
27
|
+
priority = options.merge(name: full_name)
|
28
|
+
|
29
|
+
RockRMS::Responses::Person.format(
|
30
|
+
get('People/Search', NAME_SEARCH_DEFAULTS.merge(priority))
|
31
|
+
)
|
22
32
|
end
|
23
33
|
|
24
34
|
def create_person(first_name:, last_name:, email:)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module PhoneNumber
|
4
|
+
def list_phone_numbers(options = {})
|
5
|
+
RockRMS::Responses::PhoneNumber.format(get(phone_number_path, options))
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def phone_number_path(id = nil)
|
11
|
+
id ? "PhoneNumbers/#{id}" : "PhoneNumbers"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module RockRMS
|
2
|
+
module Responses
|
3
|
+
class Campus
|
4
|
+
MAP = {
|
5
|
+
id: 'Id',
|
6
|
+
name: 'Name',
|
7
|
+
is_active: 'IsActive',
|
8
|
+
description: 'Description',
|
9
|
+
short_code: 'ShortCode',
|
10
|
+
url: 'Url',
|
11
|
+
location_id: 'LocationId',
|
12
|
+
phone_number: 'PhoneNumber',
|
13
|
+
service_times: 'ServiceTimes',
|
14
|
+
guid: 'Guid'
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
def self.format(data)
|
18
|
+
if data.is_a?(Array)
|
19
|
+
data.map { |object| format_single(object) }
|
20
|
+
else
|
21
|
+
format_single(data)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.format_single(data)
|
28
|
+
MAP.each.with_object({}) do |(l,r), object|
|
29
|
+
object[l] = data[r]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module RockRMS
|
2
|
+
module Responses
|
3
|
+
class Group
|
4
|
+
MAP = {
|
5
|
+
id: "Id",
|
6
|
+
name: "Name",
|
7
|
+
group_type_id: "GroupTypeId",
|
8
|
+
parent_group_id: "ParentGroupId",
|
9
|
+
campus_id: "CampusId",
|
10
|
+
is_active: "IsActive",
|
11
|
+
guid: "Guid",
|
12
|
+
members: "Members"
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def self.format(data)
|
16
|
+
if data.is_a?(Array)
|
17
|
+
data.map { |object| format_single(object) }
|
18
|
+
else
|
19
|
+
format_single(data)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.format_single(data)
|
26
|
+
result = MAP.each.with_object({}) do |(l,r), object|
|
27
|
+
object[l] = data[r]
|
28
|
+
end
|
29
|
+
|
30
|
+
if group_locations = data['GroupLocations']
|
31
|
+
result[:group_locations] = GroupLocation.format(group_locations)
|
32
|
+
end
|
33
|
+
|
34
|
+
if campus = data['Campus']
|
35
|
+
result[:campus] = Campus.format(campus)
|
36
|
+
end
|
37
|
+
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module RockRMS
|
2
|
+
module Responses
|
3
|
+
class GroupLocation
|
4
|
+
MAP = {
|
5
|
+
id: 'Id',
|
6
|
+
group_id: 'GroupId',
|
7
|
+
location_id: 'LocationId',
|
8
|
+
guid: 'Guid'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def self.format(data)
|
12
|
+
if data.is_a?(Array)
|
13
|
+
data.map { |object| format_single(object) }
|
14
|
+
else
|
15
|
+
format_single(data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def self.format_single(data)
|
22
|
+
result = MAP.each.with_object({}) do |(l,r), object|
|
23
|
+
object[l] = data[r]
|
24
|
+
end
|
25
|
+
|
26
|
+
if location = data['Location']
|
27
|
+
result[:location] = Location.format(location)
|
28
|
+
end
|
29
|
+
|
30
|
+
result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RockRMS
|
2
|
+
module Responses
|
3
|
+
class Location
|
4
|
+
MAP = {
|
5
|
+
id: 'Id',
|
6
|
+
name: 'Name',
|
7
|
+
is_active: 'IsActive',
|
8
|
+
street1: 'Street1',
|
9
|
+
street2: 'Street2',
|
10
|
+
city: 'City',
|
11
|
+
county: 'County',
|
12
|
+
state: 'State',
|
13
|
+
country: 'Country',
|
14
|
+
postal_code: 'PostalCode',
|
15
|
+
latitude: 'Latitude',
|
16
|
+
longitude: 'Longitude',
|
17
|
+
guid: 'Guid'
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def self.format(data)
|
21
|
+
if data.is_a?(Array)
|
22
|
+
data.map { |object| format_single(object) }
|
23
|
+
else
|
24
|
+
format_single(data)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def self.format_single(data)
|
31
|
+
MAP.each.with_object({}) do |(l,r), object|
|
32
|
+
object[l] = data[r]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,23 +1,35 @@
|
|
1
1
|
module RockRMS
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module Responses
|
3
|
+
class Person
|
4
|
+
MAP = {
|
5
|
+
id: 'Id',
|
6
|
+
name: 'FullName',
|
7
|
+
email: 'Email',
|
8
|
+
first_name: 'FirstName',
|
9
|
+
last_name: 'LastName',
|
10
|
+
giving_id: 'GivingId',
|
11
|
+
alias_id: 'PrimaryAliasId',
|
12
|
+
connection_status_value_id: 'ConnectionStatusValueId'
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def self.format(data)
|
16
|
+
if data.is_a?(Array)
|
17
|
+
data.map { |object| format_single(object) }
|
18
|
+
else
|
19
|
+
format_single(data)
|
20
|
+
end
|
8
21
|
end
|
9
|
-
end
|
10
22
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
giving_id: person['GivingId'],
|
19
|
-
alias_id: person['PrimaryAliasId']
|
20
|
-
}
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.format_single(data)
|
26
|
+
MAP.each.with_object({}) do |(l,r), object|
|
27
|
+
object[l] = data[r]
|
28
|
+
end
|
29
|
+
end
|
21
30
|
end
|
22
31
|
end
|
32
|
+
|
33
|
+
# for backwards compatibility
|
34
|
+
Person = Responses::Person
|
23
35
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RockRMS
|
2
|
+
module Responses
|
3
|
+
class PhoneNumber
|
4
|
+
MAP = {
|
5
|
+
id: 'Id',
|
6
|
+
person_id: 'PersonId',
|
7
|
+
number: 'Number',
|
8
|
+
formatted: 'NumberFormatted',
|
9
|
+
formatted_with_cc: 'NumberFormattedWithCountryCode'
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def self.format(response)
|
13
|
+
if response.is_a?(Array)
|
14
|
+
response.map { |number| format_number(number) }
|
15
|
+
else
|
16
|
+
format_number(response)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.format_number(data)
|
21
|
+
MAP.each.with_object({}) do |(l,r), object|
|
22
|
+
object[l] = data[r]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rock_rms/version.rb
CHANGED
@@ -117,15 +117,15 @@ RSpec.describe RockRMS::Client do
|
|
117
117
|
include_examples 'param request', :delete
|
118
118
|
end
|
119
119
|
|
120
|
-
describe '#patch(path,
|
120
|
+
describe '#patch(path, options = {})' do
|
121
121
|
include_examples 'body request', :patch
|
122
122
|
end
|
123
123
|
|
124
|
-
describe '#post(path,
|
124
|
+
describe '#post(path, options = {})' do
|
125
125
|
include_examples 'body request', :post
|
126
126
|
end
|
127
127
|
|
128
|
-
describe '#put(path,
|
128
|
+
describe '#put(path, options = {})' do
|
129
129
|
include_examples 'body request', :put
|
130
130
|
end
|
131
131
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RockRMS::Client::GroupMember, type: :model do
|
4
|
+
include_context 'resource specs'
|
5
|
+
|
6
|
+
describe '#create_group_member' do
|
7
|
+
context 'arguments' do
|
8
|
+
it 'require `group_id`' do
|
9
|
+
expect { client.create_group_member }
|
10
|
+
.to raise_error(ArgumentError, /group_id/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'require `group_member_status`' do
|
14
|
+
expect { client.create_group_member }
|
15
|
+
.to raise_error(ArgumentError, /group_member_status/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'require `group_role_id`' do
|
19
|
+
expect { client.create_group_member }
|
20
|
+
.to raise_error(ArgumentError, /group_role_id/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'require `person_id`' do
|
24
|
+
expect { client.create_group_member }
|
25
|
+
.to raise_error(ArgumentError, /person_id/)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
subject(:resource) {
|
31
|
+
client.create_group_member(
|
32
|
+
group_id: 123,
|
33
|
+
group_member_status: 1,
|
34
|
+
group_role_id: 456,
|
35
|
+
person_id: 123456
|
36
|
+
)
|
37
|
+
}
|
38
|
+
|
39
|
+
it 'returns integer' do
|
40
|
+
expect(resource).to be_a(Integer)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'passes options' do
|
44
|
+
expect(client).to receive(:post)
|
45
|
+
.with('GroupMembers', {
|
46
|
+
IsSystem: false,
|
47
|
+
GroupId: 123,
|
48
|
+
GroupMemberStatus: 1,
|
49
|
+
GroupRoleId: 456,
|
50
|
+
PersonId: 123456
|
51
|
+
})
|
52
|
+
.and_call_original
|
53
|
+
resource
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#delete_group_member' do
|
58
|
+
it 'returns nothing' do
|
59
|
+
expect(client.delete_group_member(123)).to eq(nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'passes id' do
|
63
|
+
expect(client).to receive(:delete).with('GroupMembers/123')
|
64
|
+
client.delete_group_member(123)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RockRMS::Client::Group, type: :model do
|
4
|
+
include_context 'resource specs'
|
5
|
+
|
6
|
+
describe '#find_group(id)' do
|
7
|
+
it 'returns a hash' do
|
8
|
+
expect(client.find_group(123)).to be_a(Hash)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'queries groups' do
|
12
|
+
expect(client).to receive(:get).with('Groups/123')
|
13
|
+
.and_call_original
|
14
|
+
|
15
|
+
resource = client.find_group(123)
|
16
|
+
|
17
|
+
expect(resource[:id]).to eq(112233)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'formats with Group' do
|
21
|
+
response = double
|
22
|
+
expect(RockRMS::Responses::Group).to receive(:format).with(response)
|
23
|
+
allow(client).to receive(:get).and_return(response)
|
24
|
+
client.find_group(123)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#list_groups(options = {})' do
|
29
|
+
it 'returns a array of hashes' do
|
30
|
+
resource = client.list_groups
|
31
|
+
expect(resource).to be_a(Array)
|
32
|
+
expect(resource.first).to be_a(Hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'queries groups' do
|
36
|
+
expect(client).to receive(:get).with('Groups', {})
|
37
|
+
.and_call_original
|
38
|
+
client.list_groups
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'passes options' do
|
42
|
+
expect(client).to receive(:get)
|
43
|
+
.with('Groups', { option1: '1' })
|
44
|
+
.and_return([])
|
45
|
+
client.list_groups(option1: '1')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'formats with Group' do
|
49
|
+
response = double
|
50
|
+
expect(RockRMS::Responses::Group).to receive(:format).with(response)
|
51
|
+
allow(client).to receive(:get).and_return(response)
|
52
|
+
client.list_groups
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#list_groups_for_person' do
|
57
|
+
it 'delegates to `list_groups`' do
|
58
|
+
expect(client).to receive(:list_groups)
|
59
|
+
client.list_groups_for_person(123)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'filters members by person_id' do
|
63
|
+
expect(client).to receive(:list_groups).with(
|
64
|
+
hash_including('$filter' => 'Members/any(m: m/PersonId eq 123)')
|
65
|
+
)
|
66
|
+
client.list_groups_for_person(123)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'expands member data by default' do
|
70
|
+
expect(client).to receive(:list_groups).with(
|
71
|
+
hash_including('$expand' => 'Members')
|
72
|
+
)
|
73
|
+
client.list_groups_for_person(123)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'supports passing additional filters' do
|
77
|
+
expect(client).to receive(:list_groups).with(
|
78
|
+
hash_including('$filter' => /GroupTypeId eq 45 and /)
|
79
|
+
)
|
80
|
+
client.list_groups_for_person(123, '$filter' => 'GroupTypeId eq 45')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#list_families_for_person' do
|
85
|
+
it 'returns a array of hashes' do
|
86
|
+
resource = client.list_families_for_person(123)
|
87
|
+
expect(resource).to be_a(Array)
|
88
|
+
expect(resource.first).to be_a(Hash)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'queries families scoped to person' do
|
92
|
+
expect(client).to receive(:get).with('Groups/GetFamilies/123', {})
|
93
|
+
.and_call_original
|
94
|
+
client.list_families_for_person(123)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'passes options' do
|
98
|
+
expect(client).to receive(:get)
|
99
|
+
.with('Groups/GetFamilies/123', { option1: '1' })
|
100
|
+
.and_return([])
|
101
|
+
client.list_families_for_person(123, option1: '1')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'formats with Group' do
|
105
|
+
response = double
|
106
|
+
allow(client).to receive(:get).and_return(response)
|
107
|
+
expect(RockRMS::Responses::Group).to receive(:format).with(response)
|
108
|
+
client.list_families_for_person(123)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RockRMS::Client::Person, type: :model do
|
4
|
+
include_context 'resource specs'
|
5
|
+
|
6
|
+
describe '#find_person_by_name(full_name)' do
|
7
|
+
it 'returns a array of hashes' do
|
8
|
+
resource = client.find_person_by_name('Some Name')
|
9
|
+
expect(resource).to be_a(Array)
|
10
|
+
expect(resource.first).to be_a(Hash)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'queries people by name' do
|
14
|
+
expect(client).to receive(:get)
|
15
|
+
.with('People/Search', hash_including(name: 'Some Name'))
|
16
|
+
.and_call_original
|
17
|
+
client.find_person_by_name('Some Name')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'includes default options' do
|
21
|
+
expect(client).to receive(:get)
|
22
|
+
.with(
|
23
|
+
'People/Search',
|
24
|
+
hash_including(**described_class::NAME_SEARCH_DEFAULTS)
|
25
|
+
).and_call_original
|
26
|
+
client.find_person_by_name('Some Name')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'passes options' do
|
30
|
+
expect(client).to receive(:get)
|
31
|
+
.with('People/Search', hash_including(option1: '1'))
|
32
|
+
.and_call_original
|
33
|
+
client.find_person_by_name('Some Name', option1: '1')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'overrides default options' do
|
37
|
+
expect(client).to receive(:get)
|
38
|
+
.with('People/Search', hash_including(includeHtml: true))
|
39
|
+
.and_call_original
|
40
|
+
client.find_person_by_name('Some Name', includeHtml: true)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'formats with Person' do
|
44
|
+
response = double
|
45
|
+
expect(RockRMS::Responses::Person).to receive(:format).with(response)
|
46
|
+
allow(client).to receive(:get).and_return(response)
|
47
|
+
client.find_person_by_name('Some Name')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|