require 'test_helper' module PagesCms class ContactsControllerTest < ActionController::TestCase setup do @routes = Engine.routes ActionMailer::Base.deliveries.clear end test 'submit a contact form' do request.env['HTTP_REFERER'] = 'where_i_came_from' assert_difference 'Contact.count', +1 do post :create, contact: { name: 'Jimmy', email: 'jimmy@test.com', message: 'hello there' } end assert_redirected_to 'where_i_came_from' assert_equal 1, ActionMailer::Base.deliveries.size end end end