Merge pull request #4557 from tgxworld/allow_date_of_birth

FEATURE: Allow date_of_field column to be updated.
This commit is contained in:
Guo Xiang Tan 2016-11-17 09:18:33 +01:00 committed by GitHub
commit 0bc84426b6
4 changed files with 8 additions and 3 deletions

View File

@ -211,7 +211,8 @@ const User = RestModel.extend({
'muted_tags', 'muted_tags',
'tracked_tags', 'tracked_tags',
'watched_tags', 'watched_tags',
'watching_first_post_tags'); 'watching_first_post_tags',
'date_of_birth');
['email_always', ['email_always',
'mailing_list_mode', 'mailing_list_mode',

View File

@ -706,7 +706,7 @@ class UsersController < ApplicationController
end end
def user_params def user_params
result = params.permit(:name, :email, :password, :username) result = params.permit(:name, :email, :password, :username, :date_of_birth)
.merge(ip_address: request.remote_ip, .merge(ip_address: request.remote_ip,
registration_ip_address: request.remote_ip, registration_ip_address: request.remote_ip,
locale: user_locale) locale: user_locale)

View File

@ -54,6 +54,7 @@ class UserUpdater
user.name = attributes.fetch(:name) { user.name } user.name = attributes.fetch(:name) { user.name }
user.locale = attributes.fetch(:locale) { user.locale } user.locale = attributes.fetch(:locale) { user.locale }
user.date_of_birth = attributes.fetch(:date_of_birth) { user.date_of_birth }
if guardian.can_grant_title?(user) if guardian.can_grant_title?(user)
user.title = attributes.fetch(:title) { user.title } user.title = attributes.fetch(:title) { user.title }

View File

@ -64,6 +64,7 @@ describe UserUpdater do
it 'updates various fields' do it 'updates various fields' do
user = Fabricate(:user) user = Fabricate(:user)
updater = UserUpdater.new(acting_user, user) updater = UserUpdater.new(acting_user, user)
date_of_birth = Time.zone.now
val = updater.update(bio_raw: 'my new bio', val = updater.update(bio_raw: 'my new bio',
email_always: 'true', email_always: 'true',
@ -72,7 +73,8 @@ describe UserUpdater do
new_topic_duration_minutes: 100, new_topic_duration_minutes: 100,
auto_track_topics_after_msecs: 101, auto_track_topics_after_msecs: 101,
notification_level_when_replying: 3, notification_level_when_replying: 3,
email_in_reply_to: false email_in_reply_to: false,
date_of_birth: date_of_birth
) )
expect(val).to be_truthy expect(val).to be_truthy
@ -86,6 +88,7 @@ describe UserUpdater do
expect(user.user_option.auto_track_topics_after_msecs).to eq 101 expect(user.user_option.auto_track_topics_after_msecs).to eq 101
expect(user.user_option.notification_level_when_replying).to eq 3 expect(user.user_option.notification_level_when_replying).to eq 3
expect(user.user_option.email_in_reply_to).to eq false expect(user.user_option.email_in_reply_to).to eq false
expect(user.date_of_birth).to eq(date_of_birth.to_date)
end end
context 'when sso overrides bio' do context 'when sso overrides bio' do