Skip to content
Open
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: 1 addition & 1 deletion lib/travis/addons/handlers/campfire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:campfire, payload, targets: targets)
run_task(payload, targets: targets)
end

def targets
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle?
end

def handle
run_task(:email, payload, recipients: recipients, broadcasts: broadcasts)
run_task(payload, recipients: recipients, broadcasts: broadcasts)
end

def recipients
Expand Down
3 changes: 1 addition & 2 deletions lib/travis/addons/handlers/flowdock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:flowdock, payload, targets: targets)
run_task(payload, targets: targets)
end

def targets
Expand All @@ -28,4 +28,3 @@ def notify_completed
end
end
end

2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/github_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle?
end

def handle
run_task(:github_status, payload, tokens: tokens)
run_task(payload, tokens: tokens)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/hipchat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:hipchat, payload, targets: targets)
run_task(payload, targets: targets)
end

def enabled?
Expand Down
3 changes: 1 addition & 2 deletions lib/travis/addons/handlers/irc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:irc, payload, channels: channels)
run_task(payload, channels: channels)
end

def channels
Expand All @@ -28,4 +28,3 @@ def notify_completed
end
end
end

2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/pusher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Pusher < Base
/^build:(created|received|started|finished|canceled|restarted)/,
/^job:(created|received|started|finished|canceled|restarted)/
]
QUEUE = :'pusher-live'
QUEUE = :'live-updates'

attr_reader :channels

Expand Down
2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/pushover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:pushover, payload, users: users, api_key: api_key)
run_task(payload, users: users, api_key: api_key)
end

def users
Expand Down
3 changes: 1 addition & 2 deletions lib/travis/addons/handlers/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:slack, payload, targets: targets)
run_task(payload, targets: targets)
end

def targets
Expand All @@ -28,4 +28,3 @@ def notify_completed
end
end
end

3 changes: 1 addition & 2 deletions lib/travis/addons/handlers/sqwiggle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handle?
end

def handle
run_task(:sqwiggle, payload, targets: targets)
run_task(payload, targets: targets)
end

def targets
Expand All @@ -28,4 +28,3 @@ def notify_completed
end
end
end

3 changes: 1 addition & 2 deletions lib/travis/addons/handlers/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def handle?
end

def handle
run_task(:webhook, payload, targets: targets, token: request.token)
run_task(payload, targets: targets, token: request.token)
end

def targets
Expand All @@ -35,4 +35,3 @@ def notify_completed
end
end
end

10 changes: 6 additions & 4 deletions lib/travis/addons/helpers/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ def tags

include Coder

def run_task(queue, *args)
QUEUE = :'notifications'

def run_task(*args)
target = "Travis::Addons::#{self.class.name.split('::').last}::Task"
args = deep_clean_strings(args)

::Sidekiq::Client.push(
'queue' => queue,
'class' => 'Travis::Async::Sidekiq::Worker',
'args' => [nil, target, 'perform', *args]
'queue' => QUEUE,
'class' => 'Travis::Async::Sidekiq::Worker',
'args' => [nil, target, 'perform', *args]
)
rescue => e
Exceptions.handle(Error.new(e, queue, args)) # TODO pass in
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/campfire_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:campfire, is_a(Hash), targets: ['room'])
handler.expects(:run_task).with(is_a(Hash), targets: ['room'])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
let(:recipient) { '[email protected]' }

it 'enqueues a task' do
handler.expects(:run_task).with(:email, is_a(Hash), recipients: [recipient], broadcasts: [{ message: 'message' }])
handler.expects(:run_task).with(is_a(Hash), recipients: [recipient], broadcasts: [{ message: 'message' }])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/flowdock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:flowdock, is_a(Hash), targets: ['room'])
handler.expects(:run_task).with(is_a(Hash), targets: ['room'])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/github_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
before { permissions.create(user: admin, admin: true) }

it 'enqueues a task' do
handler.expects(:run_task).with(:github_status, is_a(Hash), tokens: { 'admin' => 'admin-token' })
handler.expects(:run_task).with(is_a(Hash), tokens: { 'admin' => 'admin-token' })
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/hipchat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:hipchat, is_a(Hash), targets: ['room'])
handler.expects(:run_task).with(is_a(Hash), targets: ['room'])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/irc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:irc, is_a(Hash), channels: ['channel'])
handler.expects(:run_task).with(is_a(Hash), channels: ['channel'])
handler.handle
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/travis/addons/handlers/pusher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

it 'enqueues a task' do
::Sidekiq::Client.expects(:push).with do |payload|
expect(payload['queue']).to eq(:'pusher-live')
expect(payload['queue']).to eq(:'live-updates')
expect(payload['class']).to eq('Travis::Async::Sidekiq::Worker')
expect(payload['method']).to eq('perform')
expect(payload['args'][3]).to be_a(Hash)
Expand All @@ -50,7 +50,7 @@

it 'enqueues a task' do
::Sidekiq::Client.expects(:push).with do |payload|
expect(payload['queue']).to eq(:'pusher-live')
expect(payload['queue']).to eq(:'live-updates')
expect(payload['class']).to eq('Travis::Async::Sidekiq::Worker')
expect(payload['method']).to eq('perform')
expect(payload['args'][3]).to be_a(Hash)
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/pushover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:pushover, is_a(Hash), users: ['user'], api_key: 'api_key')
handler.expects(:run_task).with(is_a(Hash), users: ['user'], api_key: 'api_key')
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/slack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:slack, is_a(Hash), targets: ['room'])
handler.expects(:run_task).with(is_a(Hash), targets: ['room'])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/sqwiggle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:sqwiggle, is_a(Hash), targets: ['room'])
handler.expects(:run_task).with(is_a(Hash), targets: ['room'])
handler.handle
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/travis/addons/handlers/webhook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

describe 'handle' do
it 'enqueues a task' do
handler.expects(:run_task).with(:webhook, is_a(Hash), targets: ['http://host.com/target'], token: 'token')
handler.expects(:run_task).with(is_a(Hash), targets: ['http://host.com/target'], token: 'token')
handler.handle
end
end
Expand Down