@@ -0,0 +1,2 | |||||
|
1 | <p><%= l(:notice_account_activated) %></p> | |||
|
2 | <p><%= l(:label_login) %>: <%= link_to @login_url, @login_url %></p> |
@@ -75,7 +75,11 class UsersController < ApplicationController | |||||
75 | @user.admin = params[:user][:admin] if params[:user][:admin] |
|
75 | @user.admin = params[:user][:admin] if params[:user][:admin] | |
76 | @user.login = params[:user][:login] if params[:user][:login] |
|
76 | @user.login = params[:user][:login] if params[:user][:login] | |
77 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id |
|
77 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id | |
78 |
|
|
78 | @user.attributes = params[:user] | |
|
79 | # Was the account actived ? (do it before User#save clears the change) | |||
|
80 | was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) | |||
|
81 | if @user.save | |||
|
82 | Mailer.deliver_account_activated(@user) if was_activated | |||
79 | flash[:notice] = l(:notice_successful_update) |
|
83 | flash[:notice] = l(:notice_successful_update) | |
80 | # Give a string to redirect_to otherwise it would use status param as the response code |
|
84 | # Give a string to redirect_to otherwise it would use status param as the response code | |
81 | redirect_to(url_for(:action => 'list', :status => params[:status], :page => params[:page])) |
|
85 | redirect_to(url_for(:action => 'list', :status => params[:status], :page => params[:page])) |
@@ -163,10 +163,17 class MailHandler < ActionMailer::Base | |||||
163 | end |
|
163 | end | |
164 |
|
164 | |||
165 | def get_keyword(attr, options={}) |
|
165 | def get_keyword(attr, options={}) | |
166 | if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i |
|
166 | @keywords ||= {} | |
167 | $1.strip |
|
167 | if @keywords.has_key?(attr) | |
168 | elsif !@@handler_options[:issue][attr].blank? |
|
168 | @keywords[attr] | |
169 | @@handler_options[:issue][attr] |
|
169 | else | |
|
170 | @keywords[attr] = begin | |||
|
171 | if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '') | |||
|
172 | $1.strip | |||
|
173 | elsif !@@handler_options[:issue][attr].blank? | |||
|
174 | @@handler_options[:issue][attr] | |||
|
175 | end | |||
|
176 | end | |||
170 | end |
|
177 | end | |
171 | end |
|
178 | end | |
172 |
|
179 |
@@ -127,6 +127,15 class Mailer < ActionMailer::Base | |||||
127 | :url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc') |
|
127 | :url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc') | |
128 | end |
|
128 | end | |
129 |
|
129 | |||
|
130 | # A registered user's account was activated by an administrator | |||
|
131 | def account_activated(user) | |||
|
132 | set_language_if_valid user.language | |||
|
133 | recipients user.mail | |||
|
134 | subject l(:mail_subject_register, Setting.app_title) | |||
|
135 | body :user => user, | |||
|
136 | :login_url => url_for(:controller => 'account', :action => 'login') | |||
|
137 | end | |||
|
138 | ||||
130 | def lost_password(token) |
|
139 | def lost_password(token) | |
131 | set_language_if_valid(token.user.language) |
|
140 | set_language_if_valid(token.user.language) | |
132 | recipients token.user.mail |
|
141 | recipients token.user.mail |
@@ -5,6 +5,12 Copyright (C) 2006-2009 Jean-Philippe Lang | |||||
5 | http://www.redmine.org/ |
|
5 | http://www.redmine.org/ | |
6 |
|
6 | |||
7 |
|
7 | |||
|
8 | == 2009-xx-xx v0.8.2 | |||
|
9 | ||||
|
10 | * Send an email to the user when an administrator activates a registered user | |||
|
11 | * Strip keywords from received email body | |||
|
12 | ||||
|
13 | ||||
8 | == 2009-02-15 v0.8.1 |
|
14 | == 2009-02-15 v0.8.1 | |
9 |
|
15 | |||
10 | * Select watchers on new issue form |
|
16 | * Select watchers on new issue form |
@@ -64,6 +64,22 class UsersControllerTest < Test::Unit::TestCase | |||||
64 | assert_equal 2, Member.find(1).role_id |
|
64 | assert_equal 2, Member.find(1).role_id | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
|
67 | def test_edit_with_activation_should_send_a_notification | |||
|
68 | u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr') | |||
|
69 | u.login = 'foo' | |||
|
70 | u.status = User::STATUS_REGISTERED | |||
|
71 | u.save! | |||
|
72 | ActionMailer::Base.deliveries.clear | |||
|
73 | Setting.bcc_recipients = '1' | |||
|
74 | ||||
|
75 | post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE} | |||
|
76 | assert u.reload.active? | |||
|
77 | mail = ActionMailer::Base.deliveries.last | |||
|
78 | assert_not_nil mail | |||
|
79 | assert_equal ['foo.bar@somenet.foo'], mail.bcc | |||
|
80 | assert mail.body.include?(ll('fr', :notice_account_activated)) | |||
|
81 | end | |||
|
82 | ||||
67 | def test_destroy_membership |
|
83 | def test_destroy_membership | |
68 | post :destroy_membership, :id => 2, :membership_id => 1 |
|
84 | post :destroy_membership, :id => 2, :membership_id => 1 | |
69 | assert_redirected_to 'users/edit/2' |
|
85 | assert_redirected_to 'users/edit/2' |
@@ -47,7 +47,11 class MailHandlerTest < Test::Unit::TestCase | |||||
47 | assert_equal 'New ticket on a given project', issue.subject |
|
47 | assert_equal 'New ticket on a given project', issue.subject | |
48 | assert_equal User.find_by_login('jsmith'), issue.author |
|
48 | assert_equal User.find_by_login('jsmith'), issue.author | |
49 | assert_equal Project.find(2), issue.project |
|
49 | assert_equal Project.find(2), issue.project | |
|
50 | assert_equal IssueStatus.find_by_name('Resolved'), issue.status | |||
50 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
51 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |
|
52 | # keywords should be removed from the email body | |||
|
53 | assert !issue.description.match(/^Project:/i) | |||
|
54 | assert !issue.description.match(/^Status:/i) | |||
51 | end |
|
55 | end | |
52 |
|
56 | |||
53 | def test_add_issue_with_status |
|
57 | def test_add_issue_with_status | |
@@ -111,6 +115,7 class MailHandlerTest < Test::Unit::TestCase | |||||
111 | issue.reload |
|
115 | issue.reload | |
112 | assert_equal 'New ticket with custom field values', issue.subject |
|
116 | assert_equal 'New ticket with custom field values', issue.subject | |
113 | assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value |
|
117 | assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value | |
|
118 | assert !issue.description.match(/^searchable field:/i) | |||
114 | end |
|
119 | end | |
115 |
|
120 | |||
116 | def test_add_issue_with_cc |
|
121 | def test_add_issue_with_cc |
General Comments 0
You need to be logged in to leave comments.
Login now