aboutsummaryrefslogtreecommitdiff
path: root/test/web/twitter_api/twitter_api_test.exs
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-04-16 10:25:27 +0200
committerRoger Braun <roger@rogerbraun.net>2017-04-16 10:25:27 +0200
commitb1edd94baa64a18223ae2cc731231ba4314fd0d3 (patch)
treed974d46766e053d7877cca658c7f8284d066f2c7 /test/web/twitter_api/twitter_api_test.exs
parent40706b4c4fe4ae29bf01ef13bc3e79318773d66f (diff)
downloadpleroma-b1edd94baa64a18223ae2cc731231ba4314fd0d3.tar.gz
Add user registration to TwAPI.
Diffstat (limited to 'test/web/twitter_api/twitter_api_test.exs')
-rw-r--r--test/web/twitter_api/twitter_api_test.exs33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index 71b0d8b12..eb5f8ec26 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -3,7 +3,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
alias Pleroma.Builders.{UserBuilder, ActivityBuilder}
alias Pleroma.Web.TwitterAPI.TwitterAPI
alias Pleroma.{Activity, User, Object, Repo}
- alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
+ alias Pleroma.Web.TwitterAPI.Representers.{ActivityRepresenter, UserRepresenter}
alias Pleroma.Web.ActivityPub.ActivityPub
import Pleroma.Factory
@@ -220,6 +220,37 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert status == ActivityRepresenter.to_map(updated_activity, %{user: activity_user, for: user})
end
+ test "it registers a new user and returns the user." do
+ data = %{
+ "nickname" => "lain",
+ "email" => "lain@wired.jp",
+ "fullname" => "lain iwakura",
+ "bio" => "close the world.",
+ "password" => "bear",
+ "confirm" => "bear"
+ }
+
+ {:ok, user} = TwitterAPI.register_user(data)
+
+ fetched_user = Repo.get_by(User, nickname: "lain")
+ assert user == UserRepresenter.to_map(fetched_user)
+ end
+
+ test "it returns the error on registration problems" do
+ data = %{
+ "nickname" => "lain",
+ "email" => "lain@wired.jp",
+ "fullname" => "lain iwakura",
+ "bio" => "close the world.",
+ "password" => "bear"
+ }
+
+ {:error, error_object} = TwitterAPI.register_user(data)
+
+ assert is_binary(error_object[:error])
+ refute Repo.get_by(User, nickname: "lain")
+ end
+
setup do
Supervisor.terminate_child(Pleroma.Supervisor, ConCache)
Supervisor.restart_child(Pleroma.Supervisor, ConCache)