Patch #42467 ยป 0001-fix-Email-notification-value-in-my-account-when-empt.patch
| app/models/user.rb | ||
|---|---|---|
| 157 | 157 |
end |
| 158 | 158 |
end) |
| 159 | 159 | |
| 160 |
def normalized_mail_notification |
|
| 161 |
mail_notification.presence || 'none' |
|
| 162 |
end |
|
| 163 | ||
| 160 | 164 |
def set_mail_notification |
| 161 | 165 |
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank? |
| 162 | 166 |
true |
| app/views/users/_mail_notifications.html.erb | ||
|---|---|---|
| 3 | 3 |
<%= select_tag( |
| 4 | 4 |
'user[mail_notification]', |
| 5 | 5 |
options_for_select( |
| 6 |
user_mail_notification_options(@user), @user.mail_notification), |
|
| 6 |
user_mail_notification_options(@user), @user.normalized_mail_notification),
|
|
| 7 | 7 |
:onchange => 'if (this.value == "selected") {$("#notified-projects").show();} else {$("#notified-projects").hide();}'
|
| 8 | 8 |
) %> |
| 9 | 9 |
</p> |
| test/functional/my_controller_test.rb | ||
|---|---|---|
| 416 | 416 |
end |
| 417 | 417 |
end |
| 418 | 418 | |
| 419 |
def test_my_account_should_show_no_events_email_notification_when_empty_mail_notification |
|
| 420 |
user = User.find(2) |
|
| 421 |
user.mail_notification = '' |
|
| 422 |
user.save(validate: false) |
|
| 423 | ||
| 424 |
get :account |
|
| 425 |
assert_response :success |
|
| 426 |
assert_select 'select[name=?] option[selected]', 'user[mail_notification]', text: 'No events' |
|
| 427 |
end |
|
| 428 | ||
| 419 | 429 |
def test_page_with_calendar |
| 420 | 430 |
date = '2020-10-21' |
| 421 | 431 |
subject = 'calendar on my page' |