Sha256: 0909db67d75f4b515358149d9000b9c43af1a1b433971c1c4b31a835e6fed58e
Contents?: true
Size: 1.34 KB
Versions: 9
Compression:
Stored size: 1.34 KB
Contents
require 'null_logger' 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_or_update_user(new_attributes) @logger.info("Zendesk user created or updated: #{new_attributes.inspect}") end end end
Version data entries
9 entries across 9 versions & 1 rubygems