Sha256: e1de94d72aa640e040df4aaec81dbc64196b559986dfcd3f43419c9d9d8f05c2

Contents?: true

Size: 1.99 KB

Versions: 3

Compression:

Stored size: 1.99 KB

Contents

require 'test_plugin_helper'

module ForemanSalt
  class SaltModuleTest < ActionDispatch::IntegrationTest
    setup do
      User.current = User.anonymous_admin

      states = %w(state1 state2 state3 state4)
      state_list = {'env1' => states, 'env2' => states}

      ::ProxyAPI::Salt.any_instance.stubs(:states_list).returns(state_list)
    end

    test 'index page' do
      FactoryGirl.create_list :salt_module, 5
      assert_index_page(salt_modules_path, 'Salt State', 'New Salt State')
    end

    test 'create new page' do
      assert_new_button(salt_modules_path, 'New Salt State', new_salt_module_path)
      fill_in 'foreman_salt_salt_module_name', :with => 'common'
      assert_submit_button(salt_modules_path)
      assert page.has_link? 'common'
    end

    test 'edit page' do
      salt_module = FactoryGirl.create :salt_module
      visit salt_modules_path
      click_link salt_module.name
      fill_in :foreman_salt_salt_module_name, :with => 'some_other_name'
      assert_submit_button(salt_modules_path)
      assert page.has_link? 'some_other_name'
    end

    test 'import states' do
      proxy = FactoryGirl.create :smart_proxy, :with_salt_feature
      state = FactoryGirl.create :salt_module, :salt_environments => [FactoryGirl.create(:salt_environment)]

      visit salt_modules_path
      click_link "Import from #{proxy.name}"

      assert page.has_selector?('td', :text => 'env1'), 'Could not find env1 on importer page'
      assert page.has_selector?('td', :text => 'Add'), 'Could not find env1 on importer page'
      assert page.has_selector?('td', :text => 'state1, state2, state3, and state4'), 'Could not find states on importer page'

      assert page.has_selector?('td', :text => 'Remove'), 'Could not find remove on importer page'
      assert page.has_selector?('td', :text => state.name), 'Could not find state to remove'

      all('input.state_check').each { |checkbox| check(checkbox[:id]) }

      click_button 'Update'
      assert page.has_link? 'state1'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_salt-3.0.2 test/integration/salt_module_test.rb
foreman_salt-3.0.1 test/integration/salt_module_test.rb
foreman_salt-3.0.0 test/integration/salt_module_test.rb