-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
163 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ defmodule Recognizer.AccountsTest do | |
|
||
import Mox | ||
import Recognizer.AccountFactory | ||
import Recognizer.BigCommerceTestHelpers | ||
|
||
alias Recognizer.Accounts | ||
alias Recognizer.Accounts.BCCustomerUser | ||
|
@@ -12,12 +13,6 @@ defmodule Recognizer.AccountsTest do | |
|
||
setup :verify_on_exit! | ||
|
||
defp ok_bigcommerce_response() do | ||
body = Jason.encode!(%{data: [%{id: 1001}]}) | ||
|
||
{:ok, %HTTPoison.Response{body: body, status_code: 200}} | ||
end | ||
|
||
describe "get_user_by_email/1" do | ||
test "does not return the user if the email does not exist" do | ||
refute Accounts.get_user_by_email("[email protected]") | ||
|
@@ -193,13 +188,17 @@ defmodule Recognizer.AccountsTest do | |
end | ||
|
||
test "updates the email", %{user: user} do | ||
expect(HTTPoisonMock, :put, 1, fn _, _, _ -> ok_bigcommerce_response() end) | ||
|
||
assert {:ok, _user} = Accounts.update_user(user, %{email: "[email protected]"}) | ||
changed_user = Repo.get!(User, user.id) | ||
assert changed_user.email != user.email | ||
assert "[email protected]" == changed_user.email | ||
end | ||
|
||
test "clears company name for individual accounts", %{user: user} do | ||
expect(HTTPoisonMock, :put, 1, fn _, _, _ -> ok_bigcommerce_response() end) | ||
|
||
assert {:ok, _user} = Accounts.update_user(user, %{type: :individual, company_name: "test"}) | ||
changed_user = Repo.get!(User, user.id) | ||
assert changed_user.type == :individual | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ defmodule RecognizerWeb.Api.UserRegistrationControllerTest do | |
use RecognizerWeb.ConnCase | ||
|
||
import Mox | ||
import Recognizer.BigCommerceTestHelpers | ||
|
||
alias Recognizer.Accounts.BCCustomerUser | ||
alias Recognizer.Accounts.User | ||
|
@@ -12,24 +13,13 @@ defmodule RecognizerWeb.Api.UserRegistrationControllerTest do | |
setup :verify_on_exit! | ||
setup :register_and_log_in_admin | ||
|
||
defp ok_bigcommerce_response() do | ||
body = Jason.encode!(%{data: [%{id: 1001}]}) | ||
|
||
{:ok, %HTTPoison.Response{body: body, status_code: 200}} | ||
end | ||
|
||
defp limit_bigcommerce_response() do | ||
headers = [{"x-rate-limit-time-reset-ms", "1"}] | ||
|
||
{:ok, %HTTPoison.Response{status_code: 429, headers: headers}} | ||
end | ||
|
||
describe "POST /api/create-account" do | ||
test "POST /api/create-account is limited to staff only", %{conn: conn} do | ||
user = %{ | ||
"email" => "[email protected]", | ||
"first_name" => "Test", | ||
"last_name" => "User" | ||
"last_name" => "User", | ||
"company" => "" | ||
} | ||
|
||
user_json = Jason.encode!([user]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.