summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-09-19 20:09:17 -0700
committerStan Hu <stanhu@gmail.com>2016-09-19 20:09:17 -0700
commite0f0210e078750ec0c949c388d44f40900404b82 (patch)
treeb594781d3fc8358a685a9a5cd526704478839121
parenta3d0c84e73487dcf3a773c82c1b6f3c1126dac86 (diff)
downloadgitlab-ce-sh-fix-last-activity-at-specs.tar.gz
Fix implementation of recent_update?sh-fix-last-activity-at-specs
-rw-r--r--app/models/event.rb2
-rw-r--r--spec/models/project_spec.rb3
2 files changed, 2 insertions, 3 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 55a76e26f3c..805558f826b 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -340,7 +340,7 @@ class Event < ActiveRecord::Base
private
def recent_update?
- project.last_activity_at > RESET_PROJECT_ACTIVITY_INTERVAL.ago
+ (created_at - project.last_activity_at).to_i > RESET_PROJECT_ACTIVITY_INTERVAL.to_i
end
def try_obtain_lease
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 8f5bd674013..462b740389a 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -309,7 +309,7 @@ describe Project, models: true do
describe 'last_activity methods' do
let(:project) { create(:project) }
- let!(:last_event) { double(created_at: Time.now) }
+ let!(:last_event) { double(created_at: Time.now - 2.hours) }
describe 'last_activity' do
it 'alias last_activity to last_event' do
@@ -320,7 +320,6 @@ describe Project, models: true do
describe 'last_activity_date' do
it 'returns the creation date of the project\'s last event if present' do
- expect_any_instance_of(Event).to receive(:recent_update?).and_return(false)
expect_any_instance_of(Event).to receive(:try_obtain_lease).and_return(true)
new_event = create(:event, project: project, created_at: Time.now + 1)