move capture_exception to correct method, update spec

This commit is contained in:
carlad 2016-07-26 17:36:02 +02:00
parent 291fea3e07
commit 72be42b88f
2 changed files with 3 additions and 5 deletions

View File

@ -9,6 +9,8 @@ module Travis::API::V3
Models::Cron.all.select do |cron|
start(cron) if cron.next_enqueuing <= Time.now
end
rescue => e
Raven.capture_exception(e)
end
def start(cron)
@ -30,8 +32,6 @@ module Travis::API::V3
class_name, queue = Query.sidekiq_queue(:build_request)
::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => [{type: 'cron'.freeze, payload: JSON.dump(payload), credentials: {}}])
true
rescue => e
Raven.capture_exception(e)
end
end
end

View File

@ -26,9 +26,7 @@ describe Travis::API::V3::Queries::Crons do
cron = Travis::API::V3::Models::Cron.create(branch_id: existing_branch.id, interval: 'daily', disable_by_build: false)
error = StandardError.new('Konstantin broke all the thingz!')
Travis::API::V3::Models::Cron.any_instance.stubs(:branch).raises(error)
Raven.expects(:capture_exception).with do |event|
event.message == "#{error.class}: #{error.message}"
end
Raven.expects(:capture_exception).with(error)
query.start_all
end
end