Fixed issue #2040: Zendesk import: To/From extraction for system comments fails.

This commit is contained in:
Thorsten Eckel 2018-05-23 18:53:07 +02:00
parent c21be6e928
commit ad3362e94c
2 changed files with 45 additions and 3 deletions

View file

@ -9,9 +9,12 @@ class Sequencer
uses :resource
def value
method_name = resource.via.channel.to_sym
return if !respond_to?(method_name, true)
send(method_name)
return if private_methods(false).exclude?(value_method_name)
send(value_method_name)
end
def value_method_name
@value_method_name ||= resource.via.channel.to_sym
end
end
end

View file

@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.describe Sequencer::Unit::Import::Zendesk::Ticket::Comment::SourceBased, sequencer: :unit do
before(:all) do
described_class.class_eval do
private
def email
'test@example.com'
end
end
end
def parameters_for_channel(channel)
{
resource: double(
via: double(
channel: channel
)
)
}
end
context 'for resource.via.channel attribute' do
it 'provides from existing method' do
provided = process(parameters_for_channel('email'))
expect(provided[:source_based]).to eq('test@example.com')
end
it 'provides nil for non existing method' do
provided = process(parameters_for_channel('system'))
expect(provided[:source_based]).to be_nil
end
end
end