aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-04-01 21:47:36 -0400
committerPaul Duncan <pabs@pablotron.org>2016-04-01 21:47:36 -0400
commitdc03d9202dae2a44af2410d68b2e35d500a8a5ac (patch)
treecdcd92b58f9f997302c83a7c5c77e1e35de39a3e /src/guff/api
parent0e91a6b3ad2feb7718d6ffdfb06660451f5d064e (diff)
downloadold-guff-dc03d9202dae2a44af2410d68b2e35d500a8a5ac.tar.bz2
old-guff-dc03d9202dae2a44af2410d68b2e35d500a8a5ac.zip
add get_users
Diffstat (limited to 'src/guff/api')
-rw-r--r--src/guff/api/test.cr35
1 files changed, 6 insertions, 29 deletions
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(