moodle_rb 1.0.2 → 1.0.3
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/lib/moodle_rb/categories.rb +5 -5
- data/lib/moodle_rb/client.rb +1 -0
- data/lib/moodle_rb/courses.rb +7 -6
- data/lib/moodle_rb/enrolments.rb +2 -5
- data/lib/moodle_rb/grades.rb +4 -10
- data/lib/moodle_rb/users.rb +10 -11
- data/lib/moodle_rb/utility.rb +7 -0
- data/lib/moodle_rb/version.rb +1 -1
- data/spec/cassettes/MoodleRb_Categories/_destroy/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Categories/_destroy/{.yml → when_using_valid_token/.yml} +29 -29
- data/spec/cassettes/MoodleRb_Categories/_index/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Categories/_show/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_destroy/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_destroy/{.yml → when_using_valid_token/.yml} +37 -37
- data/spec/cassettes/MoodleRb_Courses/_destroy/when_using_valid_token/when_using_invalid_course_id/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_enrolled_users/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_enrolled_users/when_using_valid_token/.yml +75 -0
- data/spec/cassettes/MoodleRb_Courses/_index/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_show/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_destroy/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_enrolled_courses/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_search/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_show/when_using_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_update/when_using_invalid_token/.yml +39 -0
- data/spec/lib/moodle_rb/categories_spec.rb +36 -4
- data/spec/lib/moodle_rb/client_spec.rb +4 -2
- data/spec/lib/moodle_rb/courses_spec.rb +70 -13
- data/spec/lib/moodle_rb/users_spec.rb +56 -1
- metadata +36 -10
- data/spec/cassettes/MoodleRb_Courses/_enrolled_users/.yml +0 -75
@@ -0,0 +1,75 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=enrol_manual_enrol_users&wstoken=87b95af2df709fa60b395b5c59a3fc2e
|
7
|
+
body:
|
8
|
+
string: enrolments[0][userid]=3&enrolments[0][courseid]=8&enrolments[0][roleid]=5
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
X-Powered-By:
|
19
|
+
- PHP/5.6.2
|
20
|
+
Pragma:
|
21
|
+
- no-cache
|
22
|
+
Server:
|
23
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
24
|
+
Accept-Ranges:
|
25
|
+
- none
|
26
|
+
Content-Length:
|
27
|
+
- "4"
|
28
|
+
Access-Control-Allow-Origin:
|
29
|
+
- "*"
|
30
|
+
Expires:
|
31
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
32
|
+
Date:
|
33
|
+
- Mon, 20 Jun 2016 22:25:42 GMT
|
34
|
+
Cache-Control:
|
35
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
36
|
+
body:
|
37
|
+
string: "null"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 20 Jun 2016 22:25:42 GMT
|
40
|
+
- request:
|
41
|
+
method: post
|
42
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_enrol_get_enrolled_users&wstoken=87b95af2df709fa60b395b5c59a3fc2e
|
43
|
+
body:
|
44
|
+
string: courseid=8
|
45
|
+
headers: {}
|
46
|
+
|
47
|
+
response:
|
48
|
+
status:
|
49
|
+
code: 200
|
50
|
+
message: OK
|
51
|
+
headers:
|
52
|
+
Content-Type:
|
53
|
+
- application/json
|
54
|
+
X-Powered-By:
|
55
|
+
- PHP/5.6.2
|
56
|
+
Pragma:
|
57
|
+
- no-cache
|
58
|
+
Server:
|
59
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
60
|
+
Accept-Ranges:
|
61
|
+
- none
|
62
|
+
Content-Length:
|
63
|
+
- "4162"
|
64
|
+
Access-Control-Allow-Origin:
|
65
|
+
- "*"
|
66
|
+
Expires:
|
67
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
68
|
+
Date:
|
69
|
+
- Mon, 20 Jun 2016 22:25:42 GMT
|
70
|
+
Cache-Control:
|
71
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
72
|
+
body:
|
73
|
+
string: "[{\"id\":3,\"firstname\":\"- Test\",\"lastname\":\"-\",\"fullname\":\"- Test -\",\"email\":\"test@localhost\",\"firstaccess\":1405378463,\"lastaccess\":1405379119,\"description\":\"\",\"descriptionformat\":1,\"city\":\"Somewhere\",\"country\":\"AU\",\"profileimageurlsmall\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/15\\/user\\/icon\\/f2\",\"profileimageurl\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/15\\/user\\/icon\\/f1\",\"groups\":[],\"roles\":[{\"roleid\":5,\"name\":\"\",\"shortname\":\"student\",\"sortorder\":0}],\"enrolledcourses\":[{\"id\":8,\"fullname\":\"Manage operational plan (BSBMGT515A)\",\"shortname\":\"BSBMGT515A\"}]},{\"id\":14,\"firstname\":\"Test17\",\"lastname\":\"Moodle\",\"fullname\":\"Test17 Moodle\",\"email\":\"samg17@jobready.com.au\",\"firstaccess\":0,\"lastaccess\":0,\"profileimageurlsmall\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/90\\/user\\/icon\\/f2\",\"profileimageurl\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/90\\/user\\/icon\\/f1\",\"groups\":[],\"roles\":[{\"roleid\":5,\"name\":\"\",\"shortname\":\"student\",\"sortorder\":0}],\"enrolledcourses\":[{\"id\":11,\"fullname\":\"Undertake project work (BSBPMG522A)\",\"shortname\":\"BSBPMG522A\"},{\"id\":10,\"fullname\":\"Ensure team effectiveness (BSBWOR502B)\",\"shortname\":\"BSBWOR502B\"},{\"id\":9,\"fullname\":\"Manage risk (BSBRSK501B)\",\"shortname\":\"BSBRSK501B\"},{\"id\":8,\"fullname\":\"Manage operational plan (BSBMGT515A)\",\"shortname\":\"BSBMGT515A\"},{\"id\":7,\"fullname\":\"Manage people performance (BSBMGT502B)\",\"shortname\":\"BSBMGT502B\"},{\"id\":6,\"fullname\":\"Manage budgets and financial plans (BSBFIM501A)\",\"shortname\":\"BSBFIM501A\"},{\"id\":5,\"fullname\":\"Facilitate continuous improvement (BSBMGT516C)\",\"shortname\":\"BSBMGT516C\"},{\"id\":4,\"fullname\":\"Manage personal work priorities and professional development (BSBWOR501B)\",\"shortname\":\"BSBWOR501B\"}]},{\"id\":15,\"firstname\":\"Test18\",\"lastname\":\"Moodle\",\"fullname\":\"Test18 Moodle\",\"email\":\"samg18@jobready.com.au\",\"firstaccess\":0,\"lastaccess\":0,\"profileimageurlsmall\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/91\\/user\\/icon\\/f2\",\"profileimageurl\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/91\\/user\\/icon\\/f1\",\"groups\":[],\"roles\":[{\"roleid\":5,\"name\":\"\",\"shortname\":\"student\",\"sortorder\":0}],\"enrolledcourses\":[{\"id\":12,\"fullname\":\"CHC43015-Sydney\",\"shortname\":\"CHC43015\"},{\"id\":11,\"fullname\":\"Undertake project work (BSBPMG522A)\",\"shortname\":\"BSBPMG522A\"},{\"id\":10,\"fullname\":\"Ensure team effectiveness (BSBWOR502B)\",\"shortname\":\"BSBWOR502B\"},{\"id\":9,\"fullname\":\"Manage risk (BSBRSK501B)\",\"shortname\":\"BSBRSK501B\"},{\"id\":8,\"fullname\":\"Manage operational plan (BSBMGT515A)\",\"shortname\":\"BSBMGT515A\"},{\"id\":7,\"fullname\":\"Manage people performance (BSBMGT502B)\",\"shortname\":\"BSBMGT502B\"},{\"id\":6,\"fullname\":\"Manage budgets and financial plans (BSBFIM501A)\",\"shortname\":\"BSBFIM501A\"},{\"id\":5,\"fullname\":\"Facilitate continuous improvement (BSBMGT516C)\",\"shortname\":\"BSBMGT516C\"},{\"id\":4,\"fullname\":\"Manage personal work priorities and professional development (BSBWOR501B)\",\"shortname\":\"BSBWOR501B\"}]},{\"id\":16,\"firstname\":\"Test19\",\"lastname\":\"Moodle\",\"fullname\":\"Test19 Moodle\",\"email\":\"samg19@jobready.com.au\",\"firstaccess\":0,\"lastaccess\":0,\"profileimageurlsmall\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/92\\/user\\/icon\\/f2\",\"profileimageurl\":\"http:\\/\\/localhost:8888\\/moodle29\\/pluginfile.php\\/92\\/user\\/icon\\/f1\",\"groups\":[],\"roles\":[{\"roleid\":5,\"name\":\"\",\"shortname\":\"student\",\"sortorder\":0}],\"enrolledcourses\":[{\"id\":12,\"fullname\":\"CHC43015-Sydney\",\"shortname\":\"CHC43015\"},{\"id\":11,\"fullname\":\"Undertake project work (BSBPMG522A)\",\"shortname\":\"BSBPMG522A\"},{\"id\":10,\"fullname\":\"Ensure team effectiveness (BSBWOR502B)\",\"shortname\":\"BSBWOR502B\"},{\"id\":9,\"fullname\":\"Manage risk (BSBRSK501B)\",\"shortname\":\"BSBRSK501B\"},{\"id\":8,\"fullname\":\"Manage operational plan (BSBMGT515A)\",\"shortname\":\"BSBMGT515A\"},{\"id\":7,\"fullname\":\"Manage people performance (BSBMGT502B)\",\"shortname\":\"BSBMGT502B\"},{\"id\":6,\"fullname\":\"Manage budgets and financial plans (BSBFIM501A)\",\"shortname\":\"BSBFIM501A\"},{\"id\":5,\"fullname\":\"Facilitate continuous improvement (BSBMGT516C)\",\"shortname\":\"BSBMGT516C\"},{\"id\":4,\"fullname\":\"Manage personal work priorities and professional development (BSBWOR501B)\",\"shortname\":\"BSBWOR501B\"}]}]"
|
74
|
+
http_version:
|
75
|
+
recorded_at: Mon, 20 Jun 2016 22:25:42 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: get
|
6
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_courses&wstoken=
|
7
|
+
body:
|
8
|
+
string: ""
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Date:
|
17
|
+
- Mon, 20 Jun 2016 22:01:55 GMT
|
18
|
+
Content-Length:
|
19
|
+
- "103"
|
20
|
+
Accept-Ranges:
|
21
|
+
- none
|
22
|
+
Server:
|
23
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
24
|
+
Pragma:
|
25
|
+
- no-cache
|
26
|
+
X-Powered-By:
|
27
|
+
- PHP/5.6.2
|
28
|
+
Cache-Control:
|
29
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
30
|
+
Content-Type:
|
31
|
+
- application/json
|
32
|
+
Access-Control-Allow-Origin:
|
33
|
+
- "*"
|
34
|
+
Expires:
|
35
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
36
|
+
body:
|
37
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 20 Jun 2016 22:01:55 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_courses&wstoken=
|
7
|
+
body:
|
8
|
+
string: options[ids][0]=1
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Pragma:
|
17
|
+
- no-cache
|
18
|
+
Accept-Ranges:
|
19
|
+
- none
|
20
|
+
Content-Length:
|
21
|
+
- "103"
|
22
|
+
Access-Control-Allow-Origin:
|
23
|
+
- "*"
|
24
|
+
Date:
|
25
|
+
- Mon, 20 Jun 2016 22:04:25 GMT
|
26
|
+
Expires:
|
27
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
28
|
+
Content-Type:
|
29
|
+
- application/json
|
30
|
+
X-Powered-By:
|
31
|
+
- PHP/5.6.2
|
32
|
+
Server:
|
33
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
34
|
+
Cache-Control:
|
35
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
36
|
+
body:
|
37
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 20 Jun 2016 22:04:25 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_delete_users&wstoken=
|
6
|
+
body:
|
7
|
+
string: userids[0]=-1
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Pragma:
|
16
|
+
- no-cache
|
17
|
+
Date:
|
18
|
+
- Mon, 20 Jun 2016 22:34:35 GMT
|
19
|
+
Content-Length:
|
20
|
+
- "103"
|
21
|
+
Accept-Ranges:
|
22
|
+
- none
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
X-Powered-By:
|
28
|
+
- PHP/5.6.2
|
29
|
+
Expires:
|
30
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
31
|
+
Server:
|
32
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
33
|
+
Cache-Control:
|
34
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
35
|
+
body:
|
36
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Mon, 20 Jun 2016 22:34:35 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_enrol_get_users_courses&wstoken=
|
7
|
+
body:
|
8
|
+
string: userid=3
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Server:
|
17
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
18
|
+
Expires:
|
19
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
20
|
+
Content-Length:
|
21
|
+
- "103"
|
22
|
+
Pragma:
|
23
|
+
- no-cache
|
24
|
+
Cache-Control:
|
25
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
26
|
+
Accept-Ranges:
|
27
|
+
- none
|
28
|
+
Content-Type:
|
29
|
+
- application/json
|
30
|
+
X-Powered-By:
|
31
|
+
- PHP/5.6.2
|
32
|
+
Access-Control-Allow-Origin:
|
33
|
+
- "*"
|
34
|
+
Date:
|
35
|
+
- Mon, 20 Jun 2016 22:37:07 GMT
|
36
|
+
body:
|
37
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 20 Jun 2016 22:37:07 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=
|
6
|
+
body:
|
7
|
+
string: criteria[0][value]=%25&criteria[0][key]=firstname
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Content-Length:
|
16
|
+
- "103"
|
17
|
+
Expires:
|
18
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
19
|
+
Accept-Ranges:
|
20
|
+
- none
|
21
|
+
X-Powered-By:
|
22
|
+
- PHP/5.6.2
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Date:
|
26
|
+
- Mon, 20 Jun 2016 22:38:27 GMT
|
27
|
+
Access-Control-Allow-Origin:
|
28
|
+
- "*"
|
29
|
+
Cache-Control:
|
30
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
31
|
+
Server:
|
32
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
body:
|
36
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Mon, 20 Jun 2016 22:38:27 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=
|
7
|
+
body:
|
8
|
+
string: criteria[0][value]=5&criteria[0][key]=id
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Cache-Control:
|
17
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
18
|
+
Pragma:
|
19
|
+
- no-cache
|
20
|
+
Server:
|
21
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
22
|
+
Accept-Ranges:
|
23
|
+
- none
|
24
|
+
Content-Type:
|
25
|
+
- application/json
|
26
|
+
Date:
|
27
|
+
- Mon, 20 Jun 2016 22:30:45 GMT
|
28
|
+
Expires:
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
30
|
+
Access-Control-Allow-Origin:
|
31
|
+
- "*"
|
32
|
+
Content-Length:
|
33
|
+
- "103"
|
34
|
+
X-Powered-By:
|
35
|
+
- PHP/5.6.2
|
36
|
+
body:
|
37
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Mon, 20 Jun 2016 22:30:45 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle29/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_update_users&wstoken=
|
6
|
+
body:
|
7
|
+
string: users[0][email]=&users[0][id]=4
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
X-Powered-By:
|
16
|
+
- PHP/5.6.2
|
17
|
+
Accept-Ranges:
|
18
|
+
- none
|
19
|
+
Server:
|
20
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
21
|
+
Pragma:
|
22
|
+
- no-cache
|
23
|
+
Content-Type:
|
24
|
+
- application/json
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Expires:
|
28
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
29
|
+
Date:
|
30
|
+
- Mon, 20 Jun 2016 22:39:11 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
33
|
+
Content-Length:
|
34
|
+
- "103"
|
35
|
+
body:
|
36
|
+
string: "{\"exception\":\"moodle_exception\",\"errorcode\":\"invalidtoken\",\"message\":\"Invalid token - token not found\"}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Mon, 20 Jun 2016 22:39:11 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -14,6 +14,16 @@ describe MoodleRb::Categories do
|
|
14
14
|
expect(result).to be_a Array
|
15
15
|
expect(result.first).to have_key 'id'
|
16
16
|
end
|
17
|
+
|
18
|
+
context 'when using invalid token' do
|
19
|
+
let(:token) { '' }
|
20
|
+
specify do
|
21
|
+
expect{ category_moodle_rb.index }.to raise_error(
|
22
|
+
MoodleRb::MoodleError,
|
23
|
+
'Invalid token - token not found'
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
28
|
|
19
29
|
describe '#create', :vcr => {
|
@@ -59,16 +69,38 @@ describe MoodleRb::Categories do
|
|
59
69
|
expect(result).to be_a Hash
|
60
70
|
expect(result['id']).to eq 1
|
61
71
|
end
|
72
|
+
|
73
|
+
context 'when using invalid token' do
|
74
|
+
let(:token) { '' }
|
75
|
+
specify do
|
76
|
+
expect{ category_moodle_rb.show(id) }.to raise_error(
|
77
|
+
MoodleRb::MoodleError,
|
78
|
+
'Invalid token - token not found'
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
62
82
|
end
|
63
83
|
|
64
84
|
describe '#destroy', :vcr => {
|
65
85
|
:match_requests_on => [:headers], :record => :once
|
66
86
|
} do
|
67
|
-
|
68
|
-
|
87
|
+
context 'when using valid token' do
|
88
|
+
let!(:id) { category_moodle_rb.create(:name => '_')['id'] }
|
89
|
+
let(:result) { category_moodle_rb.destroy(id) }
|
69
90
|
|
70
|
-
|
71
|
-
|
91
|
+
specify do
|
92
|
+
expect(result).to eq true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when using invalid token' do
|
97
|
+
let(:token) { '' }
|
98
|
+
specify do
|
99
|
+
expect{ category_moodle_rb.destroy(0) }.to raise_error(
|
100
|
+
MoodleRb::MoodleError,
|
101
|
+
'Invalid token - token not found'
|
102
|
+
)
|
103
|
+
end
|
72
104
|
end
|
73
105
|
end
|
74
106
|
end
|
@@ -14,8 +14,10 @@ describe MoodleRb::Client do
|
|
14
14
|
let(:token) { 'invalid_moodle_rb_token' }
|
15
15
|
|
16
16
|
specify do
|
17
|
-
expect
|
18
|
-
|
17
|
+
expect{ result }.to raise_error(
|
18
|
+
MoodleRb::MoodleError,
|
19
|
+
'Invalid token - token not found'
|
20
|
+
)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -22,6 +22,16 @@ describe MoodleRb::Courses do
|
|
22
22
|
expect(result).to be_a Array
|
23
23
|
expect(result.first).to have_key 'id'
|
24
24
|
end
|
25
|
+
|
26
|
+
context 'when using invalid token' do
|
27
|
+
let(:token) { '' }
|
28
|
+
specify do
|
29
|
+
expect{ course_moodle_rb.index }.to raise_error(
|
30
|
+
MoodleRb::MoodleError,
|
31
|
+
'Invalid token - token not found'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
37
|
describe '#create', :vcr => {
|
@@ -59,16 +69,50 @@ describe MoodleRb::Courses do
|
|
59
69
|
expect(result).to be_a Hash
|
60
70
|
expect(result['id']).to eq 1
|
61
71
|
end
|
72
|
+
|
73
|
+
context 'when using invalid token' do
|
74
|
+
let(:token) { '' }
|
75
|
+
specify do
|
76
|
+
expect{ course_moodle_rb.show(id) }.to raise_error(
|
77
|
+
MoodleRb::MoodleError,
|
78
|
+
'Invalid token - token not found'
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
62
82
|
end
|
63
83
|
|
64
84
|
describe '#destroy', :vcr => {
|
65
85
|
:match_requests_on => [:headers], :record => :once
|
66
86
|
} do
|
67
|
-
|
68
|
-
|
87
|
+
context 'when using valid token' do
|
88
|
+
let(:id) { course_moodle_rb.create(params)['id'] }
|
89
|
+
let(:result) { course_moodle_rb.destroy(id) }
|
69
90
|
|
70
|
-
|
71
|
-
|
91
|
+
specify do
|
92
|
+
expect(result).to be_a Hash
|
93
|
+
expect(result['warnings']).to be_a Array
|
94
|
+
expect(result['warnings']).to be_empty
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when using invalid course id' do
|
98
|
+
let(:result) { course_moodle_rb.destroy(-1) }
|
99
|
+
|
100
|
+
specify do
|
101
|
+
expect(result).to be_a Hash
|
102
|
+
expect(result['warnings']).to be_a Array
|
103
|
+
expect(result['warnings'][0]['warningcode']).to eq 'unknowncourseidnumber'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when using invalid token' do
|
109
|
+
let(:token) { '' }
|
110
|
+
specify do
|
111
|
+
expect{ course_moodle_rb.destroy(-1) }.to raise_error(
|
112
|
+
MoodleRb::MoodleError,
|
113
|
+
'Invalid token - token not found'
|
114
|
+
)
|
115
|
+
end
|
72
116
|
end
|
73
117
|
end
|
74
118
|
|
@@ -76,17 +120,30 @@ describe MoodleRb::Courses do
|
|
76
120
|
:match_requests_on => [:headers], :record => :once
|
77
121
|
} do
|
78
122
|
let(:course_id) { 8 }
|
79
|
-
|
80
|
-
|
81
|
-
|
123
|
+
|
124
|
+
context 'when using valid token' do
|
125
|
+
let!(:enrolled_user) do
|
126
|
+
MoodleRb.new(token, url).enrolments.create(
|
127
|
+
:user_id => 3, :course_id => course_id)
|
128
|
+
end
|
129
|
+
let(:result) { course_moodle_rb.enrolled_users(course_id) }
|
130
|
+
let(:enrolment) { result.first }
|
131
|
+
|
132
|
+
specify do
|
133
|
+
expect(result).to be_a Array
|
134
|
+
expect(enrolment).to have_key 'id'
|
135
|
+
expect(enrolment).to have_key 'enrolledcourses'
|
136
|
+
end
|
82
137
|
end
|
83
|
-
let(:result) { course_moodle_rb.enrolled_users(course_id) }
|
84
|
-
let(:enrolment) { result.first }
|
85
138
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
139
|
+
context 'when using invalid token' do
|
140
|
+
let(:token) { '' }
|
141
|
+
specify do
|
142
|
+
expect{ course_moodle_rb.enrolled_users(course_id) }.to raise_error(
|
143
|
+
MoodleRb::MoodleError,
|
144
|
+
'Invalid token - token not found'
|
145
|
+
)
|
146
|
+
end
|
90
147
|
end
|
91
148
|
end
|
92
149
|
end
|
@@ -52,6 +52,16 @@ describe MoodleRb::Users do
|
|
52
52
|
expect(result).to be_a Hash
|
53
53
|
expect(result['id']).to eq 5
|
54
54
|
end
|
55
|
+
|
56
|
+
context 'when using invalid token' do
|
57
|
+
let(:token) { '' }
|
58
|
+
specify do
|
59
|
+
expect{ user_moodle_rb.show(id) }.to raise_error(
|
60
|
+
MoodleRb::MoodleError,
|
61
|
+
'Invalid token - token not found'
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
55
65
|
end
|
56
66
|
|
57
67
|
describe '#destroy', :vcr => {
|
@@ -67,7 +77,20 @@ describe MoodleRb::Users do
|
|
67
77
|
context 'when id does not exist' do
|
68
78
|
let(:id) { 999 }
|
69
79
|
specify do
|
70
|
-
expect
|
80
|
+
expect{ result }.to raise_error(
|
81
|
+
MoodleRb::MoodleError,
|
82
|
+
'Invalid user'
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when using invalid token' do
|
88
|
+
let(:token) { '' }
|
89
|
+
specify do
|
90
|
+
expect{ user_moodle_rb.destroy(-1) }.to raise_error(
|
91
|
+
MoodleRb::MoodleError,
|
92
|
+
'Invalid token - token not found'
|
93
|
+
)
|
71
94
|
end
|
72
95
|
end
|
73
96
|
end
|
@@ -83,6 +106,16 @@ describe MoodleRb::Users do
|
|
83
106
|
expect(result).to be_a Array
|
84
107
|
expect(enrolment).to have_key 'shortname'
|
85
108
|
end
|
109
|
+
|
110
|
+
context 'when using invalid token' do
|
111
|
+
let(:token) { '' }
|
112
|
+
specify do
|
113
|
+
expect{ user_moodle_rb.enrolled_courses(user_id) }.to raise_error(
|
114
|
+
MoodleRb::MoodleError,
|
115
|
+
'Invalid token - token not found'
|
116
|
+
)
|
117
|
+
end
|
118
|
+
end
|
86
119
|
end
|
87
120
|
|
88
121
|
describe '#search', :vcr => {
|
@@ -95,6 +128,16 @@ describe MoodleRb::Users do
|
|
95
128
|
expect(results.first).to be_a Hash
|
96
129
|
expect(results.first['firstname']).to eq 'Guest user'
|
97
130
|
end
|
131
|
+
|
132
|
+
context 'when using invalid token' do
|
133
|
+
let(:token) { '' }
|
134
|
+
specify do
|
135
|
+
expect{ user_moodle_rb.search({ :firstname => '%' }) }.to raise_error(
|
136
|
+
MoodleRb::MoodleError,
|
137
|
+
'Invalid token - token not found'
|
138
|
+
)
|
139
|
+
end
|
140
|
+
end
|
98
141
|
end
|
99
142
|
|
100
143
|
describe '#update', :vcr => {
|
@@ -108,5 +151,17 @@ describe MoodleRb::Users do
|
|
108
151
|
specify do
|
109
152
|
expect(result).to eq true
|
110
153
|
end
|
154
|
+
|
155
|
+
context 'when using invalid token' do
|
156
|
+
let(:token) { '' }
|
157
|
+
specify do
|
158
|
+
expect do
|
159
|
+
user_moodle_rb.update(:id => user_id, :email => '')
|
160
|
+
end.to raise_error(
|
161
|
+
MoodleRb::MoodleError,
|
162
|
+
'Invalid token - token not found'
|
163
|
+
)
|
164
|
+
end
|
165
|
+
end
|
111
166
|
end
|
112
167
|
end
|