Revision 2512
Added by Jean-Philippe Lang over 16 years ago
branches/0.8-stable/app/controllers/users_controller.rb | ||
---|---|---|
75 | 75 |
@user.admin = params[:user][:admin] if params[:user][:admin] |
76 | 76 |
@user.login = params[:user][:login] if params[:user][:login] |
77 | 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 |
if @user.update_attributes(params[:user]) |
|
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 | 83 |
flash[:notice] = l(:notice_successful_update) |
80 | 84 |
# Give a string to redirect_to otherwise it would use status param as the response code |
81 | 85 |
redirect_to(url_for(:action => 'list', :status => params[:status], :page => params[:page])) |
branches/0.8-stable/app/models/mail_handler.rb | ||
---|---|---|
163 | 163 |
end |
164 | 164 |
|
165 | 165 |
def get_keyword(attr, options={}) |
166 |
if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i |
|
167 |
$1.strip |
|
168 |
elsif !@@handler_options[:issue][attr].blank? |
|
169 |
@@handler_options[:issue][attr] |
|
166 |
@keywords ||= {} |
|
167 |
if @keywords.has_key?(attr) |
|
168 |
@keywords[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 | 177 |
end |
171 | 178 |
end |
172 | 179 |
|
branches/0.8-stable/app/models/mailer.rb | ||
---|---|---|
127 | 127 |
:url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc') |
128 | 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 | 139 |
def lost_password(token) |
131 | 140 |
set_language_if_valid(token.user.language) |
132 | 141 |
recipients token.user.mail |
branches/0.8-stable/app/views/mailer/account_activated.text.html.rhtml | ||
---|---|---|
1 |
<p><%= l(:notice_account_activated) %></p> |
|
2 |
<p><%= l(:label_login) %>: <%= link_to @login_url, @login_url %></p> |
|
0 | 3 |
branches/0.8-stable/app/views/mailer/account_activated.text.plain.rhtml | ||
---|---|---|
1 |
<%= l(:notice_account_activated) %> |
|
2 |
<%= l(:label_login) %>: <%= @login_url %> |
|
0 | 3 |
branches/0.8-stable/doc/CHANGELOG | ||
---|---|---|
5 | 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 | 14 |
== 2009-02-15 v0.8.1 |
9 | 15 |
|
10 | 16 |
* Select watchers on new issue form |
branches/0.8-stable/test/functional/users_controller_test.rb | ||
---|---|---|
64 | 64 |
assert_equal 2, Member.find(1).role_id |
65 | 65 |
end |
66 | 66 |
|
67 |
def test_edit_with_activation_should_send_a_notification |
|
68 |
u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => '[email protected]', :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 ['[email protected]'], mail.bcc |
|
80 |
assert mail.body.include?(ll('fr', :notice_account_activated)) |
|
81 |
end |
|
82 |
|
|
67 | 83 |
def test_destroy_membership |
68 | 84 |
post :destroy_membership, :id => 2, :membership_id => 1 |
69 | 85 |
assert_redirected_to 'users/edit/2' |
branches/0.8-stable/test/unit/mail_handler_test.rb | ||
---|---|---|
47 | 47 |
assert_equal 'New ticket on a given project', issue.subject |
48 | 48 |
assert_equal User.find_by_login('jsmith'), issue.author |
49 | 49 |
assert_equal Project.find(2), issue.project |
50 |
assert_equal IssueStatus.find_by_name('Resolved'), issue.status |
|
50 | 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 | 55 |
end |
52 | 56 |
|
53 | 57 |
def test_add_issue_with_status |
... | ... | |
111 | 115 |
issue.reload |
112 | 116 |
assert_equal 'New ticket with custom field values', issue.subject |
113 | 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 | 119 |
end |
115 | 120 |
|
116 | 121 |
def test_add_issue_with_cc |
Also available in: Unified diff
Merged r2426 and r2484 from trunk.