From cf90fa002afec60e2c057348de24ca1d8bcbaaa4 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 14 Mar 2016 02:20:50 -0400 Subject: add test/{get_users,set_user}, js/util.js, lots more --- src/guff/api/content-type.cr | 2 +- src/guff/api/methods.cr | 8 ++++++++ src/guff/api/test.cr | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src/guff/api') 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) -- cgit v1.2.3