Skip to content

Commit

Permalink
Remove team editable actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nburkley committed Oct 7, 2016
1 parent 76adab9 commit e498962
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 123 deletions.
38 changes: 0 additions & 38 deletions test/controllers/team_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ defmodule EspiDni.TeamControllerTest do
assert html_response(conn, 200) =~ "Listing teams"
end

test "renders form for new resources", %{conn: conn} do
conn = get conn, team_path(conn, :new)
assert html_response(conn, 200) =~ "New team"
end

test "creates resource and redirects when data is valid", %{conn: conn} do
conn = post conn, team_path(conn, :create), team: @valid_attrs
assert redirected_to(conn) == team_path(conn, :index)
assert Repo.get_by(Team, @valid_attrs)
end

test "does not create resource and renders errors when data is invalid", %{conn: conn} do
conn = post conn, team_path(conn, :create), team: @invalid_attrs
assert html_response(conn, 200) =~ "New team"
end

test "shows chosen resource", %{conn: conn, team: team} do
conn = get conn, team_path(conn, :show, team)
assert html_response(conn, 200) =~ "Show team"
Expand All @@ -41,26 +25,4 @@ defmodule EspiDni.TeamControllerTest do
get conn, team_path(conn, :show, -1)
end
end

test "renders form for editing chosen resource", %{conn: conn, team: team} do
conn = get conn, team_path(conn, :edit, team)
assert html_response(conn, 200) =~ "Edit team"
end

test "updates chosen resource and redirects when data is valid", %{conn: conn, team: team} do
conn = put conn, team_path(conn, :update, team), team: @valid_attrs
assert redirected_to(conn) == team_path(conn, :show, team)
assert Repo.get_by(Team, @valid_attrs)
end

test "does not update chosen resource and renders errors when data is invalid", %{conn: conn, team: team} do
conn = put conn, team_path(conn, :update, team), team: @invalid_attrs
assert html_response(conn, 200) =~ "Edit team"
end

test "deletes chosen resource", %{conn: conn, team: team} do
conn = delete conn, team_path(conn, :delete, team)
assert redirected_to(conn) == team_path(conn, :index)
refute Repo.get(Team, team.id)
end
end
49 changes: 0 additions & 49 deletions web/controllers/team_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,9 @@ defmodule EspiDni.TeamController do
render(conn, "index.html", teams: teams)
end

def new(conn, _params) do
changeset = Team.changeset(%Team{})
render(conn, "new.html", changeset: changeset)
end

def create(conn, %{"team" => team_params}) do
changeset = Team.changeset(%Team{}, team_params)

case Repo.insert(changeset) do
{:ok, _team} ->
conn
|> put_flash(:info, "Team created successfully.")
|> redirect(to: team_path(conn, :index))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
end
end

def show(conn, %{"id" => id}) do
team = Repo.get!(Team, id)
render(conn, "show.html", team: team)
end

def edit(conn, %{"id" => id}) do
team = Repo.get!(Team, id)
changeset = Team.changeset(team)
render(conn, "edit.html", team: team, changeset: changeset)
end

def update(conn, %{"id" => id, "team" => team_params}) do
team = Repo.get!(Team, id)
changeset = Team.changeset(team, team_params)

case Repo.update(changeset) do
{:ok, team} ->
conn
|> put_flash(:info, "Team updated successfully.")
|> redirect(to: team_path(conn, :show, team))
{:error, changeset} ->
render(conn, "edit.html", team: team, changeset: changeset)
end
end

def delete(conn, %{"id" => id}) do
team = Repo.get!(Team, id)

# Here we use delete! (with a bang) because we expect
# it to always work (and if it does not, it will raise).
Repo.delete!(team)

conn
|> put_flash(:info, "Team deleted successfully.")
|> redirect(to: team_path(conn, :index))
end
end
6 changes: 0 additions & 6 deletions web/templates/team/edit.html.eex

This file was deleted.

23 changes: 0 additions & 23 deletions web/templates/team/form.html.eex

This file was deleted.

6 changes: 0 additions & 6 deletions web/templates/team/new.html.eex

This file was deleted.

1 change: 0 additions & 1 deletion web/templates/team/show.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@

</ul>

<%= link "Edit", to: team_path(@conn, :edit, @team) %>
<%= link "Back", to: team_path(@conn, :index) %>

0 comments on commit e498962

Please sign in to comment.