Sha256: a1c6998ff228aa919894dd3d6e74866bb2fe759f83afa5066805e85b745b6519

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

require "test/test_helper"

class ValidationTest < ActiveSupport::TestCase

  context "A model that has and validates its role" do

    setup do 
      @user = User.new()
    end
    
    context "that has a role_name mapping to a role" do
      
      setup do
        @user.role_name = "admin"
      end
      
      should "be valid" do
        assert @user.valid?
      end
      
    end
    
    context "that has a blank role_name" do
      
      setup do
        @user.role_name = ""
      end
      
      should "not be valid" do
        assert !@user.valid?
      end
      
    end
    
    context "that has a role_name not mapping to a role" do
      
      setup do
        @user.role_name = "nonexisting_role_name"
      end
      
      should "not be valid" do
        assert !@user.valid?
      end
      
    end
    
    should "use add the default inclusion error message on role_name" do
      @user.role_name = ""
      @user.valid?
      assert_equal I18n.translate('activerecord.errors.messages.inclusion'), @user.errors.on(:role_name)
    end
    
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
aegis-1.1.8 test/validation_test.rb
thelinuxlich-aegis-1.1.9 test/validation_test.rb
thelinuxlich-aegis-1.1.8 test/validation_test.rb
thelinuxlich-aegis-1.1.7 test/validation_test.rb
aegis-1.1.7 test/validation_test.rb