Sha256: 1cfab2de27e3329506f19a296c89e2880acffd4fe6bdb34905d66a3231c2429f

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

require 'rails_helper'

module RailsWorkflow
  RSpec.describe OperationTemplate, :type => :model do

    let(:template) { create :process_template }

    it 'should create operation template of a given type' do
      operation_template = OperationTemplate.
          create! (
                      {
                          title: 'First Test project',
                          process_template_id: template.id,
                          type: "RailsWorkflow::CustomOperationTemplate"
                      }
                  )
      expect(operation_template).to be_instance_of(RailsWorkflow::CustomOperationTemplate)
    end

    it 'should return only independent operations' do
      operation = create :operation_template, process_template: template

      dependencies = [
          {
              "id" => operation.id,
              "statuses" => [RailsWorkflow::Operation::DONE]
          }
      ]

      create :operation_template, process_template: template, dependencies: dependencies
      expect(RailsWorkflow::OperationTemplate.independent_only.to_a).to match_array([operation])
    end


    def dependencies=(dependencies)
      write_attribute(:dependencies, dependencies.to_json.to_s)
    end

    def dependencies
      value = read_attribute(:dependencies)
      if value.present?
        JSON.parse(value)
      else
        []
      end
    end



  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_workflow-0.3.4 spec/models/rails_workflow/operation_template_spec.rb
rails_workflow-0.3.3 spec/models/rails_workflow/operation_template_spec.rb
rails_workflow-0.3.2 spec/models/rails_workflow/operation_template_spec.rb
rails_workflow-0.3.1 spec/models/rails_workflow/operation_template_spec.rb
rails_workflow-0.3.0 spec/models/rails_workflow/operation_template_spec.rb
rails_workflow-0.2.2 spec/models/rails_workflow/operation_template_spec.rb