Sha256: 3bf057a05d85980f934247b88157fe510f6d46e7d3e95bda6951be2c1329983c

Contents?: true

Size: 1.43 KB

Versions: 13

Compression:

Stored size: 1.43 KB

Contents

require File.dirname(__FILE__) + '/../../test/test_helper'


class I18nMessagesTest < Test::Unit::TestCase
  def test_should_have_default_message
    p = PhotoBare.new
    p.save
    assert_equal "is required", p.errors["image_file"]
    
    p = PhotoBare.new(:image_file => files(:not_a_photo))
    p.save
    assert_equal "was not a readable image", p.errors["image_file"]
    
    p = PhotoBare.new(:image_file => files(:i1x1))
    p.save
    assert_equal "is too small (Minimum: 2x2)", p.errors["image_file"]
  end
  
  def test_should_have_german_message
    I18n.locale = "de"
    p = PhotoBare.new
    p.save
    assert_equal "ist erforderlich", p.errors["image_file"]
    
    p = PhotoBare.new(:image_file => files(:not_a_photo))
    p.save
    assert_equal "war nicht lesbar", p.errors["image_file"]
    
    p = PhotoBare.new(:image_file => files(:i1x1))
    p.save
    assert_equal "ist zu klein (Minimalgröße: 2x2)", p.errors["image_file"]
  ensure
    I18n.locale = "en"
  end
  
  def test_should_have_model_specific_message
    p = PhotoCustomError.new
    assert !p.save
    assert_equal "needs to be attached", p.errors["image_file"]
    
    p = PhotoCustomError.new(:image_file => files(:not_a_photo))
    p.save
    assert_equal "seems to be broken", p.errors["image_file"]
    
    p = PhotoCustomError.new(:image_file => files(:i1x1))
    assert !p.save
    assert_equal "must be bigger (min. size: 2x2)", p.errors["image_file"]
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
tvdeyen-fleximage-1.1.1 test/unit/i18n_messages_test.rb
tvdeyen-fleximage-1.0.9 test/unit/i18n_messages_test.rb
tvdeyen-fleximage-1.0.8 test/unit/i18n_messages_test.rb
tvdeyen-fleximage-1.0.7 test/unit/i18n_messages_test.rb
robinboening-fleximage-1.0.6 test/unit/i18n_messages_test.rb
robinboening-fleximage-1.0.4 test/unit/i18n_messages_test.rb
tvdeyen-fleximage-1.0.5 test/unit/i18n_messages_test.rb
fleximage-1.0.4 test/unit/i18n_messages_test.rb
dougmcbride-fleximage-1.0.3 test/unit/i18n_messages_test.rb
fleximage-1.0.3 test/unit/i18n_messages_test.rb
fleximage-1.0.2 test/unit/i18n_messages_test.rb
fleximage-1.0.1 test/unit/i18n_messages_test.rb
fleximage-1.0.0 test/unit/i18n_messages_test.rb