Set last_repository_updated_at to created_at upon project creation

parent 341964da
...@@ -53,6 +53,11 @@ class Project < ActiveRecord::Base ...@@ -53,6 +53,11 @@ class Project < ActiveRecord::Base
update_column(:last_activity_at, self.created_at) update_column(:last_activity_at, self.created_at)
end 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 after_destroy :remove_pages
# update visibility_level of forks # update visibility_level of forks
......
...@@ -1925,4 +1925,12 @@ describe Project, models: true do ...@@ -1925,4 +1925,12 @@ describe Project, models: true do
not_to raise_error not_to raise_error
end end
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 end
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