summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2017-06-26 00:42:44 -0500
committerRuben Davila <rdavila84@gmail.com>2017-06-26 00:42:44 -0500
commita89c1bf645e4ca0ccc5df9d26c196652a247e82a (patch)
treec47afeb059d03cea8968a2ef3fcf83671cbf7515
parentf0886918845f8292889db7e30033b7051147f3b0 (diff)
downloadgitlab-ce-34276-fix-dashboard-page-when-last-activity-at-is-nil.tar.gz
Fix application error when Project#last_activity_at is nil34276-fix-dashboard-page-when-last-activity-at-is-nil
-rw-r--r--app/models/project.rb2
-rw-r--r--app/views/shared/projects/_project.html.haml2
-rw-r--r--spec/features/dashboard/projects_spec.rb22
3 files changed, 19 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 2c2685875f8..11038c6d0d6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -689,7 +689,7 @@ class Project < ActiveRecord::Base
end
def last_activity_date
- last_activity_at || updated_at
+ last_repository_updated_at || last_activity_at || updated_at
end
def project_id
diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml
index fbc335f6176..8c3d6351ac2 100644
--- a/app/views/shared/projects/_project.html.haml
+++ b/app/views/shared/projects/_project.html.haml
@@ -7,7 +7,7 @@
- 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
- 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 }
= cache(cache_key) do
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb
index 2a8185ca669..f29186f368d 100644
--- a/spec/features/dashboard/projects_spec.rb
+++ b/spec/features/dashboard/projects_spec.rb
@@ -15,13 +15,25 @@ RSpec.describe 'Dashboard Projects', feature: true do
expect(page).to have_content('awesome stuff')
end
- it 'shows the last_activity_at attribute as the update date' do
- now = Time.now
- project.update_column(:last_activity_at, now)
+ context 'when last_repository_updated_at, last_activity_at and update_at are present' do
+ it 'shows the last_repository_updated_at attribute as the update date' do
+ 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='#{project.last_repository_updated_at.getutc.iso8601}']")
+ end
+ end
- expect(page).to have_xpath("//time[@datetime='#{now.getutc.iso8601}']")
+ 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
context 'when on Starred projects tab' do