about summary refs log tree commit diff
path: root/test/controllers/machines_controller_test.rb
blob: 61ec2045e7e7f2fc1df904f805c18e6a59465a2a (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 MachinesControllerTest < ActionDispatch::IntegrationTest
  setup do
    @machine = machines(:one)
  end

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

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

  test 'should create machine' do
    assert_difference('Machine.count') do
      post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } }
    end

    assert_redirected_to machine_url(Machine.last)
  end

  test 'should show machine' do
    get machine_url(@machine)
    assert_response :success
  end

  test 'should get edit' do
    get edit_machine_url(@machine)
    assert_response :success
  end

  test 'should update machine' do
    patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } }
    assert_redirected_to machine_url(@machine)
  end

  test 'should destroy machine' do
    assert_difference('Machine.count', -1) do
      delete machine_url(@machine)
    end

    assert_redirected_to machines_url
  end
end