Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make assert_unique_email a method, conducive for overriding.

  • Loading branch information...
commit 531e8e6ad56ca0a04fe6cfd5c5bee491fd28a67a 1 parent 12a03de
Cyril David authored April 27, 2011
6  lib/shield/contrib/ohm/email_password.rb
@@ -35,7 +35,7 @@ def email
35 35
       def validate
36 36
         super
37 37
 
38  
-        assert_present(:email) && assert_email(:email) && assert_unique(:email)
  38
+        assert_present(:email) && assert_email(:email) && assert_unique_email(:email)
39 39
 
40 40
         assert_present(:password) if new?
41 41
 
@@ -53,6 +53,10 @@ def password=(password)
53 53
       end
54 54
 
55 55
     private
  56
+      def assert_unique_email(att, error = [att, :not_unique])
  57
+        assert_unique(att, error)
  58
+      end
  59
+
56 60
       def assert_email(att, error = [att, :not_email])
57 61
         assert_format(att, EMAIL_REGEX, error)
58 62
       end
9  test/helper.rb
@@ -19,10 +19,13 @@ class Cutest::Scope
19 19
   include Rack::Test::Methods
20 20
 
21 21
   def assert_redirected_to(path)
22  
-    assert 302  == last_response.status
23  
-    assert path == last_response.headers["Location"]
24  
-  end
  22
+    assert_equal 302, last_response.status
  23
+
  24
+    fullpath = last_response.headers["Location"].
  25
+      gsub(%r{^http://([^/]+)}, "")
25 26
 
  27
+    assert_equal path, fullpath
  28
+  end
26 29
 
27 30
   def session
28 31
     last_request.env["rack.session"]
2  test/sinatra_default_test.rb
@@ -41,7 +41,7 @@ def app
41 41
     assert_redirected_to "/dashboard"
42 42
     follow_redirect!
43 43
 
44  
-    assert "Dashboard" == last_response.body
  44
+    assert_equal "Dashboard", last_response.body
45 45
   end
46 46
 
47 47
   test "GET /logout" do

0 notes on commit 531e8e6

Please sign in to comment.
Something went wrong with that request. Please try again.