Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/api/pushes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def create
end
)
end

current_project.touch
end

render json: { status: :ok }, status: :created
Expand Down
5 changes: 1 addition & 4 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
class Report < ApplicationRecord
belongs_to :metric

after_save do
metric.touch
metric.project.touch
end
after_save { metric.touch }

has_many :occurrences, dependent: :destroy

Expand Down
6 changes: 6 additions & 0 deletions test/controllers/api/pushes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ class Api::PushesControllerTest < ActionDispatch::IntegrationTest
assert_equal 24, metric_with_value.reports.last.value
end

it 'bumps project.updated_at after a push' do
create(:project, name: 'cherrypush/cherry-app', user: user, updated_at: 1.week.ago)
post(api_push_path, params: { api_key: user.api_key, **payload }, as: :json)
assert_equal Date.current, Project.sole.reload.updated_at.to_date
end

it 'adds up value_by_owner to existing value_by_owner by uuid' do
post(api_push_path, params: { api_key: user.api_key, **payload }, as: :json)
metric_with_owners = Metric.find_by(name: 'missing coverage')
Expand Down
6 changes: 0 additions & 6 deletions test/models/metric_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ProjectTest < ActiveSupport::TestCase
it 'updates the updated_at field when a new report is created' do
create(:report, metric: metric)
assert_equal Time.current.to_date, metric.reload.updated_at.to_date
assert_equal Time.current.to_date, project.reload.updated_at.to_date
end
end

Expand All @@ -38,11 +37,6 @@ class ProjectTest < ActiveSupport::TestCase
metric.destroy!
assert_equal 1.week.ago.to_date, project.reload.updated_at.to_date
end

it 'updates the project updated_at field when creating a report for an existing metric' do
create(:report, metric: metric)
assert_equal Date.current, project.reload.updated_at.to_date
end
end

describe 'when chart metrics are present' do
Expand Down
Loading