ngp_van 0.1.1
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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/README.md +117 -0
- data/lib/ngp_van.rb +47 -0
- data/lib/ngp_van/client.rb +41 -0
- data/lib/ngp_van/client/activist_codes.rb +15 -0
- data/lib/ngp_van/client/canvass_responses.rb +19 -0
- data/lib/ngp_van/client/codes.rb +31 -0
- data/lib/ngp_van/client/district_fields.rb +15 -0
- data/lib/ngp_van/client/event_types.rb +15 -0
- data/lib/ngp_van/client/events.rb +31 -0
- data/lib/ngp_van/client/locations.rb +27 -0
- data/lib/ngp_van/client/minivan_exports.rb +15 -0
- data/lib/ngp_van/client/notes.rb +19 -0
- data/lib/ngp_van/client/people.rb +31 -0
- data/lib/ngp_van/client/printed_lists.rb +15 -0
- data/lib/ngp_van/client/signups.rb +31 -0
- data/lib/ngp_van/client/survey_questions.rb +15 -0
- data/lib/ngp_van/client/users.rb +19 -0
- data/lib/ngp_van/configuration.rb +74 -0
- data/lib/ngp_van/connection.rb +32 -0
- data/lib/ngp_van/default.rb +41 -0
- data/lib/ngp_van/error.rb +124 -0
- data/lib/ngp_van/request.rb +39 -0
- data/lib/ngp_van/response.rb +15 -0
- data/lib/ngp_van/response/raise_error.rb +17 -0
- data/lib/ngp_van/version.rb +19 -0
- data/spec/ngp_van/client/activist_codes_spec.rb +88 -0
- data/spec/ngp_van/client/canvass_responses_spec.rb +126 -0
- data/spec/ngp_van/client/codes_spec.rb +197 -0
- data/spec/ngp_van/client/district_fields_spec.rb +79 -0
- data/spec/ngp_van/client/event_types_spec.rb +69 -0
- data/spec/ngp_van/client/events_spec.rb +205 -0
- data/spec/ngp_van/client/locations_spec.rb +172 -0
- data/spec/ngp_van/client/minivan_exports_spec.rb +82 -0
- data/spec/ngp_van/client/notes_spec.rb +107 -0
- data/spec/ngp_van/client/people_spec.rb +227 -0
- data/spec/ngp_van/client/printed_lists_spec.rb +91 -0
- data/spec/ngp_van/client/signups_spec.rb +209 -0
- data/spec/ngp_van/client/survey_questions_spec.rb +83 -0
- data/spec/ngp_van/client/users_spec.rb +122 -0
- data/spec/ngp_van/configuration_spec.rb +116 -0
- data/spec/ngp_van/request_spec.rb +137 -0
- data/spec/ngp_van_spec.rb +29 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/fixtures/activist_code.json +10 -0
- data/spec/support/fixtures/activist_codes.json +36 -0
- data/spec/support/fixtures/canvass_response.json +25 -0
- data/spec/support/fixtures/canvass_responses_contact_types.json +10 -0
- data/spec/support/fixtures/canvass_responses_input_types.json +26 -0
- data/spec/support/fixtures/canvass_responses_result_codes.json +26 -0
- data/spec/support/fixtures/code.json +18 -0
- data/spec/support/fixtures/code_supported_entities.json +5 -0
- data/spec/support/fixtures/codes.json +55 -0
- data/spec/support/fixtures/create_code.json +16 -0
- data/spec/support/fixtures/create_event.json +62 -0
- data/spec/support/fixtures/create_event_shift.json +5 -0
- data/spec/support/fixtures/create_location.json +9 -0
- data/spec/support/fixtures/create_signup.json +32 -0
- data/spec/support/fixtures/create_user_district_field_values.json +7 -0
- data/spec/support/fixtures/district_field.json +28 -0
- data/spec/support/fixtures/district_fields.json +22 -0
- data/spec/support/fixtures/event.json +139 -0
- data/spec/support/fixtures/event_type.json +75 -0
- data/spec/support/fixtures/event_types.json +77 -0
- data/spec/support/fixtures/events.json +86 -0
- data/spec/support/fixtures/location.json +19 -0
- data/spec/support/fixtures/locations.json +25 -0
- data/spec/support/fixtures/match_candidate.json +61 -0
- data/spec/support/fixtures/match_response.json +4 -0
- data/spec/support/fixtures/minivan_export.json +66 -0
- data/spec/support/fixtures/minivan_exports.json +72 -0
- data/spec/support/fixtures/note_categories.json +17 -0
- data/spec/support/fixtures/note_category.json +8 -0
- data/spec/support/fixtures/note_category_types.json +6 -0
- data/spec/support/fixtures/person.json +61 -0
- data/spec/support/fixtures/printed_list.json +52 -0
- data/spec/support/fixtures/printed_lists.json +58 -0
- data/spec/support/fixtures/signup.json +55 -0
- data/spec/support/fixtures/signup_statuses.json +26 -0
- data/spec/support/fixtures/signups.json +112 -0
- data/spec/support/fixtures/survey_question.json +36 -0
- data/spec/support/fixtures/survey_questions.json +85 -0
- data/spec/support/fixtures/update_code.json +22 -0
- data/spec/support/fixtures/update_event.json +61 -0
- data/spec/support/fixtures/update_signup.json +35 -0
- data/spec/support/fixtures/update_user_district_field_values.json +6 -0
- data/spec/support/fixtures/user_district_field_values.json +7 -0
- data/spec/support/path_helpers.rb +9 -0
- data/spec/support/rspec.rb +51 -0
- data/spec/support/url_helpers.rb +5 -0
- data/spec/support/webmock.rb +5 -0
- metadata +269 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe Notes do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#note_category_types' do
|
11
|
+
let(:params) { Hash.new }
|
12
|
+
let(:response) { fixture('note_category_types.json') }
|
13
|
+
let(:url) { build_url(client: client, path: 'notes/categoryTypes') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_request(:get, url)
|
17
|
+
.with(query: params)
|
18
|
+
.to_return(
|
19
|
+
body: response
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'requests the correct resource' do
|
24
|
+
client.note_category_types(params: params)
|
25
|
+
expect(
|
26
|
+
a_request(:get, url)
|
27
|
+
.with(query: params)
|
28
|
+
).to have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns an array of items' do
|
32
|
+
note_category_types = client.note_category_types(params: params)
|
33
|
+
expect(note_category_types).to be_a(Array)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the requested note_category_types' do
|
37
|
+
note_category_types = client.note_category_types(params: params)
|
38
|
+
expect(note_category_types.first).to eq('Person')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#note_categories' do
|
43
|
+
let(:params) { Hash.new }
|
44
|
+
let(:response) { fixture('note_categories.json') }
|
45
|
+
let(:url) { build_url(client: client, path: 'notes/categories') }
|
46
|
+
|
47
|
+
before do
|
48
|
+
stub_request(:get, url)
|
49
|
+
.with(query: params)
|
50
|
+
.to_return(
|
51
|
+
body: response
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'requests the correct resource' do
|
56
|
+
client.note_categories(params: params)
|
57
|
+
expect(
|
58
|
+
a_request(:get, url)
|
59
|
+
.with(query: params)
|
60
|
+
).to have_been_made
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns an array of items' do
|
64
|
+
note_categories = client.note_categories(params: params)
|
65
|
+
expect(note_categories).to be_a(Array)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns the requested note_categories' do
|
69
|
+
note_categories = client.note_categories(params: params)
|
70
|
+
expect(note_categories.first['noteCategoryId']).to eq(24)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#note_category' do
|
75
|
+
let(:params) { Hash.new }
|
76
|
+
let(:response) { fixture('note_category.json') }
|
77
|
+
let(:url) { build_url(client: client, path: 'notes/categories/24') }
|
78
|
+
|
79
|
+
before do
|
80
|
+
stub_request(:get, url)
|
81
|
+
.with(query: params)
|
82
|
+
.to_return(
|
83
|
+
body: response
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'requests the correct resource' do
|
88
|
+
client.note_category(id: 24, params: params)
|
89
|
+
expect(
|
90
|
+
a_request(:get, url)
|
91
|
+
.with(query: params)
|
92
|
+
).to have_been_made
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns a note category object' do
|
96
|
+
note_category = client.note_category(id: 24, params: params)
|
97
|
+
expect(note_category).to be_a(Hash)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns the requested note_category' do
|
101
|
+
note_category = client.note_category(id: 24, params: params)
|
102
|
+
expect(note_category['noteCategoryId']).to eq(24)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
# rubocop:disable Metrics/ClassLength
|
7
|
+
class Client
|
8
|
+
RSpec.describe People do
|
9
|
+
let(:client) { NgpVan::Client.new }
|
10
|
+
|
11
|
+
describe '#find_person' do
|
12
|
+
let(:body) do
|
13
|
+
JSON.parse(File.read(fixture_path + '/match_candidate.json'))
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:response) { fixture('match_response.json') }
|
17
|
+
let(:url) { build_url(client: client, path: 'people/find') }
|
18
|
+
|
19
|
+
before do
|
20
|
+
stub_request(:post, url)
|
21
|
+
.with(body: JSON.generate(body))
|
22
|
+
.to_return(
|
23
|
+
body: response
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'requests the correct resource' do
|
28
|
+
client.find_person(body: body)
|
29
|
+
expect(
|
30
|
+
a_request(:post, url)
|
31
|
+
.with(
|
32
|
+
body: body
|
33
|
+
)
|
34
|
+
).to have_been_made
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the match' do
|
38
|
+
match = client.find_person(body: body)
|
39
|
+
expect(match['vanId']).to eq(1_264_324)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#find_or_create_person' do
|
44
|
+
let(:body) do
|
45
|
+
JSON.parse(File.read(fixture_path + '/match_candidate.json'))
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:response) { fixture('match_response.json') }
|
49
|
+
let(:url) { build_url(client: client, path: 'people/findOrCreate') }
|
50
|
+
|
51
|
+
before do
|
52
|
+
stub_request(:post, url)
|
53
|
+
.with(body: JSON.generate(body))
|
54
|
+
.to_return(
|
55
|
+
body: response
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'requests the correct resource' do
|
60
|
+
client.find_or_create_person(body: body)
|
61
|
+
expect(
|
62
|
+
a_request(:post, url)
|
63
|
+
.with(
|
64
|
+
body: body
|
65
|
+
)
|
66
|
+
).to have_been_made
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns the match' do
|
70
|
+
match = client.find_or_create_person(body: body)
|
71
|
+
expect(match['vanId']).to eq(1_264_324)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#person' do
|
76
|
+
let(:params) do
|
77
|
+
{
|
78
|
+
'$expand' => 'phones,emails,addresses'
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
let(:response) { fixture('person.json') }
|
83
|
+
let(:url) { build_url(client: client, path: 'people/215501') }
|
84
|
+
|
85
|
+
before do
|
86
|
+
stub_request(:get, url)
|
87
|
+
.with(query: params)
|
88
|
+
.to_return(
|
89
|
+
body: response
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'requests the correct resource' do
|
94
|
+
client.person(id: 215_501, params: params)
|
95
|
+
expect(
|
96
|
+
a_request(:get, url)
|
97
|
+
.with(query: params)
|
98
|
+
).to have_been_made
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'returns a person object' do
|
102
|
+
person = client.person(id: 215_501, params: params)
|
103
|
+
expect(person).to be_a(Hash)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'returns the requested person' do
|
107
|
+
person = client.person(id: 215_501, params: params)
|
108
|
+
expect(person['vanId']).to eq(215_501)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#person_by_type' do
|
113
|
+
let(:params) do
|
114
|
+
{
|
115
|
+
'$expand' => 'phones,emails,addresses'
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
let(:response) { fixture('person.json') }
|
120
|
+
let(:url) { build_url(client: client, path: 'people/dwid:215501') }
|
121
|
+
|
122
|
+
before do
|
123
|
+
stub_request(:get, url)
|
124
|
+
.with(query: params)
|
125
|
+
.to_return(
|
126
|
+
body: response
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'requests the correct resource' do
|
131
|
+
client.person_by_type(id: 215_501, type: 'dwid', params: params)
|
132
|
+
expect(
|
133
|
+
a_request(:get, url)
|
134
|
+
.with(query: params)
|
135
|
+
).to have_been_made
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'returns a person object' do
|
139
|
+
person = client.person_by_type(id: 215_501, type: 'dwid',
|
140
|
+
params: params)
|
141
|
+
expect(person).to be_a(Hash)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'returns the requested person' do
|
145
|
+
person = client.person_by_type(id: 215_501, type: 'dwid',
|
146
|
+
params: params)
|
147
|
+
expect(person['vanId']).to eq(215_501)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe '#create_canvass_responses_for_person' do
|
152
|
+
let(:body) do
|
153
|
+
JSON.parse(File.read(fixture_path + '/canvass_response.json'))
|
154
|
+
end
|
155
|
+
|
156
|
+
let(:url) do
|
157
|
+
build_url(client: client, path: 'people/215501/canvassResponses')
|
158
|
+
end
|
159
|
+
|
160
|
+
before do
|
161
|
+
stub_request(:post, url)
|
162
|
+
.with(body: JSON.generate(body))
|
163
|
+
.to_return(
|
164
|
+
body: '',
|
165
|
+
status: 204
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'requests the correct resource' do
|
170
|
+
client.create_canvass_responses_for_person(id: 215_501, body: body)
|
171
|
+
expect(
|
172
|
+
a_request(:post, url)
|
173
|
+
.with(
|
174
|
+
body: body
|
175
|
+
)
|
176
|
+
).to have_been_made
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'returns an empty response body' do
|
180
|
+
expect(
|
181
|
+
client.create_canvass_responses_for_person(id: 215_501, body: body)
|
182
|
+
).to eq('')
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#create_canvass_responses_for_person_by_type' do
|
187
|
+
let(:body) do
|
188
|
+
JSON.parse(File.read(fixture_path + '/canvass_response.json'))
|
189
|
+
end
|
190
|
+
|
191
|
+
let(:url) do
|
192
|
+
build_url(client: client, path: 'people/dwid:215501/canvassResponses')
|
193
|
+
end
|
194
|
+
|
195
|
+
before do
|
196
|
+
stub_request(:post, url)
|
197
|
+
.with(body: JSON.generate(body))
|
198
|
+
.to_return(
|
199
|
+
body: '',
|
200
|
+
status: 204
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'requests the correct resource' do
|
205
|
+
client.create_canvass_responses_for_person_by_type(
|
206
|
+
id: 215_501, type: 'dwid', body: body
|
207
|
+
)
|
208
|
+
|
209
|
+
expect(
|
210
|
+
a_request(:post, url)
|
211
|
+
.with(
|
212
|
+
body: body
|
213
|
+
)
|
214
|
+
).to have_been_made
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'returns an empty response body' do
|
218
|
+
expect(
|
219
|
+
client.create_canvass_responses_for_person_by_type(
|
220
|
+
id: 215_501, type: 'dwid', body: body
|
221
|
+
)
|
222
|
+
).to eq('')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe PrintedLists do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#printed_lists' do
|
11
|
+
let(:params) do
|
12
|
+
{
|
13
|
+
generatedAfter: '2012-10-01',
|
14
|
+
generatedBefore: '2012-11-01',
|
15
|
+
createdBy: '123',
|
16
|
+
folderName: 'GOTV',
|
17
|
+
turfName: 'Precinct+1',
|
18
|
+
hasSignup: true,
|
19
|
+
'$expand' => 'eventSignups'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:response) { fixture('printed_lists.json') }
|
24
|
+
let(:url) { build_url(client: client, path: 'printedLists') }
|
25
|
+
|
26
|
+
before do
|
27
|
+
stub_request(:get, url)
|
28
|
+
.with(query: params)
|
29
|
+
.to_return(
|
30
|
+
body: response
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'requests the correct resource' do
|
35
|
+
client.printed_lists(params: params)
|
36
|
+
expect(
|
37
|
+
a_request(:get, url)
|
38
|
+
.with(query: params)
|
39
|
+
).to have_been_made
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns an array of items' do
|
43
|
+
printed_lists = client.printed_lists(params: params)
|
44
|
+
expect(printed_lists['items']).to be_a(Array)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns the requested printed_lists' do
|
48
|
+
printed_lists = client.printed_lists(params: params)
|
49
|
+
expect(printed_lists['items'].first['number']).to eq('15981815-49117')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#printed_list' do
|
54
|
+
let(:params) { Hash.new }
|
55
|
+
let(:response) { fixture('printed_list.json') }
|
56
|
+
|
57
|
+
let(:url) do
|
58
|
+
build_url(client: client, path: 'printedLists/15981815-49117')
|
59
|
+
end
|
60
|
+
|
61
|
+
before do
|
62
|
+
stub_request(:get, url)
|
63
|
+
.with(query: params)
|
64
|
+
.to_return(
|
65
|
+
body: response
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'requests the correct resource' do
|
70
|
+
client.printed_list(id: '15981815-49117', params: params)
|
71
|
+
expect(
|
72
|
+
a_request(:get, url)
|
73
|
+
.with(query: params)
|
74
|
+
).to have_been_made
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns a printed_list object' do
|
78
|
+
expect(
|
79
|
+
client.printed_list(id: '15981815-49117', params: params)
|
80
|
+
).to be_a(Hash)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns the requested printed_list' do
|
84
|
+
printed_list = client.printed_list(id: '15981815-49117',
|
85
|
+
params: params)
|
86
|
+
expect(printed_list['number']).to eq('15981815-49117')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
# rubocop:disable Metrics/ClassLength
|
7
|
+
class Client
|
8
|
+
RSpec.describe Signups do
|
9
|
+
let(:client) { NgpVan::Client.new }
|
10
|
+
|
11
|
+
describe '#signup_statuses' do
|
12
|
+
let(:params) do
|
13
|
+
{
|
14
|
+
eventTypeId: 143_856
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:response) { fixture('signup_statuses.json') }
|
19
|
+
let(:url) { build_url(client: client, path: 'signups/statuses') }
|
20
|
+
|
21
|
+
before do
|
22
|
+
stub_request(:get, url)
|
23
|
+
.with(query: params)
|
24
|
+
.to_return(
|
25
|
+
body: response
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'requests the correct resource' do
|
30
|
+
client.signup_statuses(params: params)
|
31
|
+
expect(
|
32
|
+
a_request(:get, url)
|
33
|
+
.with(query: params)
|
34
|
+
).to have_been_made
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns an array of signup_statuses' do
|
38
|
+
signup_statuses = client.signup_statuses(params: params)
|
39
|
+
expect(signup_statuses).to be_a(Array)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the requested signup statuses statuses' do
|
43
|
+
signup_statuses = client.signup_statuses(params: params)
|
44
|
+
expect(signup_statuses.first['name']).to eq('Completed')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#signup' do
|
49
|
+
let(:params) { Hash.new }
|
50
|
+
let(:response) { fixture('signup.json') }
|
51
|
+
let(:url) { build_url(client: client, path: 'signups/2452') }
|
52
|
+
|
53
|
+
before do
|
54
|
+
stub_request(:get, url)
|
55
|
+
.with(query: params)
|
56
|
+
.to_return(
|
57
|
+
body: response
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'requests the correct resource' do
|
62
|
+
client.signup(id: 2_452, params: params)
|
63
|
+
expect(
|
64
|
+
a_request(:get, url)
|
65
|
+
.with(query: params)
|
66
|
+
).to have_been_made
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns a signup object' do
|
70
|
+
signup = client.signup(id: 2_452, params: params)
|
71
|
+
expect(signup).to be_a(Hash)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns the requested signup' do
|
75
|
+
signup = client.signup(id: 2_452, params: params)
|
76
|
+
expect(signup['eventSignupId']).to eq(2_452)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#signups' do
|
81
|
+
let(:params) do
|
82
|
+
{
|
83
|
+
vanId: '100476252',
|
84
|
+
'$expand' => 'printedLists,minivanExports',
|
85
|
+
hasPrintedList: true,
|
86
|
+
hasMinivanExport: true
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:response) { fixture('signups.json') }
|
91
|
+
let(:url) { build_url(client: client, path: 'signups') }
|
92
|
+
|
93
|
+
before do
|
94
|
+
stub_request(:get, url)
|
95
|
+
.with(query: params)
|
96
|
+
.to_return(
|
97
|
+
body: response
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'requests the correct resource' do
|
102
|
+
client.signups(params: params)
|
103
|
+
expect(
|
104
|
+
a_request(:get, url)
|
105
|
+
.with(query: params)
|
106
|
+
).to have_been_made
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns an array of signups' do
|
110
|
+
signups = client.signups(params: params)
|
111
|
+
expect(signups['items']).to be_a(Array)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'returns the requested signup statuses statuses' do
|
115
|
+
signups = client.signups(params: params)
|
116
|
+
expect(signups['items'].first['eventSignupId']).to eq(2_452)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#create_signup' do
|
121
|
+
let(:body) do
|
122
|
+
JSON.parse(File.read(fixture_path + '/create_signup.json'))
|
123
|
+
end
|
124
|
+
|
125
|
+
let(:url) { build_url(client: client, path: 'signups') }
|
126
|
+
|
127
|
+
before do
|
128
|
+
stub_request(:post, url)
|
129
|
+
.with(body: JSON.generate(body))
|
130
|
+
.to_return(
|
131
|
+
body: '2452',
|
132
|
+
status: 201,
|
133
|
+
headers: {
|
134
|
+
'Location' => build_url(client: client, path: '/signups/2452')
|
135
|
+
}
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'requests the correct resource' do
|
140
|
+
client.create_signup(body: body)
|
141
|
+
expect(
|
142
|
+
a_request(:post, url)
|
143
|
+
.with(
|
144
|
+
body: body
|
145
|
+
)
|
146
|
+
).to have_been_made
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns the created id' do
|
150
|
+
expect(client.create_signup(body: body)).to eq(2452)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#update_signup' do
|
155
|
+
let(:body) do
|
156
|
+
JSON.parse(File.read(fixture_path + '/update_signup.json'))
|
157
|
+
end
|
158
|
+
|
159
|
+
let(:url) { build_url(client: client, path: 'signups/2452') }
|
160
|
+
|
161
|
+
before do
|
162
|
+
stub_request(:put, url)
|
163
|
+
.with(body: JSON.generate(body))
|
164
|
+
.to_return(
|
165
|
+
body: '',
|
166
|
+
status: 204
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'requests the correct resource' do
|
171
|
+
client.update_signup(id: 2_452, body: body)
|
172
|
+
expect(
|
173
|
+
a_request(:put, url)
|
174
|
+
.with(
|
175
|
+
body: body
|
176
|
+
)
|
177
|
+
).to have_been_made
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'returns an empty response body' do
|
181
|
+
expect(client.update_signup(id: 2_452, body: body)).to eq('')
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#delete_signup' do
|
186
|
+
let(:url) { build_url(client: client, path: 'signups/2452') }
|
187
|
+
|
188
|
+
before do
|
189
|
+
stub_request(:delete, url)
|
190
|
+
.to_return(
|
191
|
+
body: '',
|
192
|
+
status: 204
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'requests the correct resource' do
|
197
|
+
client.delete_signup(id: 2_452)
|
198
|
+
expect(
|
199
|
+
a_request(:delete, url)
|
200
|
+
).to have_been_made
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'returns an empty response body' do
|
204
|
+
expect(client.delete_signup(id: 2_452)).to eq('')
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|