Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class User < Principal
end
end)

def normalized_mail_notification
mail_notification.presence || 'none'
end

def set_mail_notification
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
true
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_mail_notifications.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= select_tag(
'user[mail_notification]',
options_for_select(
user_mail_notification_options(@user), @user.mail_notification),
user_mail_notification_options(@user), @user.normalized_mail_notification),
:onchange => 'if (this.value == "selected") {$("#notified-projects").show();} else {$("#notified-projects").hide();}'
) %>
</p>
Expand Down
10 changes: 10 additions & 0 deletions test/functional/my_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ def test_my_account_should_not_show_language_select_with_force_default_language_
end
end

def test_my_account_should_show_no_events_email_notification_when_empty_mail_notification
user = User.find(2)
user.mail_notification = ''
user.save(validate: false)

get :account
assert_response :success
assert_select 'select[name=?] option[selected]', 'user[mail_notification]', text: 'No events'
end

def test_page_with_calendar
date = '2020-10-21'
subject = 'calendar on my page'
Expand Down