Commit a89c1bf6 authored by Ruben Davila's avatar Ruben Davila

Fix application error when Project#last_activity_at is nil

parent f0886918
...@@ -689,7 +689,7 @@ class Project < ActiveRecord::Base ...@@ -689,7 +689,7 @@ class Project < ActiveRecord::Base
end end
def last_activity_date def last_activity_date
last_activity_at || updated_at last_repository_updated_at || last_activity_at || updated_at
end end
def project_id def project_id
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true && project.commit - show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true && project.commit
- css_class += " no-description" if project.description.blank? && !show_last_commit_as_description - css_class += " no-description" if project.description.blank? && !show_last_commit_as_description
- cache_key = project_list_cache_key(project) - cache_key = project_list_cache_key(project)
- updated_tooltip = time_ago_with_tooltip(project.last_activity_at) - updated_tooltip = time_ago_with_tooltip(project.last_activity_date)
%li.project-row{ class: css_class } %li.project-row{ class: css_class }
= cache(cache_key) do = cache(cache_key) do
......
...@@ -15,13 +15,25 @@ RSpec.describe 'Dashboard Projects', feature: true do ...@@ -15,13 +15,25 @@ RSpec.describe 'Dashboard Projects', feature: true do
expect(page).to have_content('awesome stuff') expect(page).to have_content('awesome stuff')
end end
it 'shows the last_activity_at attribute as the update date' do context 'when last_repository_updated_at, last_activity_at and update_at are present' do
now = Time.now it 'shows the last_repository_updated_at attribute as the update date' do
project.update_column(:last_activity_at, now) project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago)
visit dashboard_projects_path visit dashboard_projects_path
expect(page).to have_xpath("//time[@datetime='#{now.getutc.iso8601}']") expect(page).to have_xpath("//time[@datetime='#{project.last_repository_updated_at.getutc.iso8601}']")
end
end
context 'when last_repository_updated_at and last_activity_at are missing' do
it 'shows the updated_at attribute as the update date' do
project.update_attributes!(last_repository_updated_at: nil, last_activity_at: nil)
project.touch
visit dashboard_projects_path
expect(page).to have_xpath("//time[@datetime='#{project.updated_at.getutc.iso8601}']")
end
end end
context 'when on Starred projects tab' do context 'when on Starred projects tab' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment