Sha256: d1a4952fd0554c86e533825c6aba243023c2e1a83d5f97fc8743669cf358b0d1

Contents?: true

Size: 1.86 KB

Versions: 2

Compression:

Stored size: 1.86 KB

Contents

require "foreman_tasks_test_helper"

module ForemanTasks
  class TasksHelperTest < ActionView::TestCase

    describe 'when formatting simple input' do
      before do
        @task = FactoryGirl.build(:dynflow_task, :user_create_task)
        humanized = {:action=>"Create", :input=>[[:user, {:text=>"user 'Anonymous Admin'", :link=>nil}]], :output=>"", :errors=>[]}
        @task.stubs(:input).returns({"user"=>{"id"=>1, "name"=>"Anonymous Admin"}, "locale"=>"en"})
        @task.stubs(:humanized).returns(humanized)
      end

      it 'formats the task input properly' do
        expects(:h).with("user 'Anonymous Admin'")
        format_task_input(@task)
        expects(:h).with("Create user 'Anonymous Admin'")
        format_task_input(@task, true)
      end

    end

    describe 'when formatting input' do
      before do
        @task = FactoryGirl.build(:dynflow_task, :product_create_task)
        humanized = {:action=>"Create",
                     :input=>[[:product, {:text=>"product 'product-2'", :link=>"#/products/3/info"}], [:organization, {:text=>"organization 'test-0'", :link=>"/organizations/3/edit"}]],
                     :output=>"",
                     :errors=>[]}
        input = {"product"=>{"id"=>3, "name"=>"product-2", "label"=>"product-2", "cp_id"=>nil},
                 "provider"=>{"id"=>3, "name"=>"Anonymous"},
                 "organization"=>{"id"=>3, "name"=>"test-0", "label"=>"test-0"},
                 "cp_id"=>"1412251033866",
                 "locale"=>"en"}
        @task.stubs(:input).returns(input)
        @task.stubs(:humanized).returns(humanized)
      end

      it 'formats the task input properly' do
        response = "product 'product-2'; organization 'test-0'"
        expects(:h).with(response)
        format_task_input(@task)
        expects(:h).with("Create #{response}")
        format_task_input(@task, true)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman-tasks-0.6.12 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.6.11 test/helpers/foreman_tasks/tasks_helper_test.rb