diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-14 02:20:50 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-14 02:20:50 -0400 |
commit | cf90fa002afec60e2c057348de24ca1d8bcbaaa4 (patch) | |
tree | 574b1df80a060a56946f45309956f3d63bbcfabe /src/guff/api | |
parent | e88219d9a4bbc85563a2ead6708641de389af4fa (diff) | |
download | old-guff-cf90fa002afec60e2c057348de24ca1d8bcbaaa4.tar.bz2 old-guff-cf90fa002afec60e2c057348de24ca1d8bcbaaa4.zip |
add test/{get_users,set_user}, js/util.js, lots more
Diffstat (limited to 'src/guff/api')
-rw-r--r-- | src/guff/api/content-type.cr | 2 | ||||
-rw-r--r-- | src/guff/api/methods.cr | 8 | ||||
-rw-r--r-- | src/guff/api/test.cr | 38 |
3 files changed, 47 insertions, 1 deletions
diff --git a/src/guff/api/content-type.cr b/src/guff/api/content-type.cr index 589e6b0..648ee3a 100644 --- a/src/guff/api/content-type.cr +++ b/src/guff/api/content-type.cr @@ -1,6 +1,6 @@ module Guff::API::ContentType CONTENT_TYPES = { - "development": "text/html; charset=utf-8", + "development": "text/json; charset=utf-8", "production": "application/json; charset=utf8", } diff --git a/src/guff/api/methods.cr b/src/guff/api/methods.cr index 9b35596..0247460 100644 --- a/src/guff/api/methods.cr +++ b/src/guff/api/methods.cr @@ -350,6 +350,14 @@ module Guff "error": { text: "Test error response", }, + + "get_users": { + text: "Get mock list of users", + }, + + "set_user": { + text: "Set mock user", + }, } } diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr index 7549c11..44b5e10 100644 --- a/src/guff/api/test.cr +++ b/src/guff/api/test.cr @@ -17,6 +17,44 @@ module Guff [{foo: "bar"}, {foo: "asdf"}].to_json end + MOCK_USERS = { + "users": [{ + "id": "0", + "name": "Guest", + "active": true, + }, { + "id": "1", + "name": "Admin", + "active": false, + }, { + "id": "2", + "name": "Test User 1", + "active": false, + }, { + "id": "2", + "name": "Test User 2", + "active": false, + }, { + "id": "3", + "name": "Test User<<<<>>>>>&&&&&&2", + "active": false, + }] + } + + private def do_test_get_users( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + MOCK_USERS + end + + private def do_test_set_user( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + { ok: true } + end + private def do_test_error( context : HTTP::Server::Context, args : Hash(String, String) |