From dc03d9202dae2a44af2410d68b2e35d500a8a5ac Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 1 Apr 2016 21:47:36 -0400 Subject: add get_users --- src/guff/api/test.cr | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'src/guff/api') diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr index 448cadf..decc5ec 100644 --- a/src/guff/api/test.cr +++ b/src/guff/api/test.cr @@ -15,45 +15,22 @@ module Guff::API::TestAPI [{foo: "bar"}, {foo: "asdf"}].to_json end - MOCK_USERS = [{ - "id": "0", - "name": "Guest", - "active": true, - }, { - "id": "1", - "name": "Admin", - "active": false, - }, { - "id": "2", - "name": "Test User 1", - "active": false, - }, { - "id": "3", - "name": "Test User 2", - "active": false, - }, { - "id": "4", - "name": "Test User<<<<>>>>>&&&&&&2", - "active": false, - }] - private def do_test_get_users( context : HTTP::Server::Context, args : Hash(String, String) ) - user_id = "0" + # get user_id + user_id = 0_i64 with_session(context) do |session| - user_id = session["user_id"]? || "0" + user_id = (session["user_id"]? || "0").to_i64 false end - # build result - users = MOCK_USERS.map { |row| - row.merge({ "active": (row["id"] == user_id) }) - } + # get users + users = @models.user.get_users # return result - { "users": users } + { "users": users, "user_id": user_id } end private def do_test_set_user( -- cgit v1.2.3