1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-24 01:11:12 +00:00

Adds the "Hide my email address" option on the registration form (#21500).

git-svn-id: http://svn.redmine.org/redmine/trunk@14976 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-12-13 15:39:09 +00:00
parent 1b5a4faf0c
commit f4c3700702
3 changed files with 33 additions and 0 deletions

View File

@ -122,6 +122,7 @@ class AccountController < ApplicationController
user_params = params[:user] || {}
@user = User.new
@user.safe_attributes = user_params
@user.pref.attributes = params[:pref] if params[:pref]
@user.admin = false
@user.register
if session[:auth_source_registration]

View File

@ -16,6 +16,10 @@
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<%= labelled_fields_for :pref, @user.pref do |pref_fields| %>
<p><%= pref_fields.check_box :hide_mail %></p>
<% end %>
<% unless @user.force_default_language? %>
<p><%= f.select :language, lang_options_for_select %></p>

View File

@ -247,6 +247,18 @@ class AccountControllerTest < ActionController::TestCase
end
end
def test_get_register_should_show_hide_mail_preference
get :register
assert_select 'input[name=?][checked=checked]', 'pref[hide_mail]'
end
def test_get_register_should_show_hide_mail_preference_with_setting_turned_off
with_settings :default_users_hide_mail => '0' do
get :register
assert_select 'input[name=?]:not([checked=checked])', 'pref[hide_mail]'
end
end
# See integration/account_test.rb for the full test
def test_post_register_with_registration_on
with_settings :self_registration => '3' do
@ -287,6 +299,22 @@ class AccountControllerTest < ActionController::TestCase
end
end
def test_post_register_should_create_user_with_hide_mail_preference
with_settings :default_users_hide_mail => '0' do
user = new_record(User) do
post :register, :user => {
:login => 'register',
:password => 'secret123', :password_confirmation => 'secret123',
:firstname => 'John', :lastname => 'Doe',
:mail => 'register@example.com'
}, :pref => {
:hide_mail => '1'
}
end
assert_equal true, user.pref.hide_mail
end
end
def test_get_lost_password_should_display_lost_password_form
get :lost_password
assert_response :success