mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
31 lines
688 B
Ruby
31 lines
688 B
Ruby
class ActiveSupport::TestCase
|
|
def setup_mailer
|
|
ActionMailer::Base.deliveries = []
|
|
end
|
|
|
|
# Helpers for creating new users
|
|
#
|
|
def generate_unique_email
|
|
@@email_count ||= 0
|
|
@@email_count += 1
|
|
"test#{@@email_count}@email.com"
|
|
end
|
|
|
|
def valid_attributes(attributes={})
|
|
{ :email => generate_unique_email,
|
|
:password => '123456',
|
|
:password_confirmation => '123456' }.update(attributes)
|
|
end
|
|
|
|
def new_user(attributes={})
|
|
User.new(valid_attributes(attributes))
|
|
end
|
|
|
|
def create_user(attributes={})
|
|
User.create!(valid_attributes(attributes))
|
|
end
|
|
|
|
def field_accessible?(field)
|
|
new_user(field => 'test').send(field) == 'test'
|
|
end
|
|
end
|