Sha256: 15150b8b0dbedc4299fb4d94ca60f9898adf55e791ee486864de882adfd8defd

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require 'test/unit'
require 'rubygems'

RAILS_ENV = ENV["RAILS_ENV"] = "test"

require 'active_support'
require 'active_support/test_case'
require 'action_mailer'
require 'action_controller/test_case'

ActionMailer::Base.delivery_method = :test

# Load respond_to before defining ApplicationController
require File.dirname(__FILE__) + '/../lib/mail_form.rb'

class ContactForm < MailForm
  recipients 'my.email@my.domain.com'

  attribute :name,     :validate => true
  attribute :email,    :validate => /[^@]+@[^\.]+\.[\w\.\-]+/
  attribute :nickname, :captcha => true
  attributes :tellphone, :message, :validate => :callback

  def callback
    @_callback_run = true
  end
end

class AdvancedForm < ContactForm
  append :remote_ip, :user_agent, :session

  recipients [ 'my.first@email.com', 'my.second@email.com' ]
  subject 'My Advanced Form'
  sender{|c| %{"#{c.name}" <#{c.email}>} }
  headers 'return-path' => 'mypath'
end

class FileForm < ContactForm
  attribute :file, :attachment => true, :validate => true
  recipients :set_recipient

  def set_recipient
    if file
      "contact_file@my.domain.com"
    else
      "contact@my.domain.com"
    end
  end
end

class NullRecipient < MailForm
  sender 'my.email@my.domain.com'
end

class TemplateForm < ContactForm
  template 'custom_template'
end

# Needed to correctly test an uploaded file
class ActionController::TestUploadedFile
  def read
    @tempfile.read
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mail_form-1.0.0 test/test_helper.rb