Sha256: d4c72c6643048c7c82db1ee1e6702d8a61f5b0b0ac328b572eca6931f7f0a511

Contents?: true

Size: 1.08 KB

Versions: 32

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

class JobTemplatesControllerTest < ActionController::TestCase
  context '#preview' do
    let(:template) { FactoryBot.create(:job_template) }
    let(:host) { FactoryBot.create(:host, :managed) }

    test 'should render a preview version of a template' do
      post :preview, params: { job_template: template.to_param, template: 'uptime' }, session: set_session_user
      assert_response :success
    end

    test 'should render a preview version of a template for a specific host' do
      post :preview, params: {
        job_template: template.to_param,
        template: '<%= @host.name %>',
        preview_host_id: host.id
      }, session: set_session_user
      assert_response :success
      assert_equal host.name, @response.body
    end

    test 'should render a error message when template has errors' do
      InputTemplateRenderer.any_instance.stubs(:render).returns(false)
      post :preview, params: { job_template: template.to_param }, session: set_session_user
      assert_response :not_acceptable
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
foreman_remote_execution-1.7.1 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.7.0 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.7 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.6 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.5 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.4 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.5.6 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.3 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.2 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.5.5 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.1 test/functional/job_templates_controller_test.rb
foreman_remote_execution-1.6.0 test/functional/job_templates_controller_test.rb