From 9c1cf1befb9905282f6b8afcfee3cf3578f41431 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 12 Jun 2018 15:01:40 +0300 Subject: [PATCH] formatting --- lib/pleroma/web/twitter_api/twitter_api.ex | 11 +++++++---- test/web/twitter_api/twitter_api_test.exs | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 8608ee9ac..ce0da3340 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -143,7 +143,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end cond do - @registrations_open || !is_nil(token) && !token.used -> + @registrations_open || (!is_nil(token) && !token.used) -> changeset = User.register_changeset(%User{}, params) with {:ok, user} <- Repo.insert(changeset) do @@ -155,11 +155,14 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end) |> Jason.encode!() - {:error, %{error: errors}} + {:error, %{error: errors}} end - !@registrations_open && is_nil(token) -> {:error, "Invalid token"} - !@registrations_open && token.used -> {:error, "Expired token"} + !@registrations_open && is_nil(token) -> + {:error, "Invalid token"} + + !@registrations_open && token.used -> + {:error, "Expired token"} end end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ed9158bf5..bdf2f2885 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -266,8 +266,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do token = Repo.get_by(UserInviteToken, token: token.token) assert token.used == true + assert UserView.render("show.json", %{user: user}) == - UserView.render("show.json", %{user: fetched_user}) + UserView.render("show.json", %{user: fetched_user}) end @moduletag skip: "needs 'registrations_open: false' in config" -- 2.45.2