mirror of
https://github.com/status-im/open-bounty.git
synced 2025-01-11 18:14:25 +00:00
Fix first-time sign in issue
* db/create-user! now returns a map with the created data instead of a number, as expected by the client side. * fixed broken test Fixes: #4
This commit is contained in:
parent
60cc76919e
commit
afce955ff3
@ -1,6 +1,6 @@
|
||||
-- Users ---------------------------------------------------------------------------
|
||||
|
||||
-- :name create-user! :! :n
|
||||
-- :name create-user! :<! :1
|
||||
-- :doc creates a new user record
|
||||
INSERT INTO users
|
||||
(id, login, name, email, token, address, created)
|
||||
@ -14,7 +14,8 @@ INSERT INTO users
|
||||
:created
|
||||
WHERE NOT exists(SELECT 1
|
||||
FROM users
|
||||
WHERE id = :id);
|
||||
WHERE id = :id)
|
||||
RETURNING id, login, name, email, token, address, created;
|
||||
|
||||
-- :name update-user! :! :n
|
||||
-- :doc updates an existing user record
|
||||
|
@ -12,26 +12,27 @@
|
||||
(mount/start
|
||||
#'commiteth.config/env
|
||||
#'commiteth.db.core/*db*)
|
||||
(migrations/migrate ["migrate"] (select-keys env [:jdbc-database-url]))
|
||||
(migrations/migrate ["migrate"]
|
||||
{:database-url (env :jdbc-database-url)})
|
||||
(f)))
|
||||
|
||||
(deftest test-users
|
||||
(jdbc/with-db-transaction [t-conn *db*]
|
||||
(jdbc/db-set-rollback-only! t-conn)
|
||||
(is (= 1 (db/create-user!
|
||||
(is (not (nil? (db/create-user!
|
||||
t-conn
|
||||
{:id "1"
|
||||
{:id 1
|
||||
:login "torvalds"
|
||||
:name "Linus Torvalds"
|
||||
:email nil
|
||||
:token "not null"
|
||||
:address "address"
|
||||
:created nil})))
|
||||
(is (= {:id "1"
|
||||
:created nil}))))
|
||||
(is (= {:id 1
|
||||
:login "torvalds"
|
||||
:name "Linus Torvalds"
|
||||
:email nil
|
||||
:token "not null"
|
||||
:address "address"
|
||||
:created nil}
|
||||
(db/get-user t-conn {:login "torvalds"})))))
|
||||
(db/get-user t-conn {:id 1})))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user