Sha256: 80ffaef548d9fab193ce2c6ddc21fd5567f280a7e06d196412eaf17d5fc0900a

Contents?: true

Size: 1.51 KB

Versions: 26

Compression:

Stored size: 1.51 KB

Contents

FactoryGirl.define do
  factory :some_task, :class => ForemanTasks::Task do
    sequence(:label) { |n| "task#{n}" }
    type 'ForemanTasks::Task'
    state 'stopped'
    result 'success'

    transient do
      set_owner nil
    end

    after(:create) do |task, evaluator|
      ForemanTasks::Lock.owner!(evaluator.set_owner, task.id) if evaluator.set_owner
    end

    factory :dynflow_task, :class => ForemanTasks::Task::DynflowTask do
      label "Support::DummyDynflowAction"
      type "ForemanTasks::Task::DynflowTask"
      started_at "2014-10-01 11:15:55"
      ended_at "2014-10-01 11:15:57"
      state "stopped"
      result "success"
      parent_task_id nil

      transient do
        sync_with_dynflow false
      end

      after(:build) do |task, evaluator|
        execution_plan = ForemanTasks.dynflow.world.plan(Support::DummyDynflowAction)
        # remove the task created automatically by the persistence
        ForemanTasks::Task.where(:external_id => execution_plan.id).delete_all
        task.update_attributes!(:external_id => execution_plan.id)
        if evaluator.sync_with_dynflow
          task.update_from_dynflow(execution_plan.to_hash)
        end
      end

      trait :user_create_task do
        label "Actions::User::Create"
      end

      trait :product_create_task do
        label "Actions::Katello::Product::Create"
      end

      trait :inconsistent_dynflow_task do
        after(:build) do |task|
          task.update_attributes!(:state => 'running')
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foreman-tasks-0.8.6 test/factories/task_factory.rb
foreman-tasks-0.8.5 test/factories/task_factory.rb
foreman-tasks-0.8.4 test/factories/task_factory.rb
foreman-tasks-0.8.3 test/factories/task_factory.rb
foreman-tasks-0.8.2 test/factories/task_factory.rb
foreman-tasks-0.8.1 test/factories/task_factory.rb
foreman-tasks-0.8.0 test/factories/task_factory.rb
foreman-tasks-0.7.20 test/factories/task_factory.rb
foreman-tasks-0.7.19 test/factories/task_factory.rb
foreman-tasks-0.7.18 test/factories/task_factory.rb
foreman-tasks-0.7.17 test/factories/task_factory.rb
foreman-tasks-0.7.16 test/factories/task_factory.rb
foreman-tasks-0.7.15 test/factories/task_factory.rb
foreman-tasks-0.7.14 test/factories/task_factory.rb
foreman-tasks-0.7.13 test/factories/task_factory.rb
foreman-tasks-0.7.12 test/factories/task_factory.rb
foreman-tasks-0.7.11 test/factories/task_factory.rb
foreman-tasks-0.7.10 test/factories/task_factory.rb
foreman-tasks-0.7.9 test/factories/task_factory.rb
foreman-tasks-0.7.8 test/factories/task_factory.rb