require 'active_support'
require 'singletrack/logging'
require 'timecop'

describe 'logger' do
  # it "test timings" do
  #   ENV['SUPPORT_REPEAT_TIMEOUT_MINUTES'] = '1'
  #
  #   logger = ActiveSupport::Logger.new(STDOUT)
  #
  #   # delete existing tickets
  #   logger.zendesk.client.tickets.all do |ticket|
  #     logger.zendesk.client.tickets.destroy(:id => ticket.id)
  #   end
  #
  #   # should just create two tickets
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   logger.zendesk.client.tickets.all { |ticket| }
  #   expect(logger.zendesk.client.tickets.fetch.count).to eq(2)
  #
  #   # delete existing tickets
  #   logger.zendesk.client.tickets.all do |ticket|
  #     logger.zendesk.client.tickets.destroy(:id => ticket.id)
  #   end
  #
  #   expect(logger.zendesk.client.tickets.fetch.count).to eq(0)
  #
  #   # should just create two tickets
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   logger.zendesk.client.tickets.all { |ticket| }
  #   expect(logger.zendesk.client.tickets.fetch.count).to eq(2)
  #
  #   # Timecop.travel(DateTime.now + 3.hours)
  #   sleep(70)
  #
  #   # should add one comment to each ticket
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   # Timecop.travel(DateTime.now + 3.hours)
  #   sleep(70)
  #
  #   # should add another comment to each ticket
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   logger.zendesk.client.tickets.all { |ticket| }
  #   expect(logger.zendesk.client.tickets.fetch.count).to eq(2)
  #
  #   # close the existing tickets
  #   logger.zendesk.client.tickets.all do |ticket|
  #     ticket.status = 'closed'
  #     ticket.save
  #   end
  #
  #   # should create two new tickets
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   # Timecop.travel(DateTime.now + 3.hours)
  #   sleep(70)
  #
  #   # should add one comment to each of the new tickets
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #   logger.support_ticket 'Testing 123'
  #   logger.support_ticket 'Testing 234'
  #
  #   logger.zendesk.client.tickets.all { |ticket| }
  #   expect(logger.zendesk.client.tickets.fetch.count).to eq(4)
  #
  #   # Timecop.return
  #
  # end
end
