Sha256: 6c6668af73ffe2d148449f3e80f9e8941109afc2f99251fa75e4e5c7306f1bdb
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' describe ContactUs::ContactsController do describe 'create' do before do ContactUs.mailer_to = 'test@example.com' end it 'should redirect with success message if valid contact' do ContactUs.success_redirect = nil post :create, :contact_us_contact => { :email => 'test@test.com', :message => 'test' } expect(assigns(:contact).valid?).to eql(true) expect(flash[:notice]).to eql('Contact email was successfully sent.') expect(response).to redirect_to('/') end it 'should redirect to custom URL with success message if valid contact' do ContactUs.success_redirect = '/success' post :create, :contact_us_contact => { :email => 'test@test.com', :message => 'test' } expect(assigns(:contact).valid?).to eql(true) expect(flash[:notice]).to eql('Contact email was successfully sent.') expect(response).to redirect_to('/success') ContactUs.success_redirect = '/' end it 'should render new with error message if invalid contact' do post :create, :contact_us_contact => { :email => 'test@test.com', :message => '' } expect(assigns(:contact).valid?).to eql(false) expect(flash[:error]).to eql('You must enter both fields.') expect(response).to render_template('new') end end describe 'new' do it 'should assign contact for form and render page successfully' do get :new expect(assigns(:contact)).to be_an_instance_of(ContactUs::Contact) expect(response).to be_success end end end
Version data entries
3 entries across 3 versions & 1 rubygems