forked from fixin.me/fixin.me
Test "register"
This commit is contained in:
parent
cc857a74bf
commit
5615113b9f
@ -78,3 +78,10 @@ possibly with different Ruby versions:
|
||||
Use `RAILS_ENV="development"` for rake commands and running rails server.
|
||||
|
||||
Use `RAILS_ENV="test"` for running tests.
|
||||
|
||||
|
||||
### Running tests
|
||||
|
||||
Single test:
|
||||
|
||||
bin/rails test test/system/users_test.rb --name test_register
|
||||
|
@ -27,6 +27,21 @@ class UsersTest < ApplicationSystemTestCase
|
||||
assert_text t('devise.failure.invalid', authentication_keys: User.human_attribute_name(:email))
|
||||
end
|
||||
|
||||
# TODO: require e-mail confirmation on registration
|
||||
test "register" do
|
||||
visit new_user_session_url
|
||||
click_link t(:register)
|
||||
fill_in User.human_attribute_name(:email).capitalize, with: random_email
|
||||
password = random_password
|
||||
fill_in User.human_attribute_name(:password).capitalize, with: password
|
||||
fill_in t('users.registrations.new.password_confirmation'), with: password
|
||||
assert_difference ->{User.count}, 1 do
|
||||
click_on t(:register)
|
||||
end
|
||||
assert_no_current_path new_user_registration_path
|
||||
assert_text t('devise.registrations.signed_up')
|
||||
end
|
||||
|
||||
#test "visiting the index" do
|
||||
# visit users_url
|
||||
# assert_selector "h1", text: "Users"
|
||||
|
@ -18,4 +18,8 @@ class ActiveSupport::TestCase
|
||||
def random_password
|
||||
SecureRandom.alphanumeric rand(Rails.configuration.devise.password_length)
|
||||
end
|
||||
|
||||
def random_email
|
||||
"%s@%s.%s" % (1..3).map { SecureRandom.alphanumeric(rand(1..20)) }
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user