validates_as_email_address 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  == master
2
2
 
3
+ == 0.2.3 / 2009-04-13
4
+
5
+ * Update docs
6
+
3
7
  == 0.2.2 / 2009-03-15
4
8
 
5
9
  * Add support for Rails 2.2 i18n error messages [Saimon Moore]
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = 'validates_as_email_address'
8
- s.version = '0.2.2'
8
+ s.version = '0.2.3'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'Adds support for validating the format/length of email addresses'
11
11
 
@@ -31,6 +31,10 @@ module ValidatesAsEmailAddress
31
31
  # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt>
32
32
  # method and the attribute is the wrong size (default is:
33
33
  # "is the wrong length (should be %d characters)")
34
+ # * <tt>:tokenizer</tt> - Specifies how to split up the attribute string.
35
+ # (e.g. <tt>:tokenizer => lambda {|str| str.scan(/\w+/)}</tt> to count
36
+ # words.) Defaults to <tt>lambda {|value| value.split(//)}</tt> which
37
+ # counts individual characters.
34
38
  #
35
39
  # Configuration options for format:
36
40
  # * <tt>:wrong_format</tt> - A custom error message (default is:
@@ -38,6 +42,7 @@ module ValidatesAsEmailAddress
38
42
  #
39
43
  # Miscellaneous configuration options:
40
44
  # * <tt>:allow_nil</tt> - Attribute may be nil; skip validation.
45
+ # * <tt>:allow_blank</tt> - Attribute may be blank; skip validation.
41
46
  # * <tt>:on</tt> - Specifies when this validation is active (default is
42
47
  # :save, other options :create, :update)
43
48
  # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class ValidatesAsEmailAddressByDefaultTest < Test::Unit::TestCase
3
+ class ValidatesAsEmailAddressByDefaultTest < ActiveSupport::TestCase
4
4
  def setup
5
5
  User.validates_as_email_address :email
6
6
  end
@@ -69,7 +69,7 @@ class ValidatesAsEmailAddressByDefaultTest < Test::Unit::TestCase
69
69
  end
70
70
  end
71
71
 
72
- class ValidatesAsEmailAddressTest < Test::Unit::TestCase
72
+ class ValidatesAsEmailAddressTest < ActiveSupport::TestCase
73
73
  def test_should_allow_minimum_length
74
74
  User.validates_as_email_address :email, :minimum => 8
75
75
 
@@ -214,6 +214,86 @@ class ValidatesAsEmailAddressTest < Test::Unit::TestCase
214
214
  assert user.valid?
215
215
  end
216
216
 
217
+ def test_should_validate_if_on_event
218
+ User.validates_as_email_address :email, :on => :update
219
+
220
+ user = create_user
221
+ user.email = 'a'
222
+ assert !user.valid?
223
+ end
224
+
225
+ def test_should_not_validate_if_not_on_event
226
+ User.validates_as_email_address :email, :on => :create
227
+
228
+ user = create_user
229
+ user.email = 'a'
230
+ assert user.valid?
231
+ end
232
+
233
+ def test_should_not_validate_if_allow_nil_and_nil
234
+ User.validates_as_email_address :email, :allow_nil => true
235
+
236
+ user = create_user
237
+ user.email = nil
238
+ assert user.valid?
239
+ end
240
+
241
+ def test_should_validate_if_allow_nil_and_not_nil
242
+ User.validates_as_email_address :email, :allow_nil => true
243
+
244
+ user = create_user
245
+ user.email = 'a'
246
+ assert !user.valid?
247
+ end
248
+
249
+ def test_should_validate_if_not_allow_nil_and_nil
250
+ User.validates_as_email_address :email, :allow_nil => false
251
+
252
+ user = create_user
253
+ user.email = nil
254
+ assert !user.valid?
255
+ end
256
+
257
+ def test_should_validate_if_not_allow_nil_and_not_nil
258
+ User.validates_as_email_address :email, :allow_nil => false
259
+
260
+ user = create_user
261
+ user.email = 'a'
262
+ assert !user.valid?
263
+ end
264
+
265
+ def test_should_not_validate_if_allow_blank_and_blank
266
+ User.validates_as_email_address :email, :allow_blank => true
267
+
268
+ user = create_user
269
+ user.email = ''
270
+ assert user.valid?
271
+ end
272
+
273
+ def test_should_validate_if_allow_blank_and_not_blank
274
+ User.validates_as_email_address :email, :allow_blank => true
275
+
276
+ user = create_user
277
+ user.email = 'a'
278
+ assert !user.valid?
279
+ end
280
+
281
+ def test_should_validate_if_not_allow_blank_and_blank
282
+ User.validates_as_email_address :email, :allow_blank => false
283
+
284
+ user = create_user
285
+ user.email = ''
286
+ assert !user.valid?
287
+ end
288
+
289
+ def test_should_validate_if_not_allow_nil_and_not_nil
290
+ User.validates_as_email_address :email, :allow_blank => false
291
+
292
+ user = create_user
293
+ user.email = 'a'
294
+ assert !user.valid?
295
+ end
296
+
217
297
  def teardown
218
298
  User.class_eval do
219
299
  @validate_callbacks = ActiveSupport::Callbacks::CallbackChain.new
@@ -223,7 +303,7 @@ class ValidatesAsEmailAddressTest < Test::Unit::TestCase
223
303
  end
224
304
  end
225
305
 
226
- class ValidatesAsEmailAddressUnrestrictedTest < Test::Unit::TestCase
306
+ class ValidatesAsEmailAddressUnrestrictedTest < ActiveSupport::TestCase
227
307
  def setup
228
308
  User.validates_as_email_address :email, :strict => false
229
309
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_as_email_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-15 00:00:00 -04:00
12
+ date: 2009-04-13 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements: []
66
66
 
67
67
  rubyforge_project: pluginaweek
68
- rubygems_version: 1.2.0
68
+ rubygems_version: 1.3.1
69
69
  signing_key:
70
70
  specification_version: 2
71
71
  summary: Adds support for validating the format/length of email addresses