Sha256: 58ebbf01b933e27d7083157e1d5083abac7e6704b0f3a631214cb228814ebb5c

Contents?: true

Size: 890 Bytes

Versions: 19

Compression:

Stored size: 890 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

    def proxy
      self.class.proxy
    end

    def proxy_action_name
      'Proxy::DummyAction'
    end

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

    def self.proxy
      @proxy
    end

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
foreman-tasks-0.8.0 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.20 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.19 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.18 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.17 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.16 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.15 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.14 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.13 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.12 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.11 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.10 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.9 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.8 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.7 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.6 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.5 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.4 test/support/dummy_proxy_action.rb
foreman-tasks-0.7.3 test/support/dummy_proxy_action.rb