Sha256: a204c2a5d6c1689a2ec2d1ad34d812220360e16c7c835cc0e5f0dea8bd942be5

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'test_plugin_helper'

class PreupgradeReportsControllerTest < ActionController::TestCase
  setup do
    @user = FactoryBot.create(:user, admin: false)
    @host = FactoryBot.create :host
    FactoryBot.create :preupgrade_report, host: @host
  end

  test 'should get :index' do
    get :index
    assert_response :success
    assert_not_empty JSON.parse(@response.body)['results']
  end

  test 'should get :index with :view_job_invocations & :view_hosts' do
    setup_user 'view', 'job_invocations', nil, @user
    setup_user 'view', 'hosts', nil, @user
    get :index, session: set_session_user(@user)
    assert_response :success
    assert_not_empty JSON.parse(@response.body)['results']
  end

  test 'should not get :index without :view_job_invocations' do
    setup_user 'view', 'hosts', nil, @user
    get :index, session: set_session_user(@user)
    assert_response :forbidden
    assert_includes JSON.parse(@response.body)['error']['missing_permissions'], 'view_job_invocations'
  end

  test 'should not get :index without :view_hosts' do
    setup_user 'view', 'job_invocations', nil, @user
    get :index, session: set_session_user(@user)
    assert_response :forbidden
    assert_includes JSON.parse(@response.body)['error']['missing_permissions'], 'view_hosts'
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
foreman_leapp-2.0.1 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-2.0.0 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-1.2.1 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-1.2.0 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.15 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-1.1.1 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-1.1.0 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-1.0.0 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.14 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.13 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.12 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.11 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.10 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.9 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.8 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.7 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.6 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.5 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.4 test/functional/preupgrade_reports_controller_test.rb
foreman_leapp-0.1.3 test/functional/preupgrade_reports_controller_test.rb