Sha256: 160dc58ce0d6f2845bdf370211f094925afe84017fd316fdb1a60b64b9a848c0

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

class InquiryTest < ActiveSupport::TestCase

  fixtures :inquiries

  def setup
    @new_inquiry = Inquiry.new
    @bad_email_inquiry = Inquiry.new(:email => "foo.bar.com", :name => "Dave")
    @valid_inquiry = Inquiry.new(:email => "foo@bar.com", :name => "Dave")
    @full_valid_inquiry = Inquiry.new(:email => "foo@bar.com", :name => "Dave", :phone => "3232332", :message => "message")
  end

  def test_should_force_name_and_email_to_be_valid
    assert !@new_inquiry.save

    assert_equal "can't be blank", @new_inquiry.errors.on('name')
    assert_equal "must be valid", @new_inquiry.errors.on('email')

    assert_nil @new_inquiry.errors.on('phone')
    assert_nil @new_inquiry.errors.on('message')

    assert !@bad_email_inquiry.save
    assert_equal "must be valid", @bad_email_inquiry.errors.on('email')
    assert_nil @bad_email_inquiry.errors.on('phone')
    assert_nil @bad_email_inquiry.errors.on('message')
    assert_nil @bad_email_inquiry.errors.on('name')

    assert @valid_inquiry.save
    assert @full_valid_inquiry.save
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
refinerycms-0.9.6.34 test/unit/inquiry_test.rb
refinerycms-0.9.6.33 test/unit/inquiry_test.rb
refinerycms-0.9.6.32 test/unit/inquiry_test.rb