Project

General

Profile

Defect #39854 ยป defect-39854.patch

Mizuki ISHIKAWA, 2023-12-15 05:48

View differences:

app/models/user.rb
MAIL_NOTIFICATION_OPTIONS = [
['all', :label_user_mail_option_all],
['selected', :label_user_mail_option_selected],
['bookmarked', :label_user_mail_option_bookmarked],
['bookmarked', :label_user_mail_option_bookmarked_my_projects],
['only_my_events', :label_user_mail_option_only_my_events],
['only_assigned', :label_user_mail_option_only_assigned],
['only_owner', :label_user_mail_option_only_owner],
config/locales/en.yml
label_search_titles_only: Search titles only
label_user_mail_option_all: "For any event on all my projects"
label_user_mail_option_selected: "For any event on the selected projects only..."
label_user_mail_option_bookmarked: "For any event on my bookmarked projects"
label_user_mail_option_bookmarked_my_projects: "For any events on bookmarked my projects"
label_user_mail_option_none: "No events"
label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
label_user_mail_option_only_assigned: "Only for things I watch or I am assigned to"
test/unit/project_test.rb
only_my_events_user = User.generate!(:mail_notification => 'only_my_events')
Member.create!(:project => project, :roles => [role], :principal => only_my_events_user)
bookmarked_user = User.generate!(:mail_notification => 'bookmarked')
Member.create!(:project => project, :roles => [role], :principal => bookmarked_user)
bookmarked_and_member_user = User.generate!(:mail_notification => 'bookmarked')
Member.create!(:project => project, :roles => [role], :principal => bookmarked_and_member_user)
pjb = Redmine::ProjectJumpBox.new bookmarked_and_member_user
pjb.bookmark_project project
bookmarked_and_member_user.update_notified_bookmarked_project_ids(project)
bookmarked_and_nonmember_user = User.generate!(:mail_notification => 'bookmarked')
pjb = Redmine::ProjectJumpBox.new bookmarked_and_nonmember_user
pjb.bookmark_project project
bookmarked_and_member_user.update_notified_bookmarked_project_ids(project)
only_assigned_user = User.generate!(:mail_notification => 'only_assigned')
Member.create!(:project => project, :roles => [role], :principal => only_assigned_user)
......
"should not include users with the 'none' notification option"
assert !project.notified_users.include?(only_my_events_user),
"should not include users with the 'only_my_events' notification option"
assert !project.notified_users.include?(bookmarked_user),
"should not include users with the 'bookmarked' notification option"
assert project.notified_users.include?(bookmarked_and_member_user),
"should include users with the 'bookmarked' notification option"
assert !project.notified_users.include?(bookmarked_and_nonmember_user),
"should not include member users with the 'bookmarked' notification option"
assert !project.notified_users.include?(only_assigned_user),
"should not include users with the 'only_assigned' notification option"
"should not include non-member users with the 'only_assigned' notification option"
assert !project.notified_users.include?(only_owned_user),
"should not include users with the 'only_owner' notification option"
end
    (1-1/1)