Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Column 'dmsf_mail_notification' cannot be null #1567

Merged
Merged
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: 3 additions & 1 deletion app/controllers/dmsf_state_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class DmsfStateController < ApplicationController
def user_pref_save
member = @project.members.find_by(user_id: User.current.id)
if member
member.dmsf_mail_notification = params[:email_notify]
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
Expand Down
25 changes: 23 additions & 2 deletions test/functional/dmsf_state_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,38 @@ def setup
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",
params: { email_notify: 1, title_format: '%t_%v', fast_links: 1, act_as_attachable: 1,
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_equal true, 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
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: { email_notify: 1, title_format: '%t_%v', fast_links: 1, act_as_attachable: 1,
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_equal true, member.dmsf_mail_notification
assert_not member.dmsf_mail_notification
assert_equal '%t_%v', member.dmsf_title_format
assert_equal true, member.dmsf_fast_links
@project1.reload
Expand Down
Loading