// test "create_action/1 kind: boot, valid" { // user = insert(:user) // commander = insert(:commander) // user_data = build(:user_data, %{ // turn: true, // user_id: user.id, // commander_id: commander.id, // position: 1 // }) // game = insert(:game, %{ // user_data: [ // build(:user_data, %{turn: false, position: 0, commander_id: commander.id, user_id: insert(:user).id}), // user_data, // build(:user_data, %{turn: false, position: 2, active: false, commander_id: commander.id, user_id: insert(:user).id}), // build(:user_data, %{turn: false, position: 3, commander_id: commander.id, user_id: insert(:user).id}) // ] // }) // insert(:game_user, %{game: game, faction: 1}) // insert(:game_user, %{game: game, faction: 2}) // action = build(:action, %{ // kind: "boot", // game_id: game.id, // user_id: user.id, // system: true // }) // |> Map.from_struct() // assert {:ok, Action { // game: Game { // user_data: [ // UserData {turn: false, position: 1, active: false, state: "boot"}, // UserData {turn: false, position: 2, active: false}, // UserData {turn: true, position: 3, active: true}, // UserData {turn: false, position: 0, active: true} // ] // } // } = action} = Engine.create_action(action) // assert_delivered_email WebWarsNotify.Mailers.Boot.email(action) // } // test "create_action/1 kind: boot, invalid" { // user = insert(:user) // game = insert(:game) // action = build(:action, %{ // kind: "boot", // game_id: game.id, // user_id: user.id // }) // |> Map.from_struct() // assert {:error, Changeset { // errors: [ // kind: {"must be system action", []} // ] // }} = Engine.create_action(action) // }