pandarus 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/pandarus/api_base.rb +9 -3
- data/lib/pandarus/remote_collection.rb +74 -0
- data/lib/pandarus/v1_api.rb +961 -2088
- data/lib/pandarus/version.rb +1 -1
- data/pandarus.gemspec +3 -2
- data/spec/api_base_spec.rb +4 -5
- data/spec/client_spec.rb +2 -16
- data/spec/fixtures/vcr_cassettes/remote_collection_all_pages.yml +211 -0
- data/spec/fixtures/vcr_cassettes/remote_collection_first_page.yml +69 -0
- data/spec/lib/pandarus/remote_collection_spec.rb +57 -0
- data/spec/model_base_spec.rb +18 -16
- data/spec/sis_import_spec.rb +4 -4
- data/spec/spec_helper.rb +24 -1
- data/spec/support/vcr.rb +10 -0
- data/spec/user_spec.rb +5 -5
- metadata +55 -53
data/lib/pandarus/version.rb
CHANGED
data/pandarus.gemspec
CHANGED
@@ -21,11 +21,12 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.add_development_dependency "rake"
|
23
23
|
gem.add_development_dependency "bundler", ">= 1.0.0"
|
24
|
-
gem.add_development_dependency "rspec", "~>
|
24
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
gem.add_development_dependency "webmock"
|
26
|
+
gem.add_development_dependency "vcr"
|
26
27
|
gem.add_development_dependency "pry"
|
27
28
|
|
28
|
-
gem.add_dependency "footrest",
|
29
|
+
gem.add_dependency "footrest", '~> 0.5.0'
|
29
30
|
gem.add_dependency "activesupport", ">= 3.0.0"
|
30
31
|
gem.add_dependency "virtus", ">= 1.0.3"
|
31
32
|
gem.add_dependency "inflecto", ">= 0.0.2"
|
data/spec/api_base_spec.rb
CHANGED
@@ -10,16 +10,15 @@ describe Pandarus::APIBase do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "converts surrounding double underscores" do
|
13
|
-
u2sb("prefix__inside__").
|
13
|
+
expect(u2sb("prefix__inside__")).to eq :"prefix[inside]"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "ignores single underscores" do
|
17
|
-
u2sb("prefix__inner_word__").
|
17
|
+
expect(u2sb("prefix__inner_word__")).to eq :"prefix[inner_word]"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "converts multiple double underscores" do
|
21
|
-
u2sb("prefix__alpha____beta_gamma__").
|
22
|
-
:"prefix[alpha][beta_gamma]"
|
21
|
+
expect(u2sb("prefix__alpha____beta_gamma__")).to eq :"prefix[alpha][beta_gamma]"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -93,4 +92,4 @@ describe Pandarus::APIBase do
|
|
93
92
|
end
|
94
93
|
|
95
94
|
end
|
96
|
-
end
|
95
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -11,21 +11,7 @@ describe Pandarus::Client do
|
|
11
11
|
let(:opts) { { :prefix => prefix, :token => token } }
|
12
12
|
|
13
13
|
it "raises when args are too few" do
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not raise when args are correct" do
|
18
|
-
stub_json_request("http://localhost:3000/api/v1/accounts/1/admins", "[]")
|
19
|
-
lambda { client.list_account_admins(1) }.should_not raise_error
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with overridden params" do
|
24
|
-
let(:opts) { { :account_id => 1, :prefix => prefix, :token => token } }
|
25
|
-
|
26
|
-
it "uses overridden param account_id" do
|
27
|
-
stub_json_request("http://localhost:3000/api/v1/accounts/1/admins", "[]")
|
28
|
-
lambda { client.list_account_admins }.should_not raise_error
|
14
|
+
expect { client.list_account_admins }.to raise_error
|
29
15
|
end
|
30
16
|
end
|
31
17
|
|
@@ -39,4 +25,4 @@ describe Pandarus::Client do
|
|
39
25
|
}
|
40
26
|
)
|
41
27
|
end
|
42
|
-
end
|
28
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Authorization:
|
13
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
14
|
+
User-Agent:
|
15
|
+
- Footrest
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
X-Canvas-User-Id:
|
24
|
+
- '10000000000001'
|
25
|
+
Link:
|
26
|
+
- <http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=10>;
|
27
|
+
rel="current",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=10>;
|
28
|
+
rel="next",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=10>;
|
29
|
+
rel="first",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10>;
|
30
|
+
rel="last"
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
Content-Type:
|
34
|
+
- application/json; charset=utf-8
|
35
|
+
X-Ua-Compatible:
|
36
|
+
- IE=Edge
|
37
|
+
Etag:
|
38
|
+
- '"d8494ce40b4b8be8addbb736bfd1c333"'
|
39
|
+
Cache-Control:
|
40
|
+
- must-revalidate, private, max-age=0
|
41
|
+
Set-Cookie:
|
42
|
+
- _csrf_token=HmhMEGEdhhvRVlnYZLXTwyIGYGjuWeQ68xUPSiAd5vt6GQdXBUXDLL0jOIkGgrqzWEhZKaQTnF3CVFolV0mTzg%3D%3D;
|
43
|
+
path=/
|
44
|
+
- _normandy_session=cP7mYMVZ0cCgO7RmBD_99w.5oUsKA4C4mkJk-l49huIqeHphIh-b8Gq1yRT8B9cvpBCTSTSGbICDIbmnIKlZX_Y76DZTEfDSLeyzDuyzECfmLPXW86Z22X6rmTroYwMeAt5ym_3khrSJGefEypDw6Hd.fKoO7AdPLd-swV8VPxGDeHz_SBg.VJLvJg;
|
45
|
+
path=/; HttpOnly
|
46
|
+
X-Session-Id:
|
47
|
+
- ac19512a3ac594145f0b4c21095275e6
|
48
|
+
X-Request-Context-Id:
|
49
|
+
- 6079e1c0-68f6-0132-4d7c-38e85630c82a
|
50
|
+
X-Canvas-Meta:
|
51
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=328036;m=328036;u=0.22;y=0.02;d=0.01;
|
52
|
+
X-Runtime:
|
53
|
+
- '0.261794'
|
54
|
+
Date:
|
55
|
+
- Thu, 18 Dec 2014 15:13:42 GMT
|
56
|
+
X-Rack-Cache:
|
57
|
+
- miss
|
58
|
+
Connection:
|
59
|
+
- close
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '[{"id":154,"name":"Brandon Adams","sortable_name":"Adams, Brandon","short_name":"Brandon
|
63
|
+
Adams","sis_user_id":"student_4471","integration_id":null,"sis_login_id":"westudent1","sis_import_id":4,"login_id":"westudent1"},{"id":126,"name":"Barry
|
64
|
+
Blankenship","sortable_name":"Blankenship, Barry","short_name":"Barry Blankenship","sis_user_id":"student_4443","integration_id":null,"sis_login_id":"westudent38","sis_import_id":4,"login_id":"westudent38"},{"id":109,"name":"Rachel
|
65
|
+
Brown","sortable_name":"Brown, Rachel","short_name":"Rachel Brown","sis_user_id":"student_4426","integration_id":null,"sis_login_id":"westudent63","sis_import_id":4,"login_id":"westudent63"},{"id":130,"name":"Riley
|
66
|
+
Brown","sortable_name":"Brown, Riley","short_name":"Riley Brown","sis_user_id":"student_4447","integration_id":null,"sis_login_id":"westudent64","sis_import_id":4,"login_id":"westudent64"},{"id":475,"name":"James
|
67
|
+
Dandy","sortable_name":"Dandy, James","short_name":"James Dandy","sis_user_id":"student_17972","integration_id":null,"sis_login_id":"0de2754a2a2caccc","sis_import_id":4,"login_id":"0de2754a2a2caccc"},{"id":110,"name":"Julie
|
68
|
+
Davis","sortable_name":"Davis, Julie","short_name":"Julie Davis","sis_user_id":"student_4427","integration_id":null,"sis_login_id":"westudent95","sis_import_id":4,"login_id":"westudent95"},{"id":105,"name":"Amber
|
69
|
+
Gray","sortable_name":"Gray, Amber","short_name":"Amber Gray","sis_user_id":"student_4422","integration_id":null,"sis_login_id":"48f6dd84e760c710","sis_import_id":4,"login_id":"48f6dd84e760c710"},{"id":119,"name":"Anthony
|
70
|
+
Gustin","sortable_name":"Gustin, Anthony","short_name":"Anthony Gustin","sis_user_id":"student_4436","integration_id":null,"sis_login_id":"westudent166","sis_import_id":4,"login_id":"westudent166"},{"id":142,"name":"Jonathan
|
71
|
+
Holland","sortable_name":"Holland, Jonathan","short_name":"Jonathan Holland","sis_user_id":"student_4459","integration_id":null,"sis_login_id":"westudent215","sis_import_id":4,"login_id":"westudent215"},{"id":91,"name":"Corey
|
72
|
+
Kelly","sortable_name":"Kelly, Corey","short_name":"Corey Kelly","sis_user_id":"student_4408","integration_id":null,"sis_login_id":"westudent259","sis_import_id":4,"login_id":"westudent259"}]'
|
73
|
+
http_version:
|
74
|
+
recorded_at: Thu, 18 Dec 2014 15:13:42 GMT
|
75
|
+
- request:
|
76
|
+
method: get
|
77
|
+
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=10
|
78
|
+
body:
|
79
|
+
encoding: US-ASCII
|
80
|
+
string: ''
|
81
|
+
headers:
|
82
|
+
Accept:
|
83
|
+
- application/json
|
84
|
+
Authorization:
|
85
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
86
|
+
User-Agent:
|
87
|
+
- Footrest
|
88
|
+
Accept-Encoding:
|
89
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
90
|
+
response:
|
91
|
+
status:
|
92
|
+
code: 200
|
93
|
+
message: OK
|
94
|
+
headers:
|
95
|
+
X-Canvas-User-Id:
|
96
|
+
- '10000000000001'
|
97
|
+
Link:
|
98
|
+
- <http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=10>;
|
99
|
+
rel="current",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10>;
|
100
|
+
rel="next",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=10>;
|
101
|
+
rel="prev",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=10>;
|
102
|
+
rel="first",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10>;
|
103
|
+
rel="last"
|
104
|
+
X-Frame-Options:
|
105
|
+
- SAMEORIGIN
|
106
|
+
Content-Type:
|
107
|
+
- application/json; charset=utf-8
|
108
|
+
X-Ua-Compatible:
|
109
|
+
- IE=Edge
|
110
|
+
Etag:
|
111
|
+
- '"75c1a350d18501f6912e575a6bbc53c1"'
|
112
|
+
Cache-Control:
|
113
|
+
- must-revalidate, private, max-age=0
|
114
|
+
Set-Cookie:
|
115
|
+
- _csrf_token=EKCSPyXN2cjUagWmSyxnJaxR8U8sEwoH%2BOK%2BsSftt2ldytoOR4iA464kSZcqS18X32KgFm84PlPPluvGcNWYMw%3D%3D;
|
116
|
+
path=/
|
117
|
+
- _normandy_session=H9dHgxOeRFp2LKwSrTNzIQ.I42HWwvEwVQ5buNUmA5dvXpAQ5ZVRmlJY3nR57DrpIwxt7DhfRP3lqo99GPyQBz_ZAkKHBQm2CSzGpIsUl7-9wpmgWa4rH-c-eZZf7rIp4gZuviyFtISh8ialNkhn7ZU.P4ihNStsDB5-nXi_LTU-7jxG30c.VJLvJw;
|
118
|
+
path=/; HttpOnly
|
119
|
+
X-Session-Id:
|
120
|
+
- bdc07fdf3be919cbe7499e043e699c6e
|
121
|
+
X-Request-Context-Id:
|
122
|
+
- 60a38680-68f6-0132-4d7c-38e85630c82a
|
123
|
+
X-Canvas-Meta:
|
124
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=328036;m=329924;u=0.43;y=0.02;d=0.01;
|
125
|
+
X-Runtime:
|
126
|
+
- '0.482755'
|
127
|
+
Date:
|
128
|
+
- Thu, 18 Dec 2014 15:13:43 GMT
|
129
|
+
X-Rack-Cache:
|
130
|
+
- miss
|
131
|
+
Connection:
|
132
|
+
- close
|
133
|
+
body:
|
134
|
+
encoding: UTF-8
|
135
|
+
string: '[{"id":77,"name":"Rachelle Kemink","sortable_name":"Kemink, Rachelle","short_name":"Rachelle
|
136
|
+
Kemink","sis_user_id":"student_4394","integration_id":null,"sis_login_id":"40dfec16918a9989","sis_import_id":4,"login_id":"40dfec16918a9989"},{"id":102,"name":"Jacob
|
137
|
+
Lock","sortable_name":"Lock, Jacob","short_name":"Jacob Lock","sis_user_id":"student_4419","integration_id":null,"sis_login_id":"westudent293","sis_import_id":4,"login_id":"westudent293"},{"id":124,"name":"Patti,K.
|
138
|
+
Mccoy","sortable_name":"Mccoy, Patti,K.","short_name":"Patti,K. Mccoy","sis_user_id":"student_4441","integration_id":null,"sis_login_id":"westudent317","sis_import_id":4,"login_id":"westudent317"},{"id":114,"name":"Alyssa
|
139
|
+
Miasnik","sortable_name":"Miasnik, Alyssa","short_name":"Alyssa Miasnik","sis_user_id":"student_4431","integration_id":null,"sis_login_id":"westudent323","sis_import_id":4,"login_id":"westudent323"},{"id":144,"name":"Carlos
|
140
|
+
Nielsen","sortable_name":"Nielsen, Carlos","short_name":"Carlos Nielsen","sis_user_id":"student_4461","integration_id":null,"sis_login_id":"westudent360","sis_import_id":4,"login_id":"westudent360"},{"id":84,"name":"Matthew
|
141
|
+
Ponchai","sortable_name":"Ponchai, Matthew","short_name":"Matthew Ponchai","sis_user_id":"student_4401","integration_id":null,"sis_login_id":"westudent398","sis_import_id":4,"login_id":"westudent398"},{"id":81,"name":"Tom
|
142
|
+
Riley","sortable_name":"Riley, Tom","short_name":"Tom Riley","sis_user_id":"student_4398","integration_id":null,"sis_login_id":"westudent417","sis_import_id":4,"login_id":"westudent417"},{"id":118,"name":"Frank
|
143
|
+
Segura","sortable_name":"Segura, Frank","short_name":"Frank Segura","sis_user_id":"student_4435","integration_id":null,"sis_login_id":"westudent438","sis_import_id":4,"login_id":"westudent438"},{"id":125,"name":"Stephenson
|
144
|
+
Watts","sortable_name":"Watts, Stephenson","short_name":"Stephenson Watts","sis_user_id":"student_4442","integration_id":null,"sis_login_id":"westudent496","sis_import_id":4,"login_id":"westudent496"},{"id":115,"name":"Britney
|
145
|
+
Whittle","sortable_name":"Whittle, Britney","short_name":"Britney Whittle","sis_user_id":"student_4432","integration_id":null,"sis_login_id":"westudent504","sis_import_id":4,"login_id":"westudent504"}]'
|
146
|
+
http_version:
|
147
|
+
recorded_at: Thu, 18 Dec 2014 15:13:43 GMT
|
148
|
+
- request:
|
149
|
+
method: get
|
150
|
+
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10
|
151
|
+
body:
|
152
|
+
encoding: US-ASCII
|
153
|
+
string: ''
|
154
|
+
headers:
|
155
|
+
Accept:
|
156
|
+
- application/json
|
157
|
+
Authorization:
|
158
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
159
|
+
User-Agent:
|
160
|
+
- Footrest
|
161
|
+
Accept-Encoding:
|
162
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
163
|
+
response:
|
164
|
+
status:
|
165
|
+
code: 200
|
166
|
+
message: OK
|
167
|
+
headers:
|
168
|
+
X-Canvas-User-Id:
|
169
|
+
- '10000000000001'
|
170
|
+
Link:
|
171
|
+
- <http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10>;
|
172
|
+
rel="current",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=10>;
|
173
|
+
rel="prev",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=10>;
|
174
|
+
rel="first",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=3&per_page=10>;
|
175
|
+
rel="last"
|
176
|
+
X-Frame-Options:
|
177
|
+
- SAMEORIGIN
|
178
|
+
Content-Type:
|
179
|
+
- application/json; charset=utf-8
|
180
|
+
X-Ua-Compatible:
|
181
|
+
- IE=Edge
|
182
|
+
Etag:
|
183
|
+
- '"fdcf93820992101b1ec6375b7d9ed8bd"'
|
184
|
+
Cache-Control:
|
185
|
+
- must-revalidate, private, max-age=0
|
186
|
+
Set-Cookie:
|
187
|
+
- _csrf_token=euTKz%2FVNURj4NjFMmxl9Cj7GbrsS%2FmZIkaZGH3aHqbUyqJy1hg4oXZluexneaRBLV55ByErLSWPo%2FjNNIvXsgw%3D%3D;
|
188
|
+
path=/
|
189
|
+
- _normandy_session=4H57XVZatJMTTHBTSz0XXg.KJo0W_Gnid9O7o93o7D0B0JXYKU_0DYjX3p5F9mu-e4jYDfeb6xGLjDIgeNmOgsH3RfmC93cFnqnoWl_VNS0F_LwZM6rgmtqWmyXSZYD2G-4Zyi1tL7FP95RBddu6MnT.8pSpRuwegl1mhR3wIZjeSFWPIzs.VJLvJw;
|
190
|
+
path=/; HttpOnly
|
191
|
+
X-Session-Id:
|
192
|
+
- 62e9e75f213e4a7d5cc91786fea42c90
|
193
|
+
X-Request-Context-Id:
|
194
|
+
- 60ef8850-68f6-0132-4d7c-38e85630c82a
|
195
|
+
X-Canvas-Meta:
|
196
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=329924;m=329968;u=0.20;y=0.02;d=0.01;
|
197
|
+
X-Runtime:
|
198
|
+
- '0.237708'
|
199
|
+
Date:
|
200
|
+
- Thu, 18 Dec 2014 15:13:43 GMT
|
201
|
+
X-Rack-Cache:
|
202
|
+
- miss
|
203
|
+
Connection:
|
204
|
+
- close
|
205
|
+
body:
|
206
|
+
encoding: UTF-8
|
207
|
+
string: '[{"id":108,"name":"Jessy Young","sortable_name":"Young, Jessy","short_name":"Jessy
|
208
|
+
Young","sis_user_id":"student_4425","integration_id":null,"sis_login_id":"westudent520","sis_import_id":4,"login_id":"westudent520"}]'
|
209
|
+
http_version:
|
210
|
+
recorded_at: Thu, 18 Dec 2014 15:13:43 GMT
|
211
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&per_page=4
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Authorization:
|
13
|
+
- Bearer Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX
|
14
|
+
User-Agent:
|
15
|
+
- Footrest
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
X-Canvas-User-Id:
|
24
|
+
- '10000000000001'
|
25
|
+
Link:
|
26
|
+
- <http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=4>;
|
27
|
+
rel="current",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=2&per_page=4>;
|
28
|
+
rel="next",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=1&per_page=4>;
|
29
|
+
rel="first",<http://shard1.canvas.dev/api/v1/courses/14/users?enrollment_type=student&page=6&per_page=4>;
|
30
|
+
rel="last"
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
Content-Type:
|
34
|
+
- application/json; charset=utf-8
|
35
|
+
X-Ua-Compatible:
|
36
|
+
- IE=Edge
|
37
|
+
Etag:
|
38
|
+
- '"4a4e3f62b00b4b6aff8936702c1cb2d8"'
|
39
|
+
Cache-Control:
|
40
|
+
- must-revalidate, private, max-age=0
|
41
|
+
Set-Cookie:
|
42
|
+
- _csrf_token=%2BD8NttV7evZgJBGpwIu2Op7orFDLkb6CdirKkZvZb4G8SX3jpD4zjjlGfsCJzuxX2bD4A63ii%2B0ubLjw9bslsw%3D%3D;
|
43
|
+
path=/
|
44
|
+
- _normandy_session=mxm4xsQUFwSJwPzOvD0PmQ.YyTzeKM2EWKw_POuu05sotuV3B5rGX66WxMgjG_4A_aJVvOiOOY6xvUYCCf4uoseJ78j7NqpOZzKLBXEgx0I7LG1tOUJdje8Y6tT7rXozQH6DagzE_MPxhwpYdcbrftU.KrBLNNsZg2h8z3H0KDtrRf3DZTA.VJLvJw;
|
45
|
+
path=/; HttpOnly
|
46
|
+
X-Session-Id:
|
47
|
+
- 5b59731950aae9f1f06f6247662ff3c3
|
48
|
+
X-Request-Context-Id:
|
49
|
+
- 6116df30-68f6-0132-4d7c-38e85630c82a
|
50
|
+
X-Canvas-Meta:
|
51
|
+
- a=1;g=DtbEcIgsiKSxJvSoQKH05C46ONAcwvepb4BEBYAz;s=2;c=development;b=329968;m=330416;u=0.20;y=0.01;d=0.00;
|
52
|
+
X-Runtime:
|
53
|
+
- '0.237391'
|
54
|
+
Date:
|
55
|
+
- Thu, 18 Dec 2014 15:13:43 GMT
|
56
|
+
X-Rack-Cache:
|
57
|
+
- miss
|
58
|
+
Connection:
|
59
|
+
- close
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '[{"id":154,"name":"Brandon Adams","sortable_name":"Adams, Brandon","short_name":"Brandon
|
63
|
+
Adams","sis_user_id":"student_4471","integration_id":null,"sis_login_id":"westudent1","sis_import_id":4,"login_id":"westudent1"},{"id":126,"name":"Barry
|
64
|
+
Blankenship","sortable_name":"Blankenship, Barry","short_name":"Barry Blankenship","sis_user_id":"student_4443","integration_id":null,"sis_login_id":"westudent38","sis_import_id":4,"login_id":"westudent38"},{"id":109,"name":"Rachel
|
65
|
+
Brown","sortable_name":"Brown, Rachel","short_name":"Rachel Brown","sis_user_id":"student_4426","integration_id":null,"sis_login_id":"westudent63","sis_import_id":4,"login_id":"westudent63"},{"id":130,"name":"Riley
|
66
|
+
Brown","sortable_name":"Brown, Riley","short_name":"Riley Brown","sis_user_id":"student_4447","integration_id":null,"sis_login_id":"westudent64","sis_import_id":4,"login_id":"westudent64"}]'
|
67
|
+
http_version:
|
68
|
+
recorded_at: Thu, 18 Dec 2014 15:13:43 GMT
|
69
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Pandarus
|
4
|
+
describe RemoteCollection do
|
5
|
+
let(:footrest) {
|
6
|
+
Footrest::Client.new({
|
7
|
+
prefix: 'http://shard1.canvas.dev/api',
|
8
|
+
token: "Bearer 1~A5dY8IsOyhVOVRJi4V3XWGNsa7pzuIbdM8OCv62YTRFqOsiS9vX0NbtY8PR9q4pX",
|
9
|
+
})
|
10
|
+
}
|
11
|
+
let(:client) {
|
12
|
+
footrest.connection
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:path) { '/v1/courses/14/users' }
|
16
|
+
let(:query_params) {
|
17
|
+
{
|
18
|
+
enrollment_type: 'student',
|
19
|
+
}
|
20
|
+
}
|
21
|
+
let(:collection) {
|
22
|
+
RemoteCollection.new(client, User, path, query_params)
|
23
|
+
}
|
24
|
+
|
25
|
+
describe '#first_page' do
|
26
|
+
let(:page) {
|
27
|
+
VCR.use_cassette('remote_collection_first_page') do
|
28
|
+
collection.first_page
|
29
|
+
end
|
30
|
+
}
|
31
|
+
|
32
|
+
before do
|
33
|
+
query_params[:per_page] = 4
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'must use the supplied query params' do
|
37
|
+
expect(page.size).to eq 4
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'must fetch the first page' do
|
41
|
+
expect(page.all?{|member| User === member}).to be_truthy
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#to_a' do
|
46
|
+
let(:array) {
|
47
|
+
VCR.use_cassette('remote_collection_all_pages') do
|
48
|
+
collection.to_a
|
49
|
+
end
|
50
|
+
}
|
51
|
+
|
52
|
+
it 'must fetch all pages and combine them into a single array' do
|
53
|
+
expect(array.size).to eq 21
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/model_base_spec.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
require 'pandarus'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
describe Pandarus::ModelBase do
|
5
|
+
let(:klass) {
|
6
|
+
Class.new(Pandarus::ModelBase) do
|
7
|
+
include Virtus.model
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
9
|
+
attribute :id, resolve_type("Integer")
|
10
|
+
attribute :name, resolve_type("String")
|
11
|
+
end
|
12
|
+
}
|
10
13
|
|
11
|
-
describe
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
describe '#initialize' do
|
15
|
+
it "works" do
|
16
|
+
tm = klass.new(:id => 1, :name => "test")
|
17
|
+
expect(tm.id).to eq 1
|
18
|
+
expect(tm.name).to eq "test"
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end.should_not raise_error
|
21
|
+
it 'must not raise an exception when supplied attributes not in the attribute list' do
|
22
|
+
klass.new({foo: 'bar', id: 32})
|
23
|
+
end
|
22
24
|
end
|
23
|
-
end
|
25
|
+
end
|