require 'test_helper'

module Catcontacts
  class ContactsControllerTest < ActionController::TestCase
    setup do
      @contact = catcontacts_contacts(:one)
      @routes = Engine.routes
    end

    test "should get index" do
      get :index
      assert_response :success
      assert_not_nil assigns(:contacts)
    end

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

    test "should create contact" do
      assert_difference('Contact.count') do
        post :create, contact: { business_id: @contact.business_id, first_name: @contact.first_name, generation: @contact.generation, honor: @contact.honor, last_name: @contact.last_name, middle_name: @contact.middle_name, title: @contact.title }
      end

      assert_redirected_to contact_path(assigns(:contact))
    end

    test "should show contact" do
      get :show, id: @contact
      assert_response :success
    end

    test "should get edit" do
      get :edit, id: @contact
      assert_response :success
    end

    test "should update contact" do
      patch :update, id: @contact, contact: { business_id: @contact.business_id, first_name: @contact.first_name, generation: @contact.generation, honor: @contact.honor, last_name: @contact.last_name, middle_name: @contact.middle_name, title: @contact.title }
      assert_redirected_to contact_path(assigns(:contact))
    end

    test "should destroy contact" do
      assert_difference('Contact.count', -1) do
        delete :destroy, id: @contact
      end

      assert_redirected_to contacts_path
    end
  end
end
