Sha256: 41c84495c1c94ee125899db218e2774ff01d8d1c0c36c039de423046b1837d75

Contents?: true

Size: 991 Bytes

Versions: 20

Compression:

Stored size: 991 Bytes

Contents

module Support
  class DummyProxyAction < Actions::ProxyAction
    class DummyProxy
      attr_reader :log, :task_triggered

      def initialize
        @log = Hash.new { |h, k| h[k] = [] }
        @task_triggered = Concurrent.future
      end

      def trigger_task(*args)
        @log[:trigger_task] << args
        @task_triggered.success(true)
        { 'task_id' => '123' }
      end

      def cancel_task(*args)
        @log[:cancel_task] << args
      end

      def url
        'proxy.example.com'
      end
    end

    class ProxySelector < ::ForemanTasks::ProxySelector
      def available_proxies
        { :global => [DummyProxyAction.proxy] }
      end
    end

    def proxy
      self.class.proxy
    end

    def task
      super
    rescue ActiveRecord::RecordNotFound
      ForemanTasks::Task::DynflowTask.new.tap { |task| task.id = '123' }
    end

    class << self
      attr_reader :proxy
    end

    def self.reset
      @proxy = DummyProxy.new
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman-tasks-0.11.3 test/support/dummy_proxy_action.rb
foreman-tasks-0.11.2 test/support/dummy_proxy_action.rb
foreman-tasks-0.11.1 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.9 test/support/dummy_proxy_action.rb
foreman-tasks-0.11.0 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.8 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.7 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.6 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.4 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.6 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.3 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.2 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.1 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.5 test/support/dummy_proxy_action.rb
foreman-tasks-0.10.0 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.4 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.3 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.2 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.1 test/support/dummy_proxy_action.rb
foreman-tasks-0.9.0 test/support/dummy_proxy_action.rb