From: John Dong Date: Wed, 29 Aug 2007 21:51:48 +0000 (-0400) Subject: Fix testcases and also fix errors the testcase brought up X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/5ccb47e8c8b3c782147b9f0ca7c45fc4dd5d034c?ds=sidebyside;hp=-c Fix testcases and also fix errors the testcase brought up --- 5ccb47e8c8b3c782147b9f0ca7c45fc4dd5d034c diff --git a/app/models/user.rb b/app/models/user.rb index eca592d..728ca16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -72,7 +72,7 @@ class User < ActiveRecord::Base # Stolen from http://www.regular-expressions.info/email.html errors.add(:email, "is not valid") unless email =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i - errors.add(:login, "should not begin or end with spaces") if login.strip! + errors.add(:login, "should not begin or end with spaces") if login and login.strip! errors.add(:login, "should contain only letters, numbers, and spaces") unless login =~ /^[A-Za-z0-9 ]*$/ end end diff --git a/test/functional/quickvote_controller_test.rb b/test/functional/quickvote_controller_test.rb index ee79b3f..fbeb4a5 100644 --- a/test/functional/quickvote_controller_test.rb +++ b/test/functional/quickvote_controller_test.rb @@ -43,19 +43,19 @@ class QuickvoteControllerTest < Test::Unit::TestCase def test_create_quickvote_badname post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => ["foo", "bar", "foobar"]}) - assert_template "quickvote/create" + assert_template "quickvote/_create_sidebar" end def test_create_quickvote_dupe_candidate post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => ["foo", "bar", "bar", "foobar"]}) - assert_template "quickvote/create" + assert_template "quickvote/_create_sidebar" end def test_create_quickvote_nil_candidate post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => nil}) - assert_template "quickvote/create" + assert_template "quickvote/_create_sidebar" post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => []}) - assert_template "quickvote/create" + assert_template "quickvote/_create_sidebar" end def test_get_quickvote_nonexistent