Sha256: b04a1a47121c686a33e7292f6ab09b4d87e5bc8a8a83e70b87b032bad0583665

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

module Helpers
  class JobHelperTest < ActionView::TestCase
    let(:helper) { ::Helpers::JobHelper }
    # let(:host) { FactoryBot.create(:host) }
    let(:job_template) do
      FactoryBot.create(:job_template, template: 'echo "1"', job_category: 'leapp',
                                       provider_type: 'SSH', name: 'Leapp preupgrade')
    end
    let(:job_invocation) { FactoryBot.create(:job_invocation, job_category: ::ForemanLeapp::JOB_CATEGORY) }

    describe 'correct_feature?' do
      setup do
        RemoteExecutionFeature.find_by(label: 'leapp_preupgrade').update(job_template: job_template)
        FactoryBot.create(:template_invocation, template: job_template, job_invocation: job_invocation)
      end

      it 'correct category & feature' do
        assert helper.correct_feature?(job_invocation, 'leapp_preupgrade')
      end

      it 'wrong category' do
        job_invocation = FactoryBot.create(:job_invocation, job_category: 'NOPE')
        FactoryBot.create(:template_invocation, template: job_template, job_invocation: job_invocation)

        assert_not helper.correct_feature?(job_invocation, 'leapp_preupgrade')
      end

      it 'wrong feature' do
        assert_not helper.correct_feature?(job_invocation, 'leapp_preupgrade2')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foreman_leapp-0.1.2 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.1.1 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.1.0 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.0.6 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.0.5 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.0.4 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.0.3 test/unit/helpers/job_helper_test.rb
foreman_leapp-0.0.2 test/unit/helpers/job_helper_test.rb