FactoryBot.define do
  factory :workflow_instance do
    after(:build){|instance| instance.setup_workflow_steps }
    state "unplanned" # default for Vula

    trait :uncategorized do
        state 'uncategorized'
    end

    trait :unplanned do
      state 'unplanned'
    end

    trait :planned do
      state 'planned'
    end

    trait :active do
      state 'active'
      after :build do |instance|
        instance.workflow_steps.first.state = 'processing'
      end
    end

    trait :overdue do
      state 'overdue'
    end

    trait :all_completed do
      state 'all_completed'
      after :build do |instance|
        instance.workflow_steps.each{|workflow_step| workflow_step.state = 'completed' }
      end
    end

    trait :any_rejected do
      state 'any_rejected'
      after :build do |instance|
        instance.workflow_steps.first.state = 'rejected'
      end
    end

    trait :with_values do
      #TODO: fill with reasonable values

    end
  end
end

