public
Description: Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.
Homepage: http://fleximage.rubyforge.org
Clone URL: git://github.com/Squeegy/fleximage.git
fleximage / test / unit / require_image_option_test.rb
100644 30 lines (25 sloc) 0.787 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require File.dirname(__FILE__) + '/../../test/test_helper'
 
class ValidatedPhoto < ActiveRecord::Base
  set_table_name :photo_dbs
  acts_as_fleximage
  
  def validate
    # overiding the validate method
  end
end
 
class FleximageRequireImageOptionTest < Test::Unit::TestCase
  def test_should_require_image_by_default
    p = PhotoBare.new
    assert !p.save, 'Record expected to not be allowed to save'
  end
  
  def test_should_disable_image_requirement
    PhotoBare.require_image = false
    p = PhotoBare.new
    assert p.save, 'Record expected to be allowed to save'
  ensure
    PhotoBare.require_image = true
  end
  
  def test_should_require_image_when_validate_is_overriden
    p = ValidatedPhoto.new
    assert !p.save, 'Record expected to not be allowed to save'
  end
end