require 'test_helper'

class BusinessesControllerTest < ActionDispatch::IntegrationTest
  setup do
    @business = businesses(:one)
  end

  test "should get index" do
    get businesses_url
    assert_response :success
  end

  test "should get new" do
    get new_business_url
    assert_response :success
  end

  test "should create business" do
    assert_difference('Business.count') do
      post businesses_url, params: { business: { address_id: @business.address_id, business_id: @business.business_id, business_name: @business.business_name, email: @business.email, prim_contact_id: @business.prim_contact_id, sec_contact_id: @business.sec_contact_id, url: @business.url } }
    end

    assert_redirected_to business_url(Business.last)
  end

  test "should show business" do
    get business_url(@business)
    assert_response :success
  end

  test "should get edit" do
    get edit_business_url(@business)
    assert_response :success
  end

  test "should update business" do
    patch business_url(@business), params: { business: { address_id: @business.address_id, business_id: @business.business_id, business_name: @business.business_name, email: @business.email, prim_contact_id: @business.prim_contact_id, sec_contact_id: @business.sec_contact_id, url: @business.url } }
    assert_redirected_to business_url(@business)
  end

  test "should destroy business" do
    assert_difference('Business.count', -1) do
      delete business_url(@business)
    end

    assert_redirected_to businesses_url
  end
end
