Sha256: f39cfe0a66575b0dc8934b7f286ffc06d7d8c60ca26b7de467a93abed9748897
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
require 'null_logger' require 'gds_zendesk/field_mappings' require 'zendesk_api/error' module GDSZendesk class DummyClient attr_reader :ticket, :users def initialize(options) @logger = options[:logger] || NullLogger.instance @ticket = DummyTicket.new(@logger) @users = DummyUsers.new(@logger) end end class DummyTicket attr_reader :options def initialize(logger) @logger = logger end def create!(options) @options = options if should_raise_error? @logger.info("Simulating Zendesk ticket creation failure: #{options.inspect}") raise ZendeskAPI::Error::RecordInvalid.new(body: {"details" => "sample error message from Zendesk"}) else @logger.info("Zendesk ticket created: #{options.inspect}") end end protected def should_raise_error? description =~ /break_zendesk/ or comment =~ /break_zendesk/ end def description @options[:description] end def comment @options[:comment][:value] unless @options[:comment].nil? end end class DummyUsers def initialize(logger) @logger = logger end def search(attributes) [] end def suspended?(user_email) false end def create!(new_user_attributes) @created_user_attributes = new_user_attributes @logger.info("Zendesk user created: #{new_user_attributes.inspect}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems