Sha256: 14a6e3418f7892a4148d0c851a260bde16709d8818eecbdc7920999aade73e56

Contents?: true

Size: 1.52 KB

Versions: 48

Compression:

Stored size: 1.52 KB

Contents

require 'test_helper'

module Incline
  class ContactMessageTest < ActiveSupport::TestCase

    def setup
      @item = Incline::ContactMessage.new(
          your_name: 'Jane Doe',
          your_email: 'janed@example.com',
          related_to: 'Other',
          subject: 'Just a test',
          body: 'This is just a test message.',
          recaptcha: Incline::Recaptcha::DISABLED
      )
    end

    test 'should be valid' do
      assert @item.valid?
    end

    test 'should require your_name' do
      assert_required @item, :your_name
    end

    test 'should require your_email' do
      assert_required @item, :your_email
    end

    test 'should require related_to' do
      assert_required @item, :related_to
    end

    test 'should require subject when related_to is other' do
      @item.related_to = 'other'
      assert_required @item, :subject
    end

    test 'should not require subject when related_to is anything else' do
      @item.related_to = 'something'
      assert @item.valid?
      @item.subject = nil
      assert @item.valid?
      @item.subject = ''
      assert @item.valid?
      @item.subject = '   '
      assert @item.valid?
    end

    test 'should require body' do
      assert_required @item, :body
    end

    test 'should require recaptcha' do
      assert_required @item, :recaptcha
    end

    test 'should validate recaptcha' do
      assert_recaptcha_validation @item, :recaptcha
    end

    test 'should validate email' do
      assert_email_validation @item, :your_email
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 test/models/incline/contact_message_test.rb
incline-0.3.13 test/models/incline/contact_message_test.rb
incline-0.3.12 test/models/incline/contact_message_test.rb
incline-0.3.11 test/models/incline/contact_message_test.rb
incline-0.3.10 test/models/incline/contact_message_test.rb
incline-0.3.9 test/models/incline/contact_message_test.rb
incline-0.3.8 test/models/incline/contact_message_test.rb
incline-0.3.7 test/models/incline/contact_message_test.rb
incline-0.3.6 test/models/incline/contact_message_test.rb
incline-0.3.5 test/models/incline/contact_message_test.rb
incline-0.3.4 test/models/incline/contact_message_test.rb
incline-0.3.3 test/models/incline/contact_message_test.rb
incline-0.3.2 test/models/incline/contact_message_test.rb
incline-0.3.1 test/models/incline/contact_message_test.rb
incline-0.3.0 test/models/incline/contact_message_test.rb
incline-0.2.36 test/models/incline/contact_message_test.rb
incline-0.2.35 test/models/incline/contact_message_test.rb
incline-0.2.34 test/models/incline/contact_message_test.rb
incline-0.2.28 test/models/incline/contact_message_test.rb
incline-0.2.27 test/models/incline/contact_message_test.rb