fixing functional tests
This commit is contained in:
18
test/unit/maintenance/user/login_reminder_mailer_test.rb
Normal file
18
test/unit/maintenance/user/login_reminder_mailer_test.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require "test_helper"
|
||||
|
||||
module Maintenance
|
||||
module User
|
||||
class LoginReminderMailerTest < ActionMailer::TestCase
|
||||
context "The login reminder mailer" do
|
||||
setup do
|
||||
@user = Factory.create(:user)
|
||||
end
|
||||
|
||||
should "send the notie" do
|
||||
LoginReminderMailer.notice(@user).deliver
|
||||
assert !ActionMailer::Base.deliveries.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
48
test/unit/user_password_reset_nonce_test.rb
Normal file
48
test/unit/user_password_reset_nonce_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UserPasswordResetNonceTest < ActiveSupport::TestCase
|
||||
context "Creating a new nonce" do
|
||||
context "with a valid email" do
|
||||
setup do
|
||||
@user = Factory.create(:user, :email => "aaa@b.net")
|
||||
@nonce = Factory.create(:user_password_reset_nonce, :email => @user.email)
|
||||
end
|
||||
|
||||
should "validate" do
|
||||
assert_equal([], @nonce.errors.full_messages)
|
||||
end
|
||||
|
||||
should "populate the key with a random string" do
|
||||
assert_equal(32, @nonce.key.size)
|
||||
end
|
||||
|
||||
should "reset the password when reset" do
|
||||
@nonce.user.expects(:reset_password_and_deliver_notice)
|
||||
@nonce.reset_user!
|
||||
end
|
||||
end
|
||||
|
||||
context "with a blank email" do
|
||||
setup do
|
||||
@user = Factory.create(:user, :email => "")
|
||||
@nonce = UserPasswordResetNonce.new(:email => "")
|
||||
end
|
||||
|
||||
should "not validate" do
|
||||
@nonce.save
|
||||
assert_equal(["Email can't be blank", "Email is invalid"], @nonce.errors.full_messages.sort)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an invalid email" do
|
||||
setup do
|
||||
@nonce = UserPasswordResetNonce.new(:email => "z@z.net")
|
||||
end
|
||||
|
||||
should "not validate" do
|
||||
@nonce.save
|
||||
assert_equal(["Email is invalid"], @nonce.errors.full_messages)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user