Features: - User registration and authentication with email/password - Admin login with username-based authentication (separate from regular users) - Review system for contractors to rate clients - Star rating system with review forms - Client identification with private data protection - Contractor registration with document verification - Admin dashboard for review management - Contact form (demo, non-functional) - Responsive navigation with DaisyUI components - Docker Compose setup for production deployment - PostgreSQL database with Ecto migrations - High Vis color scheme (dark background with safety orange/green) Admin credentials: username: admin, password: admin123 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
121 lines
4.6 KiB
Elixir
121 lines
4.6 KiB
Elixir
defmodule MyFirstElixirVibeCode.AccountsTest do
|
|
use MyFirstElixirVibeCode.DataCase
|
|
|
|
alias MyFirstElixirVibeCode.Accounts
|
|
|
|
describe "clients" do
|
|
alias MyFirstElixirVibeCode.Accounts.Client
|
|
|
|
import MyFirstElixirVibeCode.AccountsFixtures
|
|
|
|
@invalid_attrs %{name: nil, email: nil, company_name: nil}
|
|
|
|
test "list_clients/0 returns all clients" do
|
|
client = client_fixture()
|
|
assert Accounts.list_clients() == [client]
|
|
end
|
|
|
|
test "get_client!/1 returns the client with given id" do
|
|
client = client_fixture()
|
|
assert Accounts.get_client!(client.id) == client
|
|
end
|
|
|
|
test "create_client/1 with valid data creates a client" do
|
|
valid_attrs = %{name: "some name", email: "some email", company_name: "some company_name"}
|
|
|
|
assert {:ok, %Client{} = client} = Accounts.create_client(valid_attrs)
|
|
assert client.name == "some name"
|
|
assert client.email == "some email"
|
|
assert client.company_name == "some company_name"
|
|
end
|
|
|
|
test "create_client/1 with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Accounts.create_client(@invalid_attrs)
|
|
end
|
|
|
|
test "update_client/2 with valid data updates the client" do
|
|
client = client_fixture()
|
|
update_attrs = %{name: "some updated name", email: "some updated email", company_name: "some updated company_name"}
|
|
|
|
assert {:ok, %Client{} = client} = Accounts.update_client(client, update_attrs)
|
|
assert client.name == "some updated name"
|
|
assert client.email == "some updated email"
|
|
assert client.company_name == "some updated company_name"
|
|
end
|
|
|
|
test "update_client/2 with invalid data returns error changeset" do
|
|
client = client_fixture()
|
|
assert {:error, %Ecto.Changeset{}} = Accounts.update_client(client, @invalid_attrs)
|
|
assert client == Accounts.get_client!(client.id)
|
|
end
|
|
|
|
test "delete_client/1 deletes the client" do
|
|
client = client_fixture()
|
|
assert {:ok, %Client{}} = Accounts.delete_client(client)
|
|
assert_raise Ecto.NoResultsError, fn -> Accounts.get_client!(client.id) end
|
|
end
|
|
|
|
test "change_client/1 returns a client changeset" do
|
|
client = client_fixture()
|
|
assert %Ecto.Changeset{} = Accounts.change_client(client)
|
|
end
|
|
end
|
|
|
|
describe "contractors" do
|
|
alias MyFirstElixirVibeCode.Accounts.Contractor
|
|
|
|
import MyFirstElixirVibeCode.AccountsFixtures
|
|
|
|
@invalid_attrs %{name: nil, email: nil, company_name: nil}
|
|
|
|
test "list_contractors/0 returns all contractors" do
|
|
contractor = contractor_fixture()
|
|
assert Accounts.list_contractors() == [contractor]
|
|
end
|
|
|
|
test "get_contractor!/1 returns the contractor with given id" do
|
|
contractor = contractor_fixture()
|
|
assert Accounts.get_contractor!(contractor.id) == contractor
|
|
end
|
|
|
|
test "create_contractor/1 with valid data creates a contractor" do
|
|
valid_attrs = %{name: "some name", email: "some email", company_name: "some company_name"}
|
|
|
|
assert {:ok, %Contractor{} = contractor} = Accounts.create_contractor(valid_attrs)
|
|
assert contractor.name == "some name"
|
|
assert contractor.email == "some email"
|
|
assert contractor.company_name == "some company_name"
|
|
end
|
|
|
|
test "create_contractor/1 with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Accounts.create_contractor(@invalid_attrs)
|
|
end
|
|
|
|
test "update_contractor/2 with valid data updates the contractor" do
|
|
contractor = contractor_fixture()
|
|
update_attrs = %{name: "some updated name", email: "some updated email", company_name: "some updated company_name"}
|
|
|
|
assert {:ok, %Contractor{} = contractor} = Accounts.update_contractor(contractor, update_attrs)
|
|
assert contractor.name == "some updated name"
|
|
assert contractor.email == "some updated email"
|
|
assert contractor.company_name == "some updated company_name"
|
|
end
|
|
|
|
test "update_contractor/2 with invalid data returns error changeset" do
|
|
contractor = contractor_fixture()
|
|
assert {:error, %Ecto.Changeset{}} = Accounts.update_contractor(contractor, @invalid_attrs)
|
|
assert contractor == Accounts.get_contractor!(contractor.id)
|
|
end
|
|
|
|
test "delete_contractor/1 deletes the contractor" do
|
|
contractor = contractor_fixture()
|
|
assert {:ok, %Contractor{}} = Accounts.delete_contractor(contractor)
|
|
assert_raise Ecto.NoResultsError, fn -> Accounts.get_contractor!(contractor.id) end
|
|
end
|
|
|
|
test "change_contractor/1 returns a contractor changeset" do
|
|
contractor = contractor_fixture()
|
|
assert %Ecto.Changeset{} = Accounts.change_contractor(contractor)
|
|
end
|
|
end
|
|
end
|