Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:danmunn/redmine_dmsf into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Nov 25, 2024
2 parents 48da190 + 5412ab1 commit bffe457
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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

0 comments on commit bffe457

Please sign in to comment.