Project

General

Profile

Defect #6082 » 6082.patch

Yuichi HARADA, 2020-12-22 05:34

View differences:

app/helpers/activities_helper.rb
30 30
    end
31 31
    sorted_events
32 32
  end
33

  
34
  def activity_avatar(event)
35
    return nil unless event.respond_to?(:event_author)
36

  
37
    author = event.event_author
38
    committer = event.respond_to?(:committer) ? event.committer : nil
39
    avatar(author.is_a?(User) ? author : (committer || author))
40
  end
33 41
end
app/views/activities/_activities.html.erb
4 4
<dl>
5 5
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
6 6
  <dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
7
  <%= avatar(e.event_author) if e.respond_to?(:event_author) %>
7
  <%= activity_avatar(e) %>
8 8
  <span class="time"><%= format_time(e.event_datetime, false) %></span>
9 9
  <%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
10 10
  <%= link_to format_activity_title(e.event_title), e.event_url %>
test/functional/activities_controller_test.rb
28 28
           :members,
29 29
           :groups_users,
30 30
           :enabled_modules,
31
           :journals, :journal_details
31
           :journals, :journal_details,
32
           :repositories, :changesets, :changes
32 33

  
33 34
  def test_project_index
34 35
    get(
......
266 267
    assert_select '.pagination a', :text => /Previous/
267 268
    assert_select '.pagination a', :text => /Next/
268 269
  end
270

  
271
  def test_index_with_git_changesets_and_gravatar_enabled_should_display_gravatar
272
    project = Project.find(1)
273
    project.repositories.delete_all
274
    repo = Repository::Git.create!(
275
      :project => project,
276
      :url => Rails.root.join('tmp/test/git_repository').to_s
277
    )
278
    repo.fetch_changesets
279
    rev = '2a682156a3b6e77a8bf9cd4590e8db757f3c6c78'
280
    changeset = repo.find_changeset_by_name(rev)
281
    assert_equal 'test20120208 <none@none>', changeset.committer
282

  
283
    @request.session[:user_id] = 1
284
    User.current = User.find(1)
285
    from_date = User.current.time_to_date(changeset.committed_on).to_s
286

  
287
    [['1', 1], ['0', 0]].each do |(gravatar_enabled, img_count)|
288
      with_settings :gravatar_enabled => gravatar_enabled do
289
        get(
290
          :index,
291
          :params => {
292
            :id => project.id,
293
            :show_changesets => 1,
294
            :from => from_date
295
          }
296
        )
297
        assert_response :success
298
        assert_select 'dt.changeset:first-child' do
299
          assert_select 'a[href=?]', "/projects/ecookbook/repository/#{repo.id}/revisions/#{rev}"
300
          assert_select 'img.gravatar', img_count
301
        end
302
      end
303
    end
304
  end
305

  
306
  def test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar
307
    project = Project.find(1)
308
    project.repositories.delete_all
309
    repo = Repository::Mercurial.create!(
310
      :project => project,
311
      :url => Rails.root.join('tmp/test/mercurial_repository').to_s
312
    )
313
    repo.fetch_changesets
314
    rev = 'afc61e85bde74de930e5846c8451bd55b5bafc9c'
315
    changeset = repo.find_changeset_by_name(rev)
316
    assert_equal 'test Ü <test00@foo.bar>', changeset.committer
317

  
318
    @request.session[:user_id] = 1
319
    User.current = User.find(1)
320
    from_date = User.current.time_to_date(changeset.committed_on).to_s
321

  
322
    [['1', 1], ['0', 0]].each do |(gravatar_enabled, img_count)|
323
      with_settings :gravatar_enabled => gravatar_enabled do
324
        get(
325
          :index,
326
          :params => {
327
            :id => project.id,
328
            :show_changesets => 1,
329
            :from => from_date
330
          }
331
        )
332
        assert_response :success
333
        assert_select 'dt.changeset:first-child' do
334
          assert_select 'a[href=?]', "/projects/ecookbook/repository/#{repo.id}/revisions/#{rev}"
335
          assert_select 'img.gravatar', img_count
336
        end
337
      end
338
    end
339
  end
269 340
end
(2-2/2)