##// END OF EJS Templates
More flexible mail notifications settings at user level. A user has now 3 options:...
Jean-Philippe Lang -
r842:90d33c3e518f
parent child
Show More
@@ -0,0 +1,8
1 <h3><%=l(:label_my_account)%></h3>
2
3 <p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
4 <%=l(:field_created_on)%>: <%= format_time(@user.created_on) %></p>
5 <% if @user.rss_token %>
6 <p><%= l(:label_feeds_access_key_created_on, distance_of_time_in_words(Time.now, @user.rss_token.created_on)) %>
7 (<%= link_to l(:button_reset), {:action => 'reset_rss_key'}, :method => :post %>)</p>
8 <% end %>
@@ -0,0 +1,22
1 <h2><%=l(:button_change_password)%></h2>
2
3 <%= error_messages_for 'user' %>
4
5 <% form_tag({}, :class => "tabular") do %>
6 <div class="box">
7 <p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
8 <%= password_field_tag 'password', nil, :size => 25 %></p>
9
10 <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
11 <%= password_field_tag 'new_password', nil, :size => 25 %><br />
12 <em><%= l(:text_length_between, 4, 12) %></em></p>
13
14 <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
15 <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
16 </div>
17 <%= submit_tag l(:button_apply) %>
18 <% end %>
19
20 <% content_for :sidebar do %>
21 <%= render :partial => 'sidebar' %>
22 <% end %>
@@ -0,0 +1,9
1 class AddMembersMailNotification < ActiveRecord::Migration
2 def self.up
3 add_column :members, :mail_notification, :boolean, :default => false, :null => false
4 end
5
6 def self.down
7 remove_column :members, :mail_notification
8 end
9 end
@@ -50,32 +50,44 class MyController < ApplicationController
50 50
51 51 # Edit user's account
52 52 def account
53 @user = self.logged_in_user
53 @user = User.current
54 54 @pref = @user.pref
55 @user.attributes = params[:user]
56 @user.pref.attributes = params[:pref]
57 if request.post? && @user.save && @user.pref.save
58 flash[:notice] = l(:notice_account_updated)
59 redirect_to :action => 'account'
55 if request.post?
56 @user.attributes = params[:user]
57 @user.mail_notification = (params[:notification_option] == 'all')
58 @user.pref.attributes = params[:pref]
59 if @user.save
60 @user.pref.save
61 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
62 set_language_if_valid @user.language
63 flash[:notice] = l(:notice_account_updated)
64 redirect_to :action => 'account'
65 return
66 end
60 67 end
68 @notification_options = [[l(:label_user_mail_option_all), 'all'],
69 [l(:label_user_mail_option_none), 'none']]
70 # Only users that belong to more than 1 project can select projects for which they are notified
71 # Note that @user.membership.size would fail since AR ignores :include association option when doing a count
72 @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1
73 @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
61 74 end
62 75
63 # Change user's password
64 def change_password
76 # Manage user's password
77 def password
65 78 @user = self.logged_in_user
66 79 flash[:error] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
67 if @user.check_password?(params[:password])
68 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
69 if @user.save
70 flash[:notice] = l(:notice_account_password_updated)
80 if request.post?
81 if @user.check_password?(params[:password])
82 @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
83 if @user.save
84 flash[:notice] = l(:notice_account_password_updated)
85 redirect_to :action => 'account'
86 end
71 87 else
72 render :action => 'account'
73 return
88 flash[:error] = l(:notice_account_wrong_password)
74 89 end
75 else
76 flash[:error] = l(:notice_account_wrong_password)
77 90 end
78 redirect_to :action => 'account'
79 91 end
80 92
81 93 # Create a new feeds key
@@ -143,6 +143,15 class Issue < ActiveRecord::Base
143 143 project.assignable_users
144 144 end
145 145
146 # Returns the mail adresses of users that should be notified for the issue
147 def recipients
148 recipients = project.recipients
149 # Author and assignee are always notified
150 recipients << author.mail if author
151 recipients << assigned_to.mail if assigned_to
152 recipients.compact.uniq
153 end
154
146 155 def spent_hours
147 156 @spent_hours ||= time_entries.sum(:hours) || 0
148 157 end
@@ -30,13 +30,7 class Mailer < ActionMailer::Base
30 30
31 31 def issue_add(issue)
32 32 set_language_if_valid(Setting.default_language)
33 # Sends to all project members
34 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
35 # Sends to author and assignee (even if they turned off mail notification)
36 @recipients << issue.author.mail if issue.author
37 @recipients << issue.assigned_to.mail if issue.assigned_to
38 @recipients.compact!
39 @recipients.uniq!
33 @recipients = issue.recipients
40 34 @from = Setting.mail_from
41 35 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
42 36 @body['issue'] = issue
@@ -44,14 +38,8 class Mailer < ActionMailer::Base
44 38
45 39 def issue_edit(journal)
46 40 set_language_if_valid(Setting.default_language)
47 # Sends to all project members
48 41 issue = journal.journalized
49 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
50 # Sends to author and assignee (even if they turned off mail notification)
51 @recipients << issue.author.mail if issue.author
52 @recipients << issue.assigned_to.mail if issue.assigned_to
53 @recipients.compact!
54 @recipients.uniq!
42 @recipients = issue.recipients
55 43 # Watchers in cc
56 44 @cc = issue.watcher_recipients - @recipients
57 45 @from = Setting.mail_from
@@ -62,7 +50,7 class Mailer < ActionMailer::Base
62 50
63 51 def document_added(document)
64 52 set_language_if_valid(Setting.default_language)
65 @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact
53 @recipients = document.project.recipients
66 54 @from = Setting.mail_from
67 55 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
68 56 @body['document'] = document
@@ -81,7 +69,7 class Mailer < ActionMailer::Base
81 69 url = {:only_path => false, :host => Setting.host_name, :controller => 'documents', :action => 'show', :id => container.id}
82 70 added_to = "#{l(:label_document)}: #{container.title}"
83 71 end
84 @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact
72 @recipients = container.project.recipients
85 73 @from = Setting.mail_from
86 74 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
87 75 @body['attachments'] = attachments
@@ -91,7 +79,7 class Mailer < ActionMailer::Base
91 79
92 80 def news_added(news)
93 81 set_language_if_valid(Setting.default_language)
94 @recipients = news.project.users.collect { |u| u.mail if u.mail_notification }.compact
82 @recipients = news.project.recipients
95 83 @from = Setting.mail_from
96 84 @subject = "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
97 85 @body['news'] = news
@@ -118,6 +118,11 class Project < ActiveRecord::Base
118 118 members.select {|m| m.role.assignable?}.collect {|m| m.user}
119 119 end
120 120
121 # Returns the mail adresses of users that should be always notified on project events
122 def recipients
123 members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user.mail}
124 end
125
121 126 # Returns an array of all custom fields enabled for project issues
122 127 # (explictly associated custom fields and custom fields enabled for all projects)
123 128 def custom_fields_for_issues(tracker)
@@ -50,6 +50,11 class User < ActiveRecord::Base
50 50 validates_confirmation_of :password, :allow_nil => true
51 51 validates_associated :custom_values, :on => :update
52 52
53 def before_create
54 self.mail_notification = false
55 true
56 end
57
53 58 def before_save
54 59 # update hashed_password if password was set
55 60 self.hashed_password = User.hash_password(self.password) if self.password
@@ -131,6 +136,18 class User < ActiveRecord::Base
131 136 token.value
132 137 end
133 138
139 # Return an array of project ids for which the user has explicitly turned mail notifications on
140 def notified_projects_ids
141 @notified_projects_ids ||= memberships.select {|m| m.mail_notification?}.collect(&:project_id)
142 end
143
144 def notified_project_ids=(ids)
145 Member.update_all("mail_notification = #{connection.quoted_false}", ['user_id = ?', id])
146 Member.update_all("mail_notification = #{connection.quoted_true}", ['user_id = ? AND project_id IN (?)', id, ids]) if ids && !ids.empty?
147 @notified_projects_ids = nil
148 notified_projects_ids
149 end
150
134 151 def self.find_by_rss_key(key)
135 152 token = Token.find_by_value(key)
136 153 token && token.user.active? ? token.user : nil
@@ -1,55 +1,41
1 <div class="contextual">
2 <%= link_to(l(:button_change_password), :action => 'password') unless @user.auth_source_id %>
3 </div>
1 4 <h2><%=l(:label_my_account)%></h2>
2
3 5 <%= error_messages_for 'user' %>
4 6
5 <div class="box">
7 <% form_for :user, @user, :url => { :action => "account" }, :builder => TabularFormBuilder, :lang => current_language do |f| %>
8 <div class="splitcontentleft">
6 9 <h3><%=l(:label_information_plural)%></h3>
7
8 <% labelled_tabular_form_for :user, @user, :url => { :action => "account" } do |f| %>
9
10 <div class="box tabular">
10 11 <p><%= f.text_field :firstname, :required => true %></p>
11 12 <p><%= f.text_field :lastname, :required => true %></p>
12 <p><%= f.text_field :mail, :required => true, :size => 40 %></p>
13 <p><%= f.text_field :mail, :required => true %></p>
13 14 <p><%= f.select :language, lang_options_for_select %></p>
14 <p><%= f.check_box :mail_notification %></p>
15 15
16 16 <% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
17 17 <p><%= pref_fields.check_box :hide_mail %></p>
18 18 <% end %>
19
20 <center><%= submit_tag l(:button_save) %></center>
21 <% end %>
22 19 </div>
23 20
21 <%= submit_tag l(:button_save) %>
22 </div>
24 23
25 <% unless @user.auth_source_id %>
26 <div class="box">
27 <h3><%=l(:field_password)%></h3>
28
29 <% form_tag({:action => 'change_password'}, :class => "tabular") do %>
30
31 <p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
32 <%= password_field_tag 'password', nil, :size => 25 %></p>
33
34 <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
35 <%= password_field_tag 'new_password', nil, :size => 25 %><br />
36 <em><%= l(:text_length_between, 4, 12) %></em></p>
37
38 <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
39 <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
40
41 <center><%= submit_tag l(:button_save) %></center>
42 <% end %>
43 </div>
24 <div class="splitcontentright">
25 <h3><%=l(:field_mail_notification)%></h3>
26 <div class="box">
27 <%= select_tag 'notification_option', options_for_select(@notification_options, @notification_option),
28 :onchange => 'if ($("notification_option").value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %>
29 <% content_tag 'div', :id => 'notified-projects', :style => (@notification_option == 'selected' ? '' : 'display:none;') do %>
30 <p><% User.current.projects.each do |project| %>
31 <label><%= check_box_tag 'notified_project_ids[]', project.id, @user.notified_projects_ids.include?(project.id) %> <%= project.name %></label><br />
32 <% end %></p>
33 <p><em><%= l(:text_user_mail_option) %></em></p>
34 <% end %>
35 </div>
36 </div>
44 37 <% end %>
45 38
46 39 <% content_for :sidebar do %>
47 <h3><%=l(:label_my_account)%></h3>
48
49 <p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
50 <%=l(:field_created_on)%>: <%= format_time(@user.created_on) %></p>
51 <% if @user.rss_token %>
52 <p><%= l(:label_feeds_access_key_created_on, distance_of_time_in_words(Time.now, @user.rss_token.created_on)) %>
53 (<%= link_to l(:button_reset), {:action => 'reset_rss_key'}, :method => :post %>)</p>
54 <% end %>
40 <%= render :partial => 'sidebar' %>
55 41 <% end %>
@@ -14,7 +14,6
14 14 <% end if @custom_values%>
15 15
16 16 <p><%= f.check_box :admin %></p>
17 <p><%= f.check_box :mail_notification %></p>
18 17 </div>
19 18
20 19 <div class="box">
@@ -284,7 +284,7 class Setup < ActiveRecord::Migration
284 284 Permission.create :controller => "versions", :action => "destroy_file", :description => "button_delete", :sort => 1322
285 285
286 286 # create default administrator account
287 user = User.create :firstname => "redMine", :lastname => "Admin", :mail => "admin@somenet.foo", :mail_notification => true, :language => "en"
287 user = User.create :firstname => "Redmine", :lastname => "Admin", :mail => "admin@somenet.foo", :mail_notification => true, :language => "en"
288 288 user.login = "admin"
289 289 user.password = "admin"
290 290 user.admin = true
@@ -526,3 +526,8 label_theme: Тема
526 526 label_default: По подразбиране
527 527 label_search_titles_only: Само в заглавията
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -127,7 +127,7 field_parent: Subproject of
127 127 field_is_in_chlog: Issues displayed in changelog
128 128 field_is_in_roadmap: Issues displayed in roadmap
129 129 field_login: Login
130 field_mail_notification: Mail notifications
130 field_mail_notification: Email notifications
131 131 field_admin: Administrator
132 132 field_last_login_on: Last connection
133 133 field_language: Language
@@ -174,7 +174,7 setting_login_required: Authent. required
174 174 setting_self_registration: Self-registration enabled
175 175 setting_attachment_max_size: Attachment max. size
176 176 setting_issues_export_limit: Issues export limit
177 setting_mail_from: Emission mail address
177 setting_mail_from: Emission email address
178 178 setting_host_name: Host name
179 179 setting_text_formatting: Text formatting
180 180 setting_wiki_compression: Wiki history compression
@@ -437,6 +437,9 label_bulk_edit_selected_issues: Bulk edit selected issues
437 437 label_theme: Theme
438 438 label_default: Default
439 439 label_search_titles_only: Search titles only
440 label_user_mail_option_all: "For any event on all my projects"
441 label_user_mail_option_selected: "For any event on the selected projects only..."
442 label_user_mail_option_none: "Only for things I watch or I'm involved in"
440 443
441 444 button_login: Login
442 445 button_submit: Submit
@@ -470,12 +473,13 button_archive: Archive
470 473 button_unarchive: Unarchive
471 474 button_reset: Reset
472 475 button_rename: Rename
476 button_change_password: Change password
473 477
474 478 status_active: active
475 479 status_registered: registered
476 480 status_locked: locked
477 481
478 text_select_mail_notifications: Select actions for which mail notifications should be sent.
482 text_select_mail_notifications: Select actions for which email notifications should be sent.
479 483 text_regexp_info: eg. ^[A-Z0-9]+$
480 484 text_min_max_length_info: 0 means no restriction
481 485 text_project_destroy_confirmation: Are you sure you want to delete this project and all related data ?
@@ -500,6 +504,7 text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and al
500 504 text_issue_category_destroy_question: Some issues (%d) are assigned to this category. What do you want to do ?
501 505 text_issue_category_destroy_assignments: Remove category assignments
502 506 text_issue_category_reassign_to: Reassign issues to this category
507 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
503 508
504 509 default_role_manager: Manager
505 510 default_role_developper: Developer
@@ -529,3 +529,8 label_theme: Theme
529 529 label_default: Default
530 530 label_search_titles_only: Search titles only
531 531 label_nobody: nobody
532 button_change_password: Change password
533 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
534 label_user_mail_option_selected: "For any event on the selected projects only..."
535 label_user_mail_option_all: "For any event on all my projects"
536 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -437,6 +437,9 label_bulk_edit_selected_issues: Modifier les demandes sélectionnées
437 437 label_theme: Thème
438 438 label_default: Défaut
439 439 label_search_titles_only: Uniquement dans les titres
440 label_user_mail_option_all: "Pour tous les événements de tous mes projets"
441 label_user_mail_option_selected: "Pour tous les événements des projets sélectionnés..."
442 label_user_mail_option_none: "Seulement pour ce que je surveille ou à quoi je participe"
440 443
441 444 button_login: Connexion
442 445 button_submit: Soumettre
@@ -470,6 +473,7 button_archive: Archiver
470 473 button_unarchive: Désarchiver
471 474 button_reset: Réinitialiser
472 475 button_rename: Renommer
476 button_change_password: Changer de mot de passe
473 477
474 478 status_active: actif
475 479 status_registered: enregistré
@@ -500,6 +504,7 text_wiki_destroy_confirmation: Etes-vous sûr de vouloir supprimer ce wiki et t
500 504 text_issue_category_destroy_question: Des demandes (%d) sont affectées à cette catégories. Que voulez-vous faire ?
501 505 text_issue_category_destroy_assignments: N'affecter les demandes à aucune autre catégorie
502 506 text_issue_category_reassign_to: Réaffecter les demandes à cette catégorie
507 text_user_mail_option: "Pour les projets non sélectionnés, vous recevrez seulement des notifications pour ce que vous surveillez ou à quoi vous participez (exemple: demandes dont vous êtes l'auteur ou la personne assignée)."
503 508
504 509 default_role_manager: Manager
505 510 default_role_developper: Développeur
@@ -526,3 +526,8 enumeration_doc_categories: קטגוריות מסמכים
526 526 enumeration_activities: פעילויות (מעקב אחר זמנים)
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -527,3 +527,8 label_theme: テーマ
527 527 label_default: 既定
528 528 label_search_titles_only: Search titles only
529 529 label_nobody: nobody
530 button_change_password: Change password
531 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
532 label_user_mail_option_selected: "For any event on the selected projects only..."
533 label_user_mail_option_all: "For any event on all my projects"
534 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -527,3 +527,8 label_theme: Theme
527 527 label_default: Default
528 528 label_search_titles_only: Search titles only
529 529 label_nobody: nobody
530 button_change_password: Change password
531 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
532 label_user_mail_option_selected: "For any event on the selected projects only..."
533 label_user_mail_option_all: "For any event on all my projects"
534 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Temat
526 526 label_default: Domyślne
527 527 label_search_titles_only: Przeszukuj tylko tytuły
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -526,3 +526,8 label_theme: Theme
526 526 label_default: Default
527 527 label_search_titles_only: Search titles only
528 528 label_nobody: nobody
529 button_change_password: Change password
530 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
531 label_user_mail_option_selected: "For any event on the selected projects only..."
532 label_user_mail_option_all: "For any event on all my projects"
533 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -527,3 +527,8 label_theme: Theme
527 527 label_default: Default
528 528 label_search_titles_only: Search titles only
529 529 label_nobody: nobody
530 button_change_password: Change password
531 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
532 label_user_mail_option_selected: "For any event on the selected projects only..."
533 label_user_mail_option_all: "For any event on all my projects"
534 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -529,3 +529,8 label_theme: Theme
529 529 label_default: Default
530 530 label_search_titles_only: Search titles only
531 531 label_nobody: nobody
532 button_change_password: Change password
533 text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
534 label_user_mail_option_selected: "For any event on the selected projects only..."
535 label_user_mail_option_all: "For any event on all my projects"
536 label_user_mail_option_none: "Only for things I watch or I'm involved in"
@@ -116,6 +116,7 textarea.wiki-edit { width: 99%; }
116 116 li p {margin-top: 0;}
117 117 div.issue {background:#ffffdd; padding:6px; margin-bottom:6px;border: 1px solid #d7d7d7;}
118 118 .autoscroll {overflow-x: auto; padding:1px; width:100%;}
119 #user_firstname, #user_lastname, #user_mail, #notification_option { width: 90%; }
119 120
120 121 /***** Tabular forms ******/
121 122 .tabular p{
@@ -61,29 +61,30 class MyControllerTest < Test::Unit::TestCase
61 61 end
62 62
63 63 def test_change_password
64 get :account
64 get :password
65 65 assert_response :success
66 assert_template 'account'
66 assert_template 'password'
67 67
68 68 # non matching password confirmation
69 post :change_password, :password => 'jsmith',
70 :new_password => 'hello',
71 :new_password_confirmation => 'hello2'
69 post :password, :password => 'jsmith',
70 :new_password => 'hello',
71 :new_password_confirmation => 'hello2'
72 72 assert_response :success
73 assert_template 'account'
73 assert_template 'password'
74 74 assert_tag :tag => "div", :attributes => { :class => "errorExplanation" }
75 75
76 76 # wrong password
77 post :change_password, :password => 'wrongpassword',
78 :new_password => 'hello',
79 :new_password_confirmation => 'hello'
80 assert_redirected_to 'my/account'
77 post :password, :password => 'wrongpassword',
78 :new_password => 'hello',
79 :new_password_confirmation => 'hello'
80 assert_response :success
81 assert_template 'password'
81 82 assert_equal 'Wrong password', flash[:error]
82 83
83 84 # good password
84 post :change_password, :password => 'jsmith',
85 :new_password => 'hello',
86 :new_password_confirmation => 'hello'
85 post :password, :password => 'jsmith',
86 :new_password => 'hello',
87 :new_password_confirmation => 'hello'
87 88 assert_redirected_to 'my/account'
88 89 assert User.try_to_login('jsmith', 'hello')
89 90 end
@@ -105,4 +105,28 class UserTest < Test::Unit::TestCase
105 105 # user with no role
106 106 assert !@dlopper.role_for_project(Project.find(2)).member?
107 107 end
108
109 def test_mail_notification_all
110 @jsmith.mail_notification = true
111 @jsmith.notified_project_ids = []
112 @jsmith.save
113 @jsmith.reload
114 assert @jsmith.projects.first.recipients.include?(@jsmith.mail)
115 end
116
117 def test_mail_notification_selected
118 @jsmith.mail_notification = false
119 @jsmith.notified_project_ids = [@jsmith.projects.first.id]
120 @jsmith.save
121 @jsmith.reload
122 assert @jsmith.projects.first.recipients.include?(@jsmith.mail)
123 end
124
125 def test_mail_notification_none
126 @jsmith.mail_notification = false
127 @jsmith.notified_project_ids = []
128 @jsmith.save
129 @jsmith.reload
130 assert !@jsmith.projects.first.recipients.include?(@jsmith.mail)
131 end
108 132 end
General Comments 0
You need to be logged in to leave comments. Login now