Fixes Column 'dmsf_mail_notification' cannot be null
The partial app/views/dmsf_state/_user_pref.html.erb uses a condition to include the email_notify setting only if the corresponding notified_event is enabled. The database field email_notify, however, does not accept a null value. But this is what occurs when the notified event is disabled. This patch changes the DmsfStateController to assign params[:email_notify] only if the notified_event for dmsf_legacy_notifications is enabled.
This commit is contained in:
parent
fa62c09d87
commit
77df49993c
@ -28,7 +28,9 @@ class DmsfStateController < ApplicationController
|
||||
def user_pref_save
|
||||
member = @project.members.find_by(user_id: User.current.id)
|
||||
if member
|
||||
if Setting.notified_events.include?('dmsf_legacy_notifications')
|
||||
member.dmsf_mail_notification = params[:email_notify]
|
||||
end
|
||||
member.dmsf_title_format = params[:title_format]
|
||||
member.dmsf_fast_links = params[:fast_links].present?
|
||||
if format_valid?(member.dmsf_title_format) && member.save
|
||||
|
||||
@ -32,6 +32,7 @@ class DmsfStateControllerTest < RedmineDmsf::Test::TestCase
|
||||
end
|
||||
|
||||
def test_user_pref_save_member
|
||||
with_settings notified_events: ['dmsf_legacy_notifications'] do
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@role_manager.add_permission! :user_preferences
|
||||
post "/projects/#{@project1.id}/dmsf/state",
|
||||
@ -49,6 +50,26 @@ class DmsfStateControllerTest < RedmineDmsf::Test::TestCase
|
||||
assert_equal 1, @project1.dmsf_act_as_attachable
|
||||
assert_equal @query401.id, @project1.default_dmsf_query_id
|
||||
end
|
||||
end
|
||||
|
||||
def test_user_pref_save_whithout_email_notification_settings
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@role_manager.add_permission! :user_preferences
|
||||
post "/projects/#{@project1.id}/dmsf/state",
|
||||
params: { title_format: '%t_%v', fast_links: 1, act_as_attachable: 2,
|
||||
default_dmsf_query: @query401.id }
|
||||
assert_redirected_to settings_project_path(@project1, tab: 'dmsf')
|
||||
assert_not_nil flash[:notice]
|
||||
assert_equal flash[:notice], l(:notice_your_preferences_were_saved)
|
||||
member = @project1.members.find_by(user_id: @jsmith.id)
|
||||
assert member
|
||||
assert_not member.dmsf_mail_notification
|
||||
assert_equal '%t_%v', member.dmsf_title_format
|
||||
assert_equal true, member.dmsf_fast_links
|
||||
@project1.reload
|
||||
assert_equal 1, @project1.dmsf_act_as_attachable
|
||||
assert_equal @query401.id, @project1.default_dmsf_query_id
|
||||
end
|
||||
|
||||
def test_user_pref_save_member_forbidden
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user