My space on the web https://inhji.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.6 KiB

defmodule MirageWeb.SettingControllerTest do
use MirageWeb.ConnCase
alias Mirage.Settings
setup :register_and_log_in_user
@create_attrs %{name: "some name", value: "some value"}
@update_attrs %{name: "some updated name", value: "some updated value"}
@invalid_attrs %{name: nil, value: nil}
def fixture(:setting) do
{:ok, setting} = Settings.create_setting(@create_attrs)
setting
end
describe "index" do
test "lists all settings", %{conn: conn} do
conn = get(conn, Routes.setting_path(conn, :index))
assert html_response(conn, 200) =~ "Settings"
end
end
describe "edit setting" do
setup [:create_setting]
test "renders form for editing chosen setting", %{conn: conn, setting: setting} do
conn = get(conn, Routes.setting_path(conn, :edit, setting))
assert html_response(conn, 200) =~ "Edit Setting"
end
end
describe "update setting" do
setup [:create_setting]
test "redirects when data is valid", %{conn: conn, setting: setting} do
conn = put(conn, Routes.setting_path(conn, :update, setting), setting: @update_attrs)
assert redirected_to(conn) == Routes.setting_path(conn, :show, setting)
conn = get(conn, Routes.setting_path(conn, :show, setting))
assert html_response(conn, 200) =~ "some updated name"
end
test "renders errors when data is invalid", %{conn: conn, setting: setting} do
conn = put(conn, Routes.setting_path(conn, :update, setting), setting: @invalid_attrs)
assert html_response(conn, 200) =~ "Edit Setting"
end
end
defp create_setting(_) do
setting = fixture(:setting)
%{setting: setting}
end
end