Permalink
Browse files

Make assert_unique_email a method, conducive for overriding.

  • Loading branch information...
1 parent 12a03de commit 531e8e6ad56ca0a04fe6cfd5c5bee491fd28a67a @cyx cyx committed Apr 27, 2011
Showing with 12 additions and 5 deletions.
  1. +5 −1 lib/shield/contrib/ohm/email_password.rb
  2. +6 −3 test/helper.rb
  3. +1 −1 test/sinatra_default_test.rb
@@ -35,7 +35,7 @@ def email
def validate
super
- assert_present(:email) && assert_email(:email) && assert_unique(:email)
+ assert_present(:email) && assert_email(:email) && assert_unique_email(:email)
assert_present(:password) if new?
@@ -53,6 +53,10 @@ def password=(password)
end
private
+ def assert_unique_email(att, error = [att, :not_unique])
+ assert_unique(att, error)
+ end
+
def assert_email(att, error = [att, :not_email])
assert_format(att, EMAIL_REGEX, error)
end
View
@@ -19,10 +19,13 @@ class Cutest::Scope
include Rack::Test::Methods
def assert_redirected_to(path)
- assert 302 == last_response.status
- assert path == last_response.headers["Location"]
- end
+ assert_equal 302, last_response.status
+
+ fullpath = last_response.headers["Location"].
+ gsub(%r{^http://([^/]+)}, "")
+ assert_equal path, fullpath
+ end
def session
last_request.env["rack.session"]
@@ -41,7 +41,7 @@ def app
assert_redirected_to "/dashboard"
follow_redirect!
- assert "Dashboard" == last_response.body
+ assert_equal "Dashboard", last_response.body
end
test "GET /logout" do

0 comments on commit 531e8e6

Please sign in to comment.