Set last_repository_updated_at to created_at upon project creation

This commit is contained in:
Douglas Barbosa Alexandre 2017-05-03 22:39:41 -03:00
parent 341964da45
commit 56db54d3e5
2 changed files with 13 additions and 0 deletions

View File

@ -53,6 +53,11 @@ class Project < ActiveRecord::Base
update_column(:last_activity_at, self.created_at)
end
after_create :set_last_repository_updated_at
def set_last_repository_updated_at
update_column(:last_repository_updated_at, self.created_at)
end
after_destroy :remove_pages
# update visibility_level of forks

View File

@ -1925,4 +1925,12 @@ describe Project, models: true do
not_to raise_error
end
end
describe '#last_repository_updated_at' do
it 'sets to created_at upon creation' do
project = create(:empty_project, created_at: 2.hours.ago)
expect(project.last_repository_updated_at.to_i).to eq(project.created_at.to_i)
end
end
end