Feature #30822 » feature-30822.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
|
def avatar(user, options = { })
|
||
|
if Setting.gravatar_enabled?
|
||
|
options.merge!(:default => Setting.gravatar_default)
|
||
|
# style for HTML mail
|
||
|
if options.delete(:html_mail)
|
||
|
options[:style] = "#{options[:style]}width:14px;height:14px;border-radius:20%;vertical-align:middle;"
|
||
|
end
|
||
|
email = nil
|
||
|
if user.respond_to?(:mail)
|
||
|
email = user.mail
|
||
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
%w(author status priority assigned_to category fixed_version start_date due_date).each do |attribute|
|
||
|
if issue.disabled_core_fields.grep(/^#{attribute}(_id)?$/).empty?
|
||
|
if html
|
||
|
items << content_tag('strong', "#{l("field_#{attribute}")}: ") + (issue.send attribute)
|
||
|
value = issue.send(attribute)
|
||
|
if %w(author assigned_to).include?(attribute) && value.is_a?(User)
|
||
|
value = "#{avatar(value, :title => l("field_#{attribute}"), :html_mail => true)}#{value}".html_safe
|
||
|
end
|
||
|
items << content_tag('strong', "#{l("field_#{attribute}")}: ") + value
|
||
|
else
|
||
|
items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
|
||
|
end
|
||
| app/views/mailer/issue_add.html.erb | ||
|---|---|---|
|
<%= l(:text_issue_added, :id => link_to("##{@issue.id}", @issue_url), :author => h(@issue.author)).html_safe %>
|
||
|
<%= l(:text_issue_added,
|
||
|
:id => link_to("##{@issue.id}", @issue_url),
|
||
|
:author => "#{avatar(@issue.author, :html_mail => true)}#{h(@issue.author)}").html_safe %>
|
||
|
<hr />
|
||
|
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :user => @user, :issue_url => @issue_url } %>
|
||
| app/views/mailer/issue_edit.html.erb | ||
|---|---|---|
|
<% if @journal.private_notes? %>
|
||
|
(<%= l(:field_private_notes) %>)
|
||
|
<% end %>
|
||
|
<%= l(:text_issue_updated, :id => link_to("##{@issue.id}", @issue_url), :author => h(@journal.user)).html_safe %>
|
||
|
<%= l(:text_issue_updated,
|
||
|
:id => link_to("##{@issue.id}", @issue_url),
|
||
|
:author => "#{avatar(@journal.user, :html_mail => true)}#{h(@journal.user)}").html_safe %>
|
||
|
<hr />
|
||
|
<ul class="journal details">
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_avatar_with_html_mail_option
|
||
|
with_settings :gravatar_enabled => '1' do
|
||
|
avatar = avatar('jsmith <jsmith@somenet.foo>', :html_mail => true)
|
||
|
assert_include 'style="width:14px;height:14px;border-radius:20%;vertical-align:middle;"', avatar
|
||
|
assert_not_include 'html_mail', avatar
|
||
|
end
|
||
|
end
|
||
|
def test_avatar_disabled
|
||
|
with_settings :gravatar_enabled => '0' do
|
||
|
assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
|
||
| test/unit/mailer_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_issue_add_should_include_gravatar_if_gravatar_enabled
|
||
|
with_settings :gravatar_enabled => '1' do
|
||
|
issue = Issue.find(2)
|
||
|
Mailer.deliver_issue_add(issue)
|
||
|
gravatar_url = 'https://www.gravatar.com/avatar/'
|
||
|
option = '?rating=PG&size=50&default='
|
||
|
author_gravatar_url = gravatar_url + Digest::MD5.hexdigest(issue.author.mail) + option
|
||
|
assignee_gravatar_url = gravatar_url + Digest::MD5.hexdigest(issue.assigned_to.mail) + option
|
||
|
assert_select_email do
|
||
|
assert_select 'img[class=?]', 'gravatar', :count => 3
|
||
|
assert_select 'img[class="gravatar"][title=?][src=?]', '', author_gravatar_url, :count => 1
|
||
|
assert_select 'li img[class="gravatar"][title=?][src=?]', 'Author', author_gravatar_url, :count => 1
|
||
|
assert_select 'li img[class="gravatar"][title=?][src=?]', 'Assignee', assignee_gravatar_url, :count => 1
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_issue_add_should_include_gravatar_if_gravatar_disabled
|
||
|
with_settings :gravatar_enabled => '0' do
|
||
|
issue = Issue.find(2)
|
||
|
Mailer.deliver_issue_add(issue)
|
||
|
assert_select_email do
|
||
|
assert_select 'img[class=?]', 'gravatar', :count => 0
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
|
||
|
with_settings :show_status_changes_in_mail_subject => 1 do
|
||
|
issue = Issue.find(2)
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def test_issue_edit_should_include_gravatar_if_gravatar_enabled
|
||
|
with_settings :gravatar_enabled => '1' do
|
||
|
journal = Journal.find(3)
|
||
|
Mailer.deliver_issue_edit(journal)
|
||
|
gravatar_url = 'https://www.gravatar.com/avatar/'
|
||
|
option = '?rating=PG&size=50&default='
|
||
|
reported_user_gravatar_url = gravatar_url + Digest::MD5.hexdigest(journal.user.mail) + option
|
||
|
author_gravatar_url = gravatar_url + Digest::MD5.hexdigest(journal.issue.author.mail) + option
|
||
|
assignee_gravatar_url = gravatar_url + Digest::MD5.hexdigest(journal.issue.assigned_to.mail) + option
|
||
|
assert_select_email do
|
||
|
assert_select 'img[class="gravatar"]', :count => 3
|
||
|
assert_select 'img[class="gravatar"][title=?][src=?]', '', reported_user_gravatar_url, :count => 1
|
||
|
assert_select 'li img[class="gravatar"][title=?][src=?]', 'Author', author_gravatar_url, :count => 1
|
||
|
assert_select 'li img[class="gravatar"][title=?][src=?]', 'Assignee', assignee_gravatar_url, :count => 1
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_issue_edit_should_include_gravatar_if_gravatar_disabled
|
||
|
with_settings :gravatar_enabled => '0' do
|
||
|
journal = Journal.find(3)
|
||
|
Mailer.deliver_issue_edit(journal)
|
||
|
assert_select_email do
|
||
|
assert_select 'img[class="gravatar"]', :count => 0
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_version_file_added
|
||
|
attachements = [ Attachment.find_by_container_type('Version') ]
|
||
|
assert Mailer.deliver_attachments_added(attachements)
|
||
- « Previous
- 1
- 2
- Next »