diff --git a/app/helpers/activities_helper.rb b/app/helpers/activities_helper.rb
index 49074b5617..d48a9939e1 100644
--- a/app/helpers/activities_helper.rb
+++ b/app/helpers/activities_helper.rb
@@ -30,4 +30,12 @@ module ActivitiesHelper
end
sorted_events
end
+
+ def activity_avatar(event)
+ return nil unless event.respond_to?(:event_author)
+
+ author = event.event_author
+ committer = event.respond_to?(:committer) ? event.committer : nil
+ avatar(author.is_a?(User) ? author : (committer || author))
+ end
end
diff --git a/app/views/activities/_activities.html.erb b/app/views/activities/_activities.html.erb
index aaeea76bc2..5de9a7fd37 100644
--- a/app/views/activities/_activities.html.erb
+++ b/app/views/activities/_activities.html.erb
@@ -4,7 +4,7 @@
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
- <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
- <%= avatar(e.event_author) if e.respond_to?(:event_author) %>
+ <%= activity_avatar(e) %>
<%= format_time(e.event_datetime, false) %>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %>
diff --git a/test/functional/activities_controller_test.rb b/test/functional/activities_controller_test.rb
index 7475d49966..4d2c992220 100644
--- a/test/functional/activities_controller_test.rb
+++ b/test/functional/activities_controller_test.rb
@@ -28,7 +28,8 @@ class ActivitiesControllerTest < Redmine::ControllerTest
:members,
:groups_users,
:enabled_modules,
- :journals, :journal_details
+ :journals, :journal_details,
+ :repositories, :changesets, :changes
def test_project_index
get(
@@ -266,4 +267,74 @@ class ActivitiesControllerTest < Redmine::ControllerTest
assert_select '.pagination a', :text => /Previous/
assert_select '.pagination a', :text => /Next/
end
+
+ def test_index_with_git_changesets_and_gravatar_enabled_should_display_gravatar
+ project = Project.find(1)
+ project.repositories.delete_all
+ repo = Repository::Git.create!(
+ :project => project,
+ :url => Rails.root.join('tmp/test/git_repository').to_s
+ )
+ repo.fetch_changesets
+ rev = '2a682156a3b6e77a8bf9cd4590e8db757f3c6c78'
+ changeset = repo.find_changeset_by_name(rev)
+ assert_equal 'test20120208 ', changeset.committer
+
+ @request.session[:user_id] = 1
+ User.current = User.find(1)
+ from_date = User.current.time_to_date(changeset.committed_on).to_s
+
+ [['1', 1], ['0', 0]].each do |(gravatar_enabled, img_count)|
+ with_settings :gravatar_enabled => gravatar_enabled do
+ get(
+ :index,
+ :params => {
+ :id => project.id,
+ :show_changesets => 1,
+ :from => from_date
+ }
+ )
+ assert_response :success
+ assert_select 'dt.changeset:first-child' do
+ assert_select 'a[href=?]', "/projects/ecookbook/repository/#{repo.id}/revisions/#{rev}"
+ assert_select 'img.gravatar', img_count
+ end
+ end
+ end
+ end
+
+ def test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar
+ project = Project.find(1)
+ project.repositories.delete_all
+ repo = Repository::Mercurial.create!(
+ :project => project,
+ :url => Rails.root.join('tmp/test/mercurial_repository').to_s
+ )
+ repo.fetch_changesets
+ rev = 'afc61e85bde74de930e5846c8451bd55b5bafc9c'
+ changeset = repo.find_changeset_by_name(rev)
+ assert_equal 'test Ü ', changeset.committer
+
+ @request.session[:user_id] = 1
+ User.current = User.find(1)
+ from_date = User.current.time_to_date(changeset.committed_on).to_s
+
+ [['1', 1], ['0', 0]].each do |(gravatar_enabled, img_count)|
+ with_settings :gravatar_enabled => gravatar_enabled do
+ get(
+ :index,
+ :params => {
+ :id => project.id,
+ :show_changesets => 1,
+ :from => from_date
+ }
+ )
+ assert_response :success
+ assert_select 'dt.changeset:first-child' do
+ assert_select 'a[href=?]', "/projects/ecookbook/repository/#{repo.id}/revisions/#{rev}"
+ assert_select 'img.gravatar', img_count
+ end
+ end
+ end
+ end
end