Project

General

Profile

Revision 977f7c5a

Added by Daniel Lobato Garcia over 6 years ago

Fixes #9270 - Add email validation

Copied the email validation we use for the User model. This catches
errors when creating/updating the Docker compute resource email

View differences:

app/models/foreman_docker/docker.rb
5 5
    attr_accessible :email
6 6

  
7 7
    validates :url, :format => { :with => URI.regexp }
8
    validates :email, :format => { :with => /.+@.+\..+/i }, :allow_blank => true
8 9

  
9 10
    def self.model_name
10 11
      ComputeResource.model_name
test/units/foreman_docker/docker_test.rb
1
require 'test_plugin_helper'
2

  
3
module ForemanDocker
4
  class DockerTest < ActiveSupport::TestCase
5
    should allow_value('a@b.com').for(:email)
6
    should allow_value('').for(:email)
7
    should_not allow_value('abcb.com').for(:email)
8
    should_not allow_value('a').for(:email)
9
  end
10
end

Also available in: Unified diff