Project

General

Profile

Defect #6082 » 6082.patch

Yuichi HARADA, 2020-12-22 05:34

View differences:

app/helpers/activities_helper.rb
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
app/views/activities/_activities.html.erb
<dl>
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
<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 %>">
<%= avatar(e.event_author) if e.respond_to?(:event_author) %>
<%= activity_avatar(e) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %>
test/functional/activities_controller_test.rb
:members,
:groups_users,
:enabled_modules,
:journals, :journal_details
:journals, :journal_details,
:repositories, :changesets, :changes
def test_project_index
get(
......
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 <none@none>', 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 Ü <test00@foo.bar>', 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
(2-2/2)