password field supports placeholder, too

This commit is contained in:
Tony Pitale 2010-11-07 12:24:14 +08:00 committed by José Valim
parent cee443c2c6
commit 23ef40e5b4
3 changed files with 20 additions and 16 deletions

View File

@ -31,23 +31,22 @@ GEM
arel (1.0.1)
activesupport (~> 3.0.0)
builder (2.1.2)
columnize (0.3.1)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
linecache (0.43)
mail (2.2.5)
i18n (0.4.2)
mail (2.2.9)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
i18n (~> 0.4.1)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.8)
mocha (0.9.9)
rake
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
@ -63,12 +62,8 @@ GEM
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
thor (0.14.0)
test-unit (2.1.1)
thor (0.14.4)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
@ -79,4 +74,4 @@ PLATFORMS
DEPENDENCIES
mocha
rails (= 3.0.0)
ruby-debug
test-unit

View File

@ -26,7 +26,11 @@ module SimpleForm
end
def has_placeholder?
text? && super
(text? || password?) && super
end
def password?
input_type == :password
end
def text?

View File

@ -204,6 +204,11 @@ class InputTest < ActionView::TestCase
assert_select 'input[type=password].password#user_password'
end
test 'input should generate a password field for password attributes that accept placeholder' do
with_input_for @user, :password, :password, :placeholder => 'Password Confirmation'
assert_select 'input[type=password].password[placeholder=Password Confirmation]#user_password'
end
test 'input should generate a file field' do
with_input_for @user, :name, :file
assert_select 'input#user_name[type=file]'