GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 12. April, ab 19:00 Uhr nicht zur Verfügung.

Handle excpetion in PluginWorker

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 4b998239
......@@ -5,5 +5,7 @@ class PluginWorker
def perform(file_name, data)
Gitlab::Plugin.execute(file_name, data)
rescue => e
Rails.logger.error("#{self.class}: #{e.message}")
end
end
require 'spec_helper'
describe PluginWorker do
include RepoHelpers
subject { described_class.new }
let(:filename) { 'my_plugin.rb' }
describe '#perform' do
it 'executes Gitlab::Plugin with expected values' do
data = { 'event_name' => 'project_create' }
allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_return(true)
expect(subject.perform(filename, data)).to be_truthy
end
it 'handles exception well' do
data = { 'event_name' => 'project_create' }
allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_raise('Permission denied')
expect { subject.perform(filename, data) }.to_not raise_error
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