Sha256: e41c747d5cc08675be40c4ec6d1645c3e551a301eaa5622347a9b912a12ab0d8

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

module Shipit
  class TaskDefinitionsTest < ActiveSupport::TestCase
    setup do
      @definition = TaskDefinition.new(
        'restart',
        'action' => 'Restart application',
        'description' => 'Restart app and job servers',
        'steps' => ['touch tmp/restart'],
        'allow_concurrency' => true,
        'variables' => [
          {'name' => 'FOO', 'title' => 'Set to 0 to foo', 'default' => '1'},
          {'name' => 'BAR', 'title' => 'Set to 1 to bar', 'default' => '0'},
        ],
      )
    end

    test ".load returns nil if payload is nil or blank" do
      assert_nil TaskDefinition.load('')
      assert_nil TaskDefinition.load(nil)
    end

    test ".dump returns nil if given nil" do
      assert_nil TaskDefinition.dump(nil)
    end

    test "serialization works" do
      as_json = {
        id: 'restart',
        action: 'Restart application',
        description: 'Restart app and job servers',
        steps: ['touch tmp/restart'],
        checklist: [],
        allow_concurrency: true,
        variables: [
          {'name' => 'FOO', 'title' => 'Set to 0 to foo', 'default' => '1'},
          {'name' => 'BAR', 'title' => 'Set to 1 to bar', 'default' => '0'},
        ],
      }
      assert_equal as_json, TaskDefinition.load(TaskDefinition.dump(@definition)).as_json
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shipit-engine-0.13.0 test/models/task_definitions_test.rb
shipit-engine-0.12.1 test/models/task_definitions_test.rb
shipit-engine-0.12.0 test/models/task_definitions_test.rb
shipit-engine-0.11.0 test/models/task_definitions_test.rb
shipit-engine-0.10.0 test/models/task_definitions_test.rb
shipit-engine-0.9.0 test/models/task_definitions_test.rb
shipit-engine-0.8.9 test/models/task_definitions_test.rb
shipit-engine-0.8.8 test/models/task_definitions_test.rb
shipit-engine-0.8.7 test/models/task_definitions_test.rb
shipit-engine-0.8.6 test/models/task_definitions_test.rb
shipit-engine-0.8.5 test/models/task_definitions_test.rb
shipit-engine-0.8.4 test/models/task_definitions_test.rb
shipit-engine-0.8.3 test/models/task_definitions_test.rb
shipit-engine-0.8.2 test/models/task_definitions_test.rb
shipit-engine-0.8.1 test/models/task_definitions_test.rb
shipit-engine-0.8.0 test/models/task_definitions_test.rb