From 9cb7e93f09b1ff0c1c889a004479a8ef21abbae2 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 3 Mar 2018 05:59:40 -0800 Subject: Fix project dashboard showing the wrong timestamps Use the max of the `last_activity_at` and `last_repository_updated_at` columns. The latter is updated only when a push happens, but the former is updated whenever any activity (e.g. issue creation) happens. Closes #27181 --- spec/features/dashboard/projects_spec.rb | 8 ++++++++ spec/models/project_spec.rb | 14 ++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'spec') diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 586c7b48d0b..986f864f0b5 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -37,6 +37,14 @@ feature 'Dashboard Projects' do expect(page).to have_xpath("//time[@datetime='#{project.last_repository_updated_at.getutc.iso8601}']") end + + it 'shows the last_activity_at attribute as the update date' do + project.update_attributes!(last_repository_updated_at: 1.hour.ago, last_activity_at: Time.now) + + visit dashboard_projects_path + + expect(page).to have_xpath("//time[@datetime='#{project.last_activity_at.getutc.iso8601}']") + end end context 'when last_repository_updated_at and last_activity_at are missing' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index f4faec9e52a..27bb1a2e3bd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -517,6 +517,20 @@ describe Project do it 'returns the project\'s last update date if it has no events' do expect(project.last_activity_date).to eq(project.updated_at) end + + it 'returns the most recent timestamp' do + project.update_attributes(updated_at: nil, + last_activity_at: timestamp, + last_repository_updated_at: timestamp - 1.hour) + + expect(project.last_activity_date).to eq(timestamp) + + project.update_attributes(updated_at: timestamp, + last_activity_at: timestamp - 1.hour, + last_repository_updated_at: nil) + + expect(project.last_activity_date).to eq(timestamp) + end end end -- cgit v1.2.1