additionals/test/functional/account_controller_test.rb

68 lines
2.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
2016-12-02 12:45:12 +01:00
2018-07-15 13:14:41 +02:00
class AccountControllerTest < Additionals::ControllerTest
2020-07-27 10:49:23 +02:00
fixtures :users, :groups_users, :email_addresses, :user_preferences,
:roles, :members, :member_roles,
:issues, :issue_statuses, :issue_relations,
:issues, :issue_statuses, :issue_categories,
:versions, :trackers,
:projects, :projects_trackers, :enabled_modules,
:enumerations
2016-12-02 12:45:12 +01:00
2024-09-25 10:10:02 +02:00
fixtures :hrm_user_types, :hrm_working_calendars if AdditionalsPlugin.active_hrm?
2016-12-02 12:45:12 +01:00
def setup
Setting.default_language = 'en'
User.current = nil
end
def test_get_login_with_welcome_text
change_plugin_settings 'additionals', account_login_bottom: 'Lore impsuum'
2020-07-27 10:49:23 +02:00
get :login
2022-10-30 17:08:52 +01:00
2020-07-27 10:49:23 +02:00
assert_response :success
assert_select 'input[name=username]'
assert_select 'input[name=password]'
assert_select 'div.login-additionals', text: /Lore impsuum/
2016-12-02 12:45:12 +01:00
end
def test_get_login_without_welcome_text
change_plugin_settings 'additionals', account_login_bottom: ''
2020-07-27 10:49:23 +02:00
get :login
2022-10-30 17:08:52 +01:00
2020-07-27 10:49:23 +02:00
assert_response :success
assert_select 'input[name=username]'
assert_select 'input[name=password]'
assert_select 'div.login-additionals', count: 0
2016-12-02 12:45:12 +01:00
end
# See integration/account_test.rb for the full test
def test_post_register_with_registration_on
with_settings self_registration: '3' do
assert_difference 'User.count' do
2018-05-03 20:18:55 +02:00
post :register,
params: { user: { login: 'register',
password: 'secret123',
password_confirmation: 'secret123',
firstname: 'John',
lastname: 'Doe',
mail: 'register@example.com' } }
2022-10-30 17:08:52 +01:00
assert_redirected_to '/my/account'
end
2021-07-31 08:53:54 +02:00
user = User.last
2022-10-30 17:08:52 +01:00
assert_equal 'register', user.login
assert_equal 'John', user.firstname
assert_equal 'Doe', user.lastname
assert_equal 'register@example.com', user.mail
assert user.check_password?('secret123')
assert user.active?
end
end
2016-12-02 12:45:12 +01:00
end