Permalink
Browse files

make tests pass

  • Loading branch information...
1 parent ce48262 commit 72b5d60ec205708e26e3d4e5651773ee7394701e @binarylogic committed Jun 1, 2012
View
@@ -1,12 +1,12 @@
source :rubygems
-gem 'activesupport', '>= 3.0.0'
-gem 'activerecord', '>= 3.0.0'
+gem 'activesupport', '>= 3.0.7'
+gem 'activerecord', '>= 3.0.7'
group :test do
gem 'bcrypt-ruby'
gem 'jeweler'
gem 'rake'
- gem 'ruby-debug19'
+ gem 'debugger'
gem 'sqlite3'
end
View
@@ -12,11 +12,17 @@ GEM
activesupport (3.2.5)
i18n (~> 0.6)
multi_json (~> 1.0)
- archive-tar-minitar (0.5.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
columnize (0.3.6)
+ debugger (1.1.3)
+ columnize (>= 0.3.1)
+ debugger-linecache (~> 1.1.1)
+ debugger-ruby_core_source (~> 1.1.2)
+ debugger-linecache (1.1.1)
+ debugger-ruby_core_source (>= 1.1.1)
+ debugger-ruby_core_source (1.1.3)
git (1.2.5)
i18n (0.6.0)
jeweler (1.8.3)
@@ -25,33 +31,21 @@ GEM
rake
rdoc
json (1.7.3)
- linecache19 (0.5.12)
- ruby_core_source (>= 0.1.4)
multi_json (1.3.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- ruby-debug-base19 (0.11.25)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby_core_source (>= 0.1.4)
- ruby-debug19 (0.11.6)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby-debug-base19 (>= 0.11.19)
- ruby_core_source (0.1.5)
- archive-tar-minitar (>= 0.5.2)
sqlite3 (1.3.6)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
- activerecord (>= 3.0.0)
- activesupport (>= 3.0.0)
+ activerecord (>= 3.0.7)
+ activesupport (>= 3.0.7)
bcrypt-ruby
+ debugger
jeweler
rake
- ruby-debug19
sqlite3
@@ -65,7 +65,7 @@ def merge_validates_length_of_email_field_options(options = {})
# * <tt>Default:</tt> {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}}
# * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
def validates_format_of_email_field_options(value = nil)
- rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}})
+ rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => I18n.t('error_messages.email_invalid', :default => "should look like an email address.")})
end
alias_method :validates_format_of_email_field_options=, :validates_format_of_email_field_options
@@ -62,7 +62,7 @@ def merge_validates_length_of_login_field_options(options = {})
# * <tt>Default:</tt> {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}}
# * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
def validates_format_of_login_field_options(value = nil)
- rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}})
+ rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
end
alias_method :validates_format_of_login_field_options=, :validates_format_of_login_field_options
@@ -5,101 +5,101 @@ class LoginTest < ActiveSupport::TestCase
def test_login_field_config
assert_equal :login, User.login_field
assert_nil Employee.login_field
-
+
User.login_field = :nope
assert_equal :nope, User.login_field
User.login_field :login
assert_equal :login, User.login_field
end
-
+
def test_validate_login_field_config
assert User.validate_login_field
assert Employee.validate_login_field
-
+
User.validate_login_field = false
assert !User.validate_login_field
User.validate_login_field true
assert User.validate_login_field
end
-
+
def test_validates_length_of_login_field_options_config
assert_equal({:within => 3..100}, User.validates_length_of_login_field_options)
assert_equal({:within => 3..100}, Employee.validates_length_of_login_field_options)
-
+
User.validates_length_of_login_field_options = {:yes => "no"}
assert_equal({:yes => "no"}, User.validates_length_of_login_field_options)
User.validates_length_of_login_field_options({:within => 3..100})
assert_equal({:within => 3..100}, User.validates_length_of_login_field_options)
end
-
+
def test_validates_format_of_login_field_options_config
- default = {:with => /\A\w[\w\.+\-_@ ]+$/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
+ default = {:with => /\A\w[\w\.+\-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
assert_equal default, User.validates_format_of_login_field_options
assert_equal default, Employee.validates_format_of_login_field_options
-
+
User.validates_format_of_login_field_options = {:yes => "no"}
assert_equal({:yes => "no"}, User.validates_format_of_login_field_options)
User.validates_format_of_login_field_options default
assert_equal default, User.validates_format_of_login_field_options
end
-
+
def test_validates_uniqueness_of_login_field_options_config
default = {:case_sensitive => false, :scope => User.validations_scope, :if => "#{User.login_field}_changed?".to_sym}
assert_equal default, User.validates_uniqueness_of_login_field_options
-
+
User.validates_uniqueness_of_login_field_options = {:yes => "no"}
assert_equal({:yes => "no"}, User.validates_uniqueness_of_login_field_options)
User.validates_uniqueness_of_login_field_options default
assert_equal default, User.validates_uniqueness_of_login_field_options
end
-
+
def test_validates_length_of_login_field
u = User.new
u.login = "a"
assert !u.valid?
assert u.errors[:login].size > 0
-
+
u.login = "aaaaaaaaaa"
assert !u.valid?
assert u.errors[:login].size == 0
end
-
+
def test_validates_format_of_login_field
u = User.new
u.login = "fdsf@^&*"
assert !u.valid?
assert u.errors[:login].size > 0
-
+
u.login = "fdsfdsfdsfdsfs"
assert !u.valid?
assert u.errors[:login].size == 0
-
+
u.login = "dakota.dux+1@gmail.com"
assert !u.valid?
assert u.errors[:login].size == 0
end
-
+
def test_validates_uniqueness_of_login_field
u = User.new
u.login = "bjohnson"
assert !u.valid?
assert u.errors[:login].size > 0
-
+
u.login = "BJOHNSON"
assert !u.valid?
assert u.errors[:login].size > 0
-
+
u.login = "fdsfdsf"
assert !u.valid?
assert u.errors[:login].size == 0
end
-
+
def test_find_by_smart_case_login_field
ben = users(:ben)
assert_equal ben, User.find_by_smart_case_login_field("bjohnson")
assert_equal ben, User.find_by_smart_case_login_field("BJOHNSON")
assert_equal ben, User.find_by_smart_case_login_field("Bjohnson")
-
+
drew = employees(:drew)
assert_equal drew, Employee.find_by_smart_case_login_field("dgainor@binarylogic.com")
assert_equal drew, Employee.find_by_smart_case_login_field("Dgainor@binarylogic.com")

0 comments on commit 72b5d60

Please sign in to comment.