Sha256: 306277603185735cd0595d49115c6ba9f5aeedb4b0beed48885673a4a6b71246

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

module Shipit
  module Api
    class TasksControllerTest < ActionController::TestCase
      setup do
        @stack = shipit_stacks(:shipit)
        authenticate!
      end

      test "#index returns a list of tasks" do
        task = @stack.tasks.last

        get :index, stack_id: @stack.to_param
        assert_response :ok
        assert_json '0.id', task.id
      end

      test "#show returns a task" do
        task = @stack.tasks.last

        get :show, stack_id: @stack.to_param, id: task.id
        assert_response :ok
        assert_json 'id', task.id
      end

      test "#trigger triggers a custom task" do
        post :trigger, stack_id: @stack.to_param, task_name: 'restart'
        assert_response :accepted
        assert_json 'type', 'task'
        assert_json 'status', 'pending'
      end

      test "#trigger returns a 404 when the task doesn't exist" do
        post :trigger, stack_id: @stack.to_param, task_name: 'doesnt_exist'
        assert_response :not_found
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shipit-engine-0.7.0 test/controllers/api/tasks_controller_test.rb
shipit-engine-0.6.4 test/controllers/api/tasks_controller_test.rb
shipit-engine-0.6.3 test/controllers/api/tasks_controller_test.rb
shipit-engine-0.6.2 test/controllers/api/tasks_controller_test.rb
shipit-engine-0.6.1 test/controllers/api/tasks_controller_test.rb
shipit-engine-0.6.0 test/controllers/api/tasks_controller_test.rb