FEATURE: Allow date_of_field column to be updated.

This commit is contained in:
Guo Xiang Tan 2016-11-15 16:10:20 +08:00
parent 8c6d8c85db
commit f824afb4d3
4 changed files with 8 additions and 3 deletions

View File

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

View File

@ -706,7 +706,7 @@ class UsersController < ApplicationController
end
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,
registration_ip_address: request.remote_ip,
locale: user_locale)

View File

@ -54,6 +54,7 @@ class UserUpdater
user.name = attributes.fetch(:name) { user.name }
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)
user.title = attributes.fetch(:title) { user.title }

View File

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