about summary refs log tree commit diff
path: root/test/controllers/players_controller_test.rb
blob: 8e446f03459bf9f76fa3c5ea16f749e588228a77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'test_helper'

class PlayersControllerTest < ActionDispatch::IntegrationTest
  setup do
    @player = players(:one)
  end

  test 'should get index' do
    get players_url
    assert_response :success
  end

  test 'should get new' do
    get new_player_url
    assert_response :success
  end

  test 'should create player' do
    assert_difference('Player.count') do
      post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
    end

    assert_redirected_to player_url(Player.last)
  end

  test 'should show player' do
    get player_url(@player)
    assert_response :success
  end

  test 'should get edit' do
    get edit_player_url(@player)
    assert_response :success
  end

  test 'should update player' do
    patch player_url(@player), params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
    assert_redirected_to player_url(@player)
  end

  test 'should destroy player' do
    assert_difference('Player.count', -1) do
      delete player_url(@player)
    end

    assert_redirected_to players_url
  end
end