require "test_helper"
class UserCreationTest < ActionDispatch::IntegrationTest
- fixtures :users
-
def setup
I18n.locale = "en"
def test_user_create_submit_duplicate_email
I18n.available_locales.each do |locale|
- dup_email = users(:public_user).email
+ dup_email = create(:user).email
display_name = "#{locale}_new_tester"
assert_difference("User.count", 0) do
assert_difference("ActionMailer::Base.deliveries.size", 0) do
def test_user_create_submit_duplicate_username
I18n.available_locales.each do |locale|
- dup_display_name = users(:public_user).display_name
+ dup_display_name = create(:user).display_name
email = "#{locale}_new_tester"
assert_difference("User.count", 0) do
assert_difference("ActionMailer::Base.deliveries.size", 0) do
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
assert_match /#{@url}/, register_email.body.to_s
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_openid/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_google/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_facebook/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
follow_redirect!
assert_response :redirect
- assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
+ assert_redirected_to auth_success_path(:provider => "windowslive")
follow_redirect!
assert_response :redirect
assert_redirected_to "/user/terms"
assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
follow_redirect!
assert_response :redirect
- assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
+ assert_redirected_to auth_success_path(:provider => "windowslive")
follow_redirect!
assert_response :redirect
assert_redirected_to auth_failure_path(:strategy => "windowslive", :message => "connection_failed", :origin => "/user/new")
assert_redirected_to auth_path(:provider => "windowslive", :origin => "/user/new")
follow_redirect!
assert_response :redirect
- assert_redirected_to auth_success_path(:provider => "windowslive", :origin => "/user/new")
+ assert_redirected_to auth_success_path(:provider => "windowslive")
follow_redirect!
assert_response :redirect
assert_redirected_to "/user/terms"
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_windowslive/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_github/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success
# Check the e-mail
register_email = ActionMailer::Base.deliveries.first
- assert_equal register_email.to[0], new_email
+ assert_equal register_email.to.first, new_email
# Check that the confirm account url is correct
confirm_regex = Regexp.new("/user/redirect_tester_wikipedia/confirm\\?confirm_string=([a-zA-Z0-9]*)")
- register_email.parts.each do |part|
+ email_text_parts(register_email).each do |part|
assert_match confirm_regex, part.body.to_s
end
- confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
+ confirm_string = email_text_parts(register_email).first.body.match(confirm_regex)[1]
# Check the page
assert_response :success