diff --git a/app/jobs/shipit/refresh_check_runs_job.rb b/app/jobs/shipit/refresh_check_runs_job.rb index 26cf8f31f..885783112 100644 --- a/app/jobs/shipit/refresh_check_runs_job.rb +++ b/app/jobs/shipit/refresh_check_runs_job.rb @@ -8,9 +8,7 @@ def perform(params) Commit.find(params[:commit_id]).refresh_check_runs! else stack = Stack.find(params[:stack_id]) - stack.commits.order(id: :desc).limit(30).each do |commit| - RefreshCheckRunsJob.perform_later(commit_id: commit.id) - end + stack.commits.order(id: :desc).limit(30).each(&:refresh_check_runs!) end end end diff --git a/app/jobs/shipit/refresh_statuses_job.rb b/app/jobs/shipit/refresh_statuses_job.rb index f21b609d0..0a94b5733 100644 --- a/app/jobs/shipit/refresh_statuses_job.rb +++ b/app/jobs/shipit/refresh_statuses_job.rb @@ -8,9 +8,7 @@ def perform(params) Commit.find(params[:commit_id]).refresh_statuses! else stack = Stack.find(params[:stack_id]) - stack.commits.order(id: :desc).limit(30).each do |commit| - RefreshStatusesJob.perform_later(commit_id: commit.id) - end + stack.commits.order(id: :desc).limit(30).each(&:refresh_statuses!) end end end diff --git a/test/jobs/refresh_check_runs_job_test.rb b/test/jobs/refresh_check_runs_job_test.rb deleted file mode 100644 index 38f5cf3a5..000000000 --- a/test/jobs/refresh_check_runs_job_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true -require 'test_helper' - -module Shipit - class RefreshCheckRunsJobTest < ActiveSupport::TestCase - setup do - @stack = shipit_stacks(:shipit) - @job = RefreshCheckRunsJob.new - end - - test "#perform enqueues RefreshCheckRunsJob for the last 30 commits on the stack" do - assert_enqueued_jobs @stack.commits.count, only: RefreshCheckRunsJob do - @job.perform(stack_id: @stack.id) - end - end - - test "if :commit_id param is present only this commit is refreshed" do - Commit.any_instance.expects(:refresh_check_runs!).once - - @job.perform(stack_id: @stack.id, commit_id: shipit_commits(:first).id) - end - end -end diff --git a/test/jobs/refresh_statuses_job_test.rb b/test/jobs/refresh_status_job_test.rb similarity index 67% rename from test/jobs/refresh_statuses_job_test.rb rename to test/jobs/refresh_status_job_test.rb index 5ccf711eb..d60e477f8 100644 --- a/test/jobs/refresh_statuses_job_test.rb +++ b/test/jobs/refresh_status_job_test.rb @@ -8,10 +8,10 @@ class RefreshStatusesJobTest < ActiveSupport::TestCase @job = RefreshStatusesJob.new end - test "#perform enqueues RefreshStatusesJob for the last 30 commits on the stack" do - assert_enqueued_jobs @stack.commits.count, only: RefreshStatusesJob do - @job.perform(stack_id: @stack.id) - end + test "#perform call #refresh_statuses! on the last 30 commits of the stack" do + Commit.any_instance.expects(:refresh_statuses!).times(@stack.commits.count) + + @job.perform(stack_id: @stack.id) end test "if :commit_id param is present only this commit is refreshed" do