Sha256: 55700808f690344dd90adb449863ec0a47586c6d45ab8e13c072ad87e7cf1422

Contents?: true

Size: 1.93 KB

Versions: 49

Compression:

Stored size: 1.93 KB

Contents

require 'foreman_tasks_test_helper'

module ForemanTasks
  class TasksHelperTest < ActionView::TestCase
    describe 'when formatting simple input' do
      before do
        @task = FactoryBot.build(:dynflow_task, :user_create_task)
        humanized = { :humanized_name => 'Create', :humanized_input => [[:user, { :text => "user 'Anonymous Admin'", :link => nil }]] }
        @task.instance_variable_set('@humanized_cache', humanized)
        @task.stubs(:input).returns('user' => { 'id' => 1, 'name' => 'Anonymous Admin' }, 'locale' => 'en')
        @task.stubs(:action).returns(@task.to_label)
      end

      it 'formats the task input properly' do
        format_task_input(@task).must_equal("Create user 'Anonymous Admin'")
      end

      it 'displays the dash if task is nil' do
        format_task_input(nil).must_equal('-')
      end
    end

    describe 'when formatting input' do
      before do
        @task = FactoryBot.build(:dynflow_task, :product_create_task)
        humanized = { :humanized_name => 'Create',
                      :humanized_input => [[:product, { :text => "product 'product-2'", :link => '#/products/3/info' }], [:organization, { :text => "organization 'test-0'", :link => '/organizations/3/edit' }]] }
        @task.instance_variable_set('@humanized_cache', humanized)
        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(:action).returns(@task.to_label)
      end

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

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
foreman-tasks-2.0.3 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-2.0.2 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.1.3 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.1.2 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-2.0.1 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-2.0.0 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.2.0 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.1.1 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.1.0 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.6 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.0.1 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-1.0.0 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.5 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.4 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.3 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.2 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.16.3 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.17.1 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.15.11 test/helpers/foreman_tasks/tasks_helper_test.rb
foreman-tasks-0.16.2 test/helpers/foreman_tasks/tasks_helper_test.rb