Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add show admin endpoint #42

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

yashin5
Copy link
Collaborator

@yashin5 yashin5 commented Oct 30, 2020

This PR aims to do an admin endpoint that returns an identity

@yashin5 yashin5 requested a review from lcpojr October 30, 2020 22:55
@yashin5 yashin5 force-pushed the feat/add_show_admin_endpoint branch from 3b9a4b4 to adaa2ea Compare October 30, 2020 22:55
@yashin5 yashin5 force-pushed the feat/add_show_admin_endpoint branch 2 times, most recently from 26c8ea3 to 7ca729e Compare November 10, 2020 00:00
@yashin5 yashin5 force-pushed the feat/add_show_admin_endpoint branch from 7ca729e to ed091f9 Compare November 10, 2020 00:02
@yashin5 yashin5 marked this pull request as ready for review November 10, 2020 00:03
@yashin5 yashin5 marked this pull request as draft November 10, 2020 00:03
* chore: refactor factories

* chore: change dialyzer folder

* chore: update plt config
@yashin5 yashin5 force-pushed the feat/add_show_admin_endpoint branch from 4c8e984 to a3ffcb2 Compare November 10, 2020 00:13
@yashin5 yashin5 force-pushed the feat/add_show_admin_endpoint branch from e3aaf45 to 0ca451e Compare December 9, 2020 00:14
@yashin5 yashin5 marked this pull request as ready for review December 9, 2020 00:26
@yashin5 yashin5 requested a review from lcpojr December 9, 2020 00:26

using do
quote do
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import RestAPI.ConnCase
import RestAPI.{ConnCase, Factory}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use the resource_manager factory here.

Comment on lines +1 to +32
defmodule RestAPI.Factory do
@moduledoc false

alias ResourceManager.Identities.Schemas.User
alias ResourceManager.Repo

@doc "Builds a default struct from the requested model"
@spec build(model :: atom()) :: struct()
def build(:user) do
%User{
username: "my-test-username#{System.unique_integer()}",
status: "active",
is_admin: false
}
end

@doc "Returns the a model struct with the given attributes"
@spec build(factory_name :: atom(), attributes :: Keyword.t()) :: struct()
def build(factory_name, attributes) when is_atom(factory_name) and is_list(attributes) do
factory_name
|> build()
|> struct!(attributes)
end

@doc "Inserts a model with the given attributes on database"
@spec insert!(factory_name :: atom(), attributes :: Keyword.t()) :: struct()
def insert!(factory_name, attributes \\ []) when is_atom(factory_name) do
factory_name
|> build(attributes)
|> Repo.insert!()
end
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.
This is not necessary.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants