foreman_remote_execution 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +11 -9
  3. data/.rubocop_todo.yml +146 -116
  4. data/app/controllers/api/v2/job_invocations_controller.rb +6 -1
  5. data/app/controllers/api/v2/job_templates_controller.rb +0 -1
  6. data/app/controllers/job_invocations_controller.rb +6 -1
  7. data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
  8. data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +3 -0
  9. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +1 -1
  10. data/app/models/concerns/foreman_remote_execution/subnet_extensions.rb +1 -1
  11. data/app/models/foreign_input_set.rb +1 -1
  12. data/app/models/job_invocation.rb +1 -1
  13. data/app/models/job_invocation_composer.rb +2 -2
  14. data/app/models/job_invocation_task_group.rb +1 -1
  15. data/app/models/job_template.rb +3 -3
  16. data/app/models/job_template_effective_user.rb +1 -1
  17. data/app/models/remote_execution_feature.rb +1 -1
  18. data/app/models/target_remote_execution_proxy.rb +1 -1
  19. data/app/models/targeting.rb +2 -2
  20. data/app/models/targeting_host.rb +1 -1
  21. data/app/models/template_input.rb +1 -1
  22. data/app/models/template_invocation.rb +1 -1
  23. data/app/models/template_invocation_input_value.rb +1 -1
  24. data/db/migrate/20150612121541_add_job_template_to_template.rb +1 -1
  25. data/db/migrate/20150616080015_create_template_input.rb +1 -1
  26. data/db/migrate/20150708133241_add_targeting.rb +1 -1
  27. data/db/migrate/20150708133242_add_invocation.rb +1 -1
  28. data/db/migrate/20150708133305_add_template_invocation.rb +1 -1
  29. data/db/migrate/20150812110800_add_resolved_at_to_targeting.rb +1 -1
  30. data/db/migrate/20150812145900_add_last_task_id_to_job_invocation.rb +1 -1
  31. data/db/migrate/20150826191632_create_target_remote_execution_proxies.rb +1 -1
  32. data/db/migrate/20150827144500_change_targeting_search_query_type.rb +1 -1
  33. data/db/migrate/20150827152730_add_options_to_template_input.rb +1 -1
  34. data/db/migrate/20150903192731_add_execution_to_interface.rb +2 -2
  35. data/db/migrate/20150923125825_add_job_invocation_task_group.rb +1 -1
  36. data/db/migrate/20151013135415_add_pub_key_to_smart_proxy.rb +1 -1
  37. data/db/migrate/20151022105508_rename_last_task_id_column.rb +1 -1
  38. data/db/migrate/20151116105412_add_triggering_to_job_invocation.rb +1 -1
  39. data/db/migrate/20151120171100_add_effective_user_to_template_invocation.rb +1 -1
  40. data/db/migrate/20151124162300_create_job_template_effective_users.rb +1 -1
  41. data/db/migrate/20151203100824_add_description_to_job_invocation.rb +1 -1
  42. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +2 -2
  43. data/db/migrate/20151217092555_migrate_to_task_groups.rb +2 -2
  44. data/db/migrate/20160108134600_create_template_input_sets.rb +1 -1
  45. data/db/migrate/20160108141144_make_job_name_default_to_something.rb +1 -1
  46. data/db/migrate/20160111113032_upcase_ssh_feature.rb +2 -2
  47. data/db/migrate/20160113161916_add_run_host_job_task_id_to_template_invocation.rb +1 -1
  48. data/db/migrate/20160113162007_expand_all_template_invocations.rb +3 -3
  49. data/db/migrate/20160114120200_rename_job_categories.rb +1 -1
  50. data/db/migrate/20160114125628_rename_job_name_to_job_category.rb +1 -1
  51. data/db/migrate/20160118124600_create_remote_execution_features.rb +1 -1
  52. data/db/migrate/20160125155108_make_job_template_name_unique.rb +1 -1
  53. data/db/migrate/20160127134031_add_advanced_to_template_input.rb +1 -1
  54. data/db/migrate/20160127162711_reword_puppet_template_description.rb +1 -1
  55. data/db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb +1 -1
  56. data/db/migrate/20160926225841_update_template_input_value.rb +1 -1
  57. data/db/migrate/20170110145641_add_host_action_button_to_remote_execution_feature.rb +1 -1
  58. data/db/migrate/20170613101039_add_timeout_to_job_templates_and_job_invocations.rb +1 -1
  59. data/db/migrate/20180110104432_rename_template_invocation_permission.rb +25 -0
  60. data/db/migrate/20180112125015_fix_taxable_taxonomies_job_template.rb +14 -0
  61. data/db/seeds.d/90-bookmarks.rb +1 -1
  62. data/foreman_remote_execution.gemspec +2 -1
  63. data/lib/foreman_remote_execution/engine.rb +3 -3
  64. data/lib/foreman_remote_execution/version.rb +1 -1
  65. data/test/benchmark/run_hosts_job_benchmark.rb +10 -10
  66. data/test/benchmark/targeting_benchmark.rb +6 -6
  67. data/test/factories/foreman_remote_execution_factories.rb +14 -14
  68. data/test/functional/api/v2/foreign_input_sets_controller_test.rb +10 -15
  69. data/test/functional/api/v2/job_invocations_controller_test.rb +19 -8
  70. data/test/functional/api/v2/job_templates_controller_test.rb +12 -16
  71. data/test/functional/api/v2/remote_execution_features_controller_test.rb +3 -4
  72. data/test/functional/api/v2/template_inputs_controller_test.rb +8 -13
  73. data/test/test_plugin_helper.rb +4 -4
  74. data/test/unit/actions/run_hosts_job_test.rb +3 -3
  75. data/test/unit/concerns/exportable_test.rb +1 -1
  76. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +2 -2
  77. data/test/unit/concerns/host_extensions_test.rb +20 -20
  78. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  79. data/test/unit/input_template_renderer_test.rb +86 -86
  80. data/test/unit/job_invocation_composer_test.rb +17 -16
  81. data/test/unit/job_invocation_test.rb +10 -10
  82. data/test/unit/job_template_effective_user_test.rb +2 -2
  83. data/test/unit/job_template_importer_test.rb +3 -3
  84. data/test/unit/job_template_test.rb +15 -15
  85. data/test/unit/remote_execution_feature_test.rb +3 -3
  86. data/test/unit/remote_execution_provider_test.rb +15 -15
  87. data/test/unit/targeting_test.rb +3 -3
  88. data/test/unit/template_input_test.rb +1 -1
  89. data/test/unit/template_invocation_input_value_test.rb +17 -17
  90. metadata +19 -77
  91. data/doc/.gitignore +0 -7
  92. data/doc/Gemfile +0 -7
  93. data/doc/Rakefile +0 -41
  94. data/doc/_config.yml +0 -33
  95. data/doc/plugins/alert_block.rb +0 -27
  96. data/doc/plugins/div_tag.rb +0 -24
  97. data/doc/plugins/graphviz.rb +0 -121
  98. data/doc/plugins/plantuml.rb +0 -84
  99. data/doc/plugins/play.rb +0 -13
  100. data/doc/plugins/tags.rb +0 -137
  101. data/doc/plugins/toc.rb +0 -19
  102. data/doc/source/.nojekyll +0 -0
  103. data/doc/source/404.md +0 -6
  104. data/doc/source/_includes/footer.html +0 -21
  105. data/doc/source/_includes/header.html +0 -59
  106. data/doc/source/_includes/tocify.html +0 -6
  107. data/doc/source/_layouts/default.html +0 -9
  108. data/doc/source/_layouts/page.html +0 -25
  109. data/doc/source/atom.xml +0 -32
  110. data/doc/source/design/index.md +0 -1322
  111. data/doc/source/design/wireframes.pdf +0 -0
  112. data/doc/source/index.md +0 -18
  113. data/doc/source/static/css/bootstrap-responsive.min.css +0 -9
  114. data/doc/source/static/css/bootstrap.min.css +0 -866
  115. data/doc/source/static/css/jquery.tocify.css +0 -128
  116. data/doc/source/static/css/style.css +0 -285
  117. data/doc/source/static/css/syntax.css +0 -60
  118. data/doc/source/static/images/foreman.png +0 -0
  119. data/doc/source/static/images/glyphicons-halflings-white.png +0 -0
  120. data/doc/source/static/images/glyphicons-halflings.png +0 -0
  121. data/doc/source/static/js/bootstrap.min.js +0 -7
  122. data/doc/source/static/js/jquery-ui-1.9.2.custom.min.js +0 -6
  123. data/doc/source/static/js/jquery.js +0 -2
  124. data/doc/source/static/js/jquery.tocify.min.js +0 -3
  125. data/doc/source/static/js/scroll.js +0 -24
@@ -7,7 +7,7 @@ module Api
7
7
  @remote_execution_feature = RemoteExecutionFeature.register(:my_awesome_feature, 'My awesome feature',
8
8
  :description => 'You will not believe what it does',
9
9
  :provided_inputs => ['awesomeness_level'])
10
- @template = FactoryGirl.create(:job_template, :with_input)
10
+ @template = FactoryBot.create(:job_template, :with_input)
11
11
  end
12
12
 
13
13
  test 'should get index' do
@@ -18,7 +18,7 @@ module Api
18
18
  end
19
19
 
20
20
  test 'should get input set detail' do
21
- get :show, :id => @remote_execution_feature.to_param
21
+ get :show, params: { :id => @remote_execution_feature.to_param }
22
22
  assert_response :success
23
23
  remote_execution_feature = ActiveSupport::JSON.decode(@response.body)
24
24
  refute remote_execution_feature.empty?
@@ -26,8 +26,7 @@ module Api
26
26
  end
27
27
 
28
28
  test 'should update valid' do
29
- put :update, :id => @remote_execution_feature.to_param,
30
- :job_template_id => @template.id
29
+ put :update, params: { :id => @remote_execution_feature.to_param, :job_template_id => @template.id }
31
30
  assert_response :ok
32
31
  end
33
32
  end
@@ -4,19 +4,19 @@ module Api
4
4
  module V2
5
5
  class TemplateInputsControllerTest < ActionController::TestCase
6
6
  setup do
7
- @template = FactoryGirl.create(:job_template, :with_input)
7
+ @template = FactoryBot.create(:job_template, :with_input)
8
8
  @input = @template.template_inputs.first
9
9
  end
10
10
 
11
11
  test 'should get index' do
12
- get :index, :template_id => @template.id
12
+ get :index, params: { :template_id => @template.id }
13
13
  inputs = ActiveSupport::JSON.decode(@response.body)
14
14
  assert !inputs.empty?, 'Should respond with inputs'
15
15
  assert_response :success
16
16
  end
17
17
 
18
18
  test 'should get input detail' do
19
- get :show, :template_id => @template.to_param, :id => @input.to_param
19
+ get :show, params: { :template_id => @template.to_param, :id => @input.to_param }
20
20
  assert_response :success
21
21
  input = ActiveSupport::JSON.decode(@response.body)
22
22
  assert !input.empty?
@@ -25,34 +25,29 @@ module Api
25
25
 
26
26
  test 'should create valid' do
27
27
  valid_attrs = { :name => 'is_potato', :input_type => 'user', :options => ['true', 'false'] }
28
- post :create, :template_input => valid_attrs, :template_id => @template.to_param
28
+ post :create, params: { :template_input => valid_attrs, :template_id => @template.to_param }
29
29
  input = ActiveSupport::JSON.decode(@response.body)
30
30
  assert input['name'] == 'is_potato'
31
31
  assert_response :success
32
32
  end
33
33
 
34
34
  test 'should not create invalid' do
35
- post :create, :template_id => @template.to_param
35
+ post :create, params: { :template_id => @template.to_param }
36
36
  assert_response :unprocessable_entity
37
37
  end
38
38
 
39
39
  test 'should update valid' do
40
- put :update, :template_id => @template.to_param,
41
- :id => @input.to_param,
42
- :template_input => { :name => 'blah' }
40
+ put :update, params: { :template_id => @template.to_param, :id => @input.to_param, :template_input => { :name => 'blah' } }
43
41
  assert_response :ok
44
42
  end
45
43
 
46
44
  test 'should not update invalid' do
47
- put :update, :template_id => @template.to_param,
48
- :id => @input.to_param,
49
- :template_input => { :name => '' }
45
+ put :update, params: { :template_id => @template.to_param, :id => @input.to_param, :template_input => { :name => '' } }
50
46
  assert_response :unprocessable_entity
51
47
  end
52
48
 
53
49
  test 'should destroy' do
54
- delete :destroy, :template_id => @template.to_param,
55
- :id => @input.to_param
50
+ delete :destroy, params: { :template_id => @template.to_param, :id => @input.to_param }
56
51
  assert_response :ok
57
52
  refute TemplateInput.exists?(@input.id)
58
53
  end
@@ -2,8 +2,8 @@
2
2
  require 'test_helper'
3
3
  require 'dynflow/testing'
4
4
 
5
- # Add plugin to FactoryGirl's paths
6
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
5
+ # Add plugin to FactoryBot's paths
6
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
7
7
  # Add foreman tasks factories too
8
- FactoryGirl.definition_file_paths << "#{ForemanTasks::Engine.root}/test/factories"
9
- FactoryGirl.reload
8
+ FactoryBot.definition_file_paths << "#{ForemanTasks::Engine.root}/test/factories"
9
+ FactoryBot.reload
@@ -5,11 +5,11 @@ module ForemanRemoteExecution
5
5
  class RunHostsJobTest < ActiveSupport::TestCase
6
6
  include Dynflow::Testing
7
7
 
8
- let(:host) { FactoryGirl.create(:host, :with_execution) }
8
+ let(:host) { FactoryBot.create(:host, :with_execution) }
9
9
  let(:proxy) { host.remote_execution_proxies('SSH')[:subnet].first }
10
- let(:targeting) { FactoryGirl.create(:targeting, :search_query => "name = #{host.name}", :user => User.current) }
10
+ let(:targeting) { FactoryBot.create(:targeting, :search_query => "name = #{host.name}", :user => User.current) }
11
11
  let(:job_invocation) do
12
- FactoryGirl.build(:job_invocation, :with_template).tap do |invocation|
12
+ FactoryBot.build(:job_invocation, :with_template).tap do |invocation|
13
13
  invocation.targeting = targeting
14
14
  invocation.description = 'Some short description'
15
15
  invocation.save
@@ -5,7 +5,7 @@ module ForemanRemoteExecution
5
5
  class SampleModel
6
6
  include ::ForemanRemoteExecution::Exportable
7
7
 
8
- attr_accessor :name, :attrs, :subnet, :mac, :password, :subnet
8
+ attr_accessor :name, :attrs, :subnet, :mac, :password
9
9
  attr_exportable :name, :attrs, :mac, :subnet, :mac => ->(m) { m.mac.upcase if m.mac },
10
10
  :custom_attr => ->(m) { 'hello world' }
11
11
 
@@ -2,13 +2,13 @@ require 'test_plugin_helper'
2
2
 
3
3
  class ForemanRemoteExecutionForemanTasksCleanerExtensionsTest < ActiveSupport::TestCase
4
4
  it 'tries to delete associated job invocations' do
5
- job = FactoryGirl.create(:job_invocation, :with_task)
5
+ job = FactoryBot.create(:job_invocation, :with_task)
6
6
  ForemanTasks::Cleaner.new(:filter => "id = #{job.task.id}").delete
7
7
  JobInvocation.where(:id => job.id).must_be :empty?
8
8
  end
9
9
 
10
10
  it 'removes orphaned job invocations' do
11
- job = FactoryGirl.create(:job_invocation, :with_task)
11
+ job = FactoryBot.create(:job_invocation, :with_task)
12
12
  JobInvocation.where(:id => job.id).count.must_equal 1
13
13
  job.task.delete
14
14
  job.reload
@@ -6,11 +6,11 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
6
6
  end
7
7
  let(:provider) { 'SSH' }
8
8
 
9
- before { User.current = FactoryGirl.build(:user, :admin) }
9
+ before { User.current = FactoryBot.build(:user, :admin) }
10
10
  after { User.current = nil }
11
11
 
12
12
  describe 'ssh specific params' do
13
- let(:host) { FactoryGirl.create(:host, :with_execution) }
13
+ let(:host) { FactoryBot.create(:host, :with_execution) }
14
14
  let(:sshkey) { 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQ foo@example.com' }
15
15
 
16
16
  before do
@@ -24,7 +24,7 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
24
24
  end
25
25
 
26
26
  it 'can override ssh user' do
27
- host.host_parameters << FactoryGirl.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'amy')
27
+ host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'amy')
28
28
  host.params['remote_execution_ssh_user'].must_equal 'amy'
29
29
  end
30
30
 
@@ -33,7 +33,7 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
33
33
  end
34
34
 
35
35
  it 'can override effective user method' do
36
- host.host_parameters << FactoryGirl.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'su')
36
+ host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'su')
37
37
  host.params['remote_execution_effective_user_method'].must_equal 'su'
38
38
  end
39
39
 
@@ -43,7 +43,7 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
43
43
 
44
44
  it 'has ssh keys in the parameters even when no user specified' do
45
45
  # this is a case, when using the helper in provisioning templates
46
- FactoryGirl.create(:smart_proxy, :ssh)
46
+ FactoryBot.create(:smart_proxy, :ssh)
47
47
  host.interfaces.first.subnet.remote_execution_proxies.clear
48
48
  User.current = nil
49
49
  host.remote_execution_ssh_keys.must_include sshkey
@@ -51,10 +51,10 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
51
51
  end
52
52
 
53
53
  context 'host has multiple nics' do
54
- let(:host) { FactoryGirl.build(:host, :with_execution) }
54
+ let(:host) { FactoryBot.build(:host, :with_execution) }
55
55
 
56
56
  it 'should only have one execution interface' do
57
- host.interfaces << FactoryGirl.build(:nic_managed)
57
+ host.interfaces << FactoryBot.build(:nic_managed)
58
58
  host.interfaces.each { |interface| interface.execution = true }
59
59
  host.wont_be :valid?
60
60
  end
@@ -66,14 +66,14 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
66
66
 
67
67
  context 'scoped search' do
68
68
  let(:job) do
69
- job = FactoryGirl.create(:job_invocation, :with_task)
70
- job.template_invocations << FactoryGirl.create(:template_invocation, :with_host, :with_failed_task)
69
+ job = FactoryBot.create(:job_invocation, :with_task)
70
+ job.template_invocations << FactoryBot.create(:template_invocation, :with_host, :with_failed_task)
71
71
  job
72
72
  end
73
73
 
74
74
  let(:job2) do
75
- job = FactoryGirl.create(:job_invocation, :with_task)
76
- job.template_invocations << FactoryGirl.create(:template_invocation, :with_host, :with_failed_task)
75
+ job = FactoryBot.create(:job_invocation, :with_task)
76
+ job.template_invocations << FactoryBot.create(:template_invocation, :with_host, :with_failed_task)
77
77
  job
78
78
  end
79
79
 
@@ -112,17 +112,17 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
112
112
 
113
113
  describe 'proxy determination strategies' do
114
114
  context 'subnet strategy' do
115
- let(:host) { FactoryGirl.build(:host, :with_execution) }
115
+ let(:host) { FactoryBot.build(:host, :with_execution) }
116
116
  it { host.remote_execution_proxies(provider)[:subnet].must_include host.subnet.remote_execution_proxies.first }
117
117
  end
118
118
 
119
119
  context 'fallback strategy' do
120
- let(:host) { FactoryGirl.build(:host, :with_puppet) }
120
+ let(:host) { FactoryBot.build(:host, :with_puppet) }
121
121
 
122
122
  context 'enabled' do
123
123
  before do
124
124
  Setting[:remote_execution_fallback_proxy] = true
125
- host.puppet_proxy.features << FactoryGirl.create(:feature, :ssh)
125
+ host.puppet_proxy.features << FactoryBot.create(:feature, :ssh)
126
126
  end
127
127
 
128
128
  it 'returns a fallback proxy' do
@@ -133,7 +133,7 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
133
133
  context 'disabled' do
134
134
  before do
135
135
  Setting[:remote_execution_fallback_proxy] = false
136
- host.puppet_proxy.features << FactoryGirl.create(:feature, :ssh)
136
+ host.puppet_proxy.features << FactoryBot.create(:feature, :ssh)
137
137
  end
138
138
 
139
139
  it 'returns no proxy' do
@@ -143,11 +143,11 @@ class ForemanRemoteExecutionHostExtensionsTest < ActiveSupport::TestCase
143
143
  end
144
144
 
145
145
  context 'global strategy' do
146
- let(:tax_organization) { FactoryGirl.build(:organization) }
147
- let(:tax_location) { FactoryGirl.build(:location) }
148
- let(:host) { FactoryGirl.build(:host, :organization => tax_organization, :location => tax_location) }
149
- let(:proxy_in_taxonomies) { FactoryGirl.create(:smart_proxy, :ssh, :organizations => [tax_organization], :locations => [tax_location]) }
150
- let(:proxy_no_taxonomies) { FactoryGirl.create(:smart_proxy, :ssh) }
146
+ let(:tax_organization) { FactoryBot.build(:organization) }
147
+ let(:tax_location) { FactoryBot.build(:location) }
148
+ let(:host) { FactoryBot.build(:host, :organization => tax_organization, :location => tax_location) }
149
+ let(:proxy_in_taxonomies) { FactoryBot.create(:smart_proxy, :ssh, :organizations => [tax_organization], :locations => [tax_location]) }
150
+ let(:proxy_no_taxonomies) { FactoryBot.create(:smart_proxy, :ssh) }
151
151
 
152
152
  context 'enabled' do
153
153
  before { Setting[:remote_execution_global_proxy] = true }
@@ -1,7 +1,7 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class ForemanRemoteExecutionNicExtensionsTest < ActiveSupport::TestCase
4
- let(:host) { FactoryGirl.create(:host) }
4
+ let(:host) { FactoryBot.create(:host) }
5
5
 
6
6
  it 'sets the first primary interface as the execution interface' do
7
7
  host.execution_interface.must_equal host.interfaces.first
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class InputTemplateRendererTest < ActiveSupport::TestCase
4
4
  context 'renderer for simple template without inputs' do
5
- let(:renderer) { InputTemplateRenderer.new(FactoryGirl.build(:job_template, :template => 'id <%= preview? %>')) }
5
+ let(:renderer) { InputTemplateRenderer.new(FactoryBot.build(:job_template, :template => 'id <%= preview? %>')) }
6
6
 
7
7
  it 'should render the content' do
8
8
  renderer.render.must_equal 'id false'
@@ -14,7 +14,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
14
14
  end
15
15
 
16
16
  context 'renderer for template with user input used' do
17
- let(:template) { FactoryGirl.build(:job_template, :template => 'service restart <%= input("service_name") -%>') }
17
+ let(:template) { FactoryBot.build(:job_template, :template => 'service restart <%= input("service_name") -%>') }
18
18
  let(:renderer) { InputTemplateRenderer.new(template) }
19
19
 
20
20
  context 'but without input defined' do
@@ -43,12 +43,12 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
43
43
 
44
44
  context 'with matching input defined' do
45
45
 
46
- let(:job_invocation) { FactoryGirl.create(:job_invocation) }
47
- let(:template_invocation) { FactoryGirl.build(:template_invocation, :template => template) }
46
+ let(:job_invocation) { FactoryBot.create(:job_invocation) }
47
+ let(:template_invocation) { FactoryBot.build(:template_invocation, :template => template) }
48
48
  let(:result) { renderer.render }
49
49
 
50
50
  before do
51
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'service_name', :input_type => 'user')
51
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name', :input_type => 'user')
52
52
  job_invocation.template_invocations << template_invocation
53
53
  end
54
54
 
@@ -78,10 +78,10 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
78
78
 
79
79
  context 'with invocation specified' do
80
80
  before do
81
- FactoryGirl.create(:template_invocation_input_value,
82
- :template_invocation => template_invocation,
83
- :template_input => template.template_inputs.first,
84
- :value => 'foreman')
81
+ FactoryBot.create(:template_invocation_input_value,
82
+ :template_invocation => template_invocation,
83
+ :template_input => template.template_inputs.first,
84
+ :value => 'foreman')
85
85
  renderer.invocation = template_invocation
86
86
  renderer.invocation.reload
87
87
  end
@@ -98,21 +98,21 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
98
98
 
99
99
  describe 'with circular reference' do
100
100
  let(:recursive_template_with_inputs) do
101
- FactoryGirl.create(:job_template, :name => 'test', :template => 'test')
101
+ FactoryBot.create(:job_template, :name => 'test', :template => 'test')
102
102
  end
103
103
 
104
104
  let(:template_with_inputs) do
105
- FactoryGirl.create(:job_template, :template => 'test').tap do |template|
106
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => recursive_template_with_inputs)
105
+ FactoryBot.create(:job_template, :template => 'test').tap do |template|
106
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => recursive_template_with_inputs)
107
107
  end
108
108
  end
109
109
 
110
110
  let(:recursive_template_without_inputs) do
111
- FactoryGirl.create(:job_template, :name => 'recursive template', :template => '<%= render_template("template with inputs", "action" => "install") %>')
111
+ FactoryBot.create(:job_template, :name => 'recursive template', :template => '<%= render_template("template with inputs", "action" => "install") %>')
112
112
  end
113
113
 
114
114
  let(:template_without_inputs) do
115
- FactoryGirl.create(:job_template, :name => 'template with inputs', :template => "<%= render_template('#{recursive_template_without_inputs.name}') %>")
115
+ FactoryBot.create(:job_template, :name => 'template with inputs', :template => "<%= render_template('#{recursive_template_without_inputs.name}') %>")
116
116
  end
117
117
 
118
118
  before do
@@ -120,7 +120,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
120
120
  end
121
121
 
122
122
  it 'handles circular references in templates' do
123
- renderer.invocation = FactoryGirl.build(:template_invocation, :template => template_without_inputs)
123
+ renderer.invocation = FactoryBot.build(:template_invocation, :template => template_without_inputs)
124
124
  renderer.template = template_without_inputs
125
125
  refute renderer.render
126
126
  renderer.error_message.must_include 'Recursive rendering of templates detected'
@@ -128,8 +128,8 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
128
128
 
129
129
  it 'handles circular references in inputs' do
130
130
  assert_raises(ActiveRecord::RecordInvalid) do
131
- input_set = FactoryGirl.build(:foreign_input_set, :target_template => template_with_inputs, :include_all => false,
132
- :include => 'package, debug', :exclude => 'action,debug')
131
+ input_set = FactoryBot.build(:foreign_input_set, :target_template => template_with_inputs, :include_all => false,
132
+ :include => 'package, debug', :exclude => 'action,debug')
133
133
  recursive_template_with_inputs.foreign_input_sets << input_set
134
134
  recursive_template_with_inputs.save!
135
135
  end
@@ -140,31 +140,31 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
140
140
 
141
141
  context 'renderer for template with input set and render_template' do
142
142
  let(:command_template) do
143
- FactoryGirl.build(:job_template, :name => 'command action', :template => '<%= input("command") -%>').tap do |template|
144
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'command', :input_type => 'user')
145
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'debug', :input_type => 'user')
143
+ FactoryBot.build(:job_template, :name => 'command action', :template => '<%= input("command") -%>').tap do |template|
144
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'command', :input_type => 'user')
145
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'debug', :input_type => 'user')
146
146
  end
147
147
  end
148
148
 
149
149
  let(:package_template) do
150
- FactoryGirl.build(:job_template, :name => 'package action', :template => <<-TEMPLATE.strip_heredoc) do |template|
150
+ FactoryBot.build(:job_template, :name => 'package action', :template => <<-TEMPLATE.strip_heredoc) do |template|
151
151
  <%= render_template("command action", "command" => "yum -y \#{ input("action") } \#{ input('package') }") -%>
152
152
  TEMPLATE
153
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'package', :input_type => 'user')
154
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'action', :input_type => 'user')
155
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => command_template, :include_all => true, :exclude => 'command')
153
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'package', :input_type => 'user')
154
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'action', :input_type => 'user')
155
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => command_template, :include_all => true, :exclude => 'command')
156
156
  end
157
157
  end
158
158
 
159
159
  let(:template) do
160
- FactoryGirl.create(:job_template,
161
- :template => '<%= render_template("package action", { :action => "install" }, { :with_foreign_input_set => true }) %>').tap do |template|
162
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => package_template, :include_all => true, :exclude => 'action')
160
+ FactoryBot.create(:job_template,
161
+ :template => '<%= render_template("package action", { :action => "install" }, { :with_foreign_input_set => true }) %>').tap do |template|
162
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => package_template, :include_all => true, :exclude => 'action')
163
163
  end
164
164
  end
165
165
 
166
- let(:job_invocation) { FactoryGirl.create(:job_invocation) }
167
- let(:template_invocation) { FactoryGirl.build(:template_invocation, :template => template) }
166
+ let(:job_invocation) { FactoryBot.create(:job_invocation) }
167
+ let(:template_invocation) { FactoryBot.build(:template_invocation, :template => template) }
168
168
  let(:renderer) { InputTemplateRenderer.new(template) }
169
169
  let(:result) { renderer.render }
170
170
 
@@ -178,15 +178,15 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
178
178
  describe 'foreign input set' do
179
179
  describe 'with include_all' do
180
180
  let(:template) do
181
- FactoryGirl.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
182
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => package_template, :include_all => true)
181
+ FactoryBot.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
182
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => package_template, :include_all => true)
183
183
  end
184
184
  end
185
185
 
186
186
  let(:template_2) do
187
- FactoryGirl.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
188
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set,
189
- :target_template => package_template, :include_all => true, :include => '', :exclude => '')
187
+ FactoryBot.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
188
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set,
189
+ :target_template => package_template, :include_all => true, :include => '', :exclude => '')
190
190
  end
191
191
  end
192
192
 
@@ -198,8 +198,8 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
198
198
 
199
199
  describe 'with include_all and some excludes' do
200
200
  let(:template) do
201
- FactoryGirl.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
202
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => package_template, :include_all => true, :exclude => 'action,debug')
201
+ FactoryBot.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
202
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => package_template, :include_all => true, :exclude => 'action,debug')
203
203
  end
204
204
  end
205
205
 
@@ -210,9 +210,9 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
210
210
 
211
211
  describe 'with some includes and some excludes' do
212
212
  let(:template) do
213
- FactoryGirl.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
214
- template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => package_template, :include_all => false,
215
- :include => 'package, debug', :exclude => 'action,debug')
213
+ FactoryBot.create(:job_template, :template => '<%= render_template("package action", "action" => "install") %>').tap do |template|
214
+ template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => package_template, :include_all => false,
215
+ :include => 'package, debug', :exclude => 'action,debug')
216
216
  end
217
217
  end
218
218
 
@@ -224,10 +224,10 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
224
224
 
225
225
  context 'with invocation specified' do
226
226
  before do
227
- FactoryGirl.create(:template_invocation_input_value,
228
- :template_invocation => template_invocation,
229
- :template_input => template.template_inputs_with_foreign.find { |input| input.name == 'package' },
230
- :value => 'zsh')
227
+ FactoryBot.create(:template_invocation_input_value,
228
+ :template_invocation => template_invocation,
229
+ :template_input => template.template_inputs_with_foreign.find { |input| input.name == 'package' },
230
+ :value => 'zsh')
231
231
  renderer.invocation = template_invocation
232
232
  renderer.invocation.reload
233
233
  end
@@ -241,8 +241,8 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
241
241
 
242
242
  context 'with explicitly specifying inputs' do
243
243
  let(:template) do
244
- FactoryGirl.create(:job_template,
245
- :template => '<%= render_template("package action", {"action" => "install", :package => "zsh"}) %>')
244
+ FactoryBot.create(:job_template,
245
+ :template => '<%= render_template("package action", {"action" => "install", :package => "zsh"}) %>')
246
246
  end
247
247
 
248
248
  before do
@@ -267,12 +267,12 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
267
267
 
268
268
  context 'with options specified' do
269
269
 
270
- let(:job_invocation) { FactoryGirl.create(:job_invocation) }
271
- let(:template_invocation) { FactoryGirl.build(:template_invocation, :template => template) }
270
+ let(:job_invocation) { FactoryBot.create(:job_invocation) }
271
+ let(:template_invocation) { FactoryBot.build(:template_invocation, :template => template) }
272
272
  let(:result) { renderer.render }
273
273
 
274
274
  before do
275
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'service_name', :input_type => 'user', :options => "httpd\nforeman")
275
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name', :input_type => 'user', :options => "httpd\nforeman")
276
276
  end
277
277
 
278
278
  context 'with a valid input defined' do
@@ -280,10 +280,10 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
280
280
  job_invocation.template_invocations << template_invocation
281
281
  renderer.invocation = template_invocation
282
282
 
283
- FactoryGirl.create(:template_invocation_input_value,
284
- :template_invocation => template_invocation,
285
- :template_input => template.template_inputs.first,
286
- :value => 'foreman')
283
+ FactoryBot.create(:template_invocation_input_value,
284
+ :template_invocation => template_invocation,
285
+ :template_input => template.template_inputs.first,
286
+ :value => 'foreman')
287
287
  renderer.invocation.reload
288
288
  end
289
289
 
@@ -295,11 +295,11 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
295
295
  end
296
296
 
297
297
  context 'renderer for template with fact input used' do
298
- let(:template) { FactoryGirl.build(:job_template, :template => 'echo <%= input("issue") -%> > /etc/issue') }
298
+ let(:template) { FactoryBot.build(:job_template, :template => 'echo <%= input("issue") -%> > /etc/issue') }
299
299
  let(:renderer) { InputTemplateRenderer.new(template) }
300
300
 
301
301
  context 'with matching input defined' do
302
- before { renderer.template.template_inputs<< FactoryGirl.build(:template_input, :name => 'issue', :input_type => 'fact', :fact_name => 'issue') }
302
+ before { renderer.template.template_inputs<< FactoryBot.build(:template_input, :name => 'issue', :input_type => 'fact', :fact_name => 'issue') }
303
303
  let(:result) { renderer.render }
304
304
 
305
305
  describe 'rendering' do
@@ -314,7 +314,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
314
314
  end
315
315
 
316
316
  context 'with host specified' do
317
- before { renderer.host = FactoryGirl.create(:host) }
317
+ before { renderer.host = FactoryBot.create(:host) }
318
318
 
319
319
  describe 'rendering' do
320
320
  it 'can\'t render the content without host since we don\'t have fact value' do
@@ -335,7 +335,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
335
335
  end
336
336
 
337
337
  context 'with existing fact' do
338
- let(:fact) { FactoryGirl.create(:fact_name, :name => 'issue') }
338
+ let(:fact) { FactoryBot.create(:fact_name, :name => 'issue') }
339
339
 
340
340
  describe 'rendering' do
341
341
  it 'can\'t render the content without host since we don\'t have fact value' do
@@ -357,7 +357,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
357
357
  end
358
358
 
359
359
  context 'with fact issue value' do
360
- before { FactoryGirl.create(:fact_value, :host => renderer.host, :fact_name => fact, :value => 'banner') }
360
+ before { FactoryBot.create(:fact_value, :host => renderer.host, :fact_name => fact, :value => 'banner') }
361
361
 
362
362
  let(:result) { renderer.render }
363
363
 
@@ -376,9 +376,9 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
376
376
 
377
377
  context 'with host specified' do
378
378
  before do
379
- host = FactoryGirl.create(:host)
380
- fact = FactoryGirl.create(:fact_name, :name => 'issue')
381
- FactoryGirl.create(:fact_value, :host => host, :fact_name => fact, :value => 'banner')
379
+ host = FactoryBot.create(:host)
380
+ fact = FactoryBot.create(:fact_name, :name => 'issue')
381
+ FactoryBot.create(:fact_value, :host => host, :fact_name => fact, :value => 'banner')
382
382
  renderer.host = host
383
383
  end
384
384
 
@@ -393,11 +393,11 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
393
393
  end
394
394
 
395
395
  context 'renderer for template with variable input used' do
396
- let(:template) { FactoryGirl.build(:job_template, :template => 'echo <%= input("client_key") -%> > /etc/chef/client.pem') }
396
+ let(:template) { FactoryBot.build(:job_template, :template => 'echo <%= input("client_key") -%> > /etc/chef/client.pem') }
397
397
  let(:renderer) { InputTemplateRenderer.new(template) }
398
398
 
399
399
  context 'with matching input defined' do
400
- before { renderer.template.template_inputs<< FactoryGirl.build(:template_input, :name => 'client_key', :input_type => 'variable', :variable_name => 'client_key') }
400
+ before { renderer.template.template_inputs<< FactoryBot.build(:template_input, :name => 'client_key', :input_type => 'variable', :variable_name => 'client_key') }
401
401
  let(:result) { renderer.render }
402
402
 
403
403
  describe 'rendering' do
@@ -412,11 +412,11 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
412
412
  end
413
413
 
414
414
  context 'with host specified' do
415
- before { User.current = FactoryGirl.build(:user, :admin) }
415
+ before { User.current = FactoryBot.build(:user, :admin) }
416
416
  after { User.current = nil }
417
417
 
418
- let(:environment) { FactoryGirl.create(:environment) }
419
- before { renderer.host = FactoryGirl.create(:host, :environment => environment) }
418
+ let(:environment) { FactoryBot.create(:environment) }
419
+ before { renderer.host = FactoryBot.create(:host, :environment => environment) }
420
420
 
421
421
  describe 'rendering' do
422
422
  it 'can\'t render the content without host since we don\'t have variable value in classification' do
@@ -438,7 +438,7 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
438
438
 
439
439
 
440
440
  context 'with existing variable implemented as host parameter' do
441
- let(:parameter) { FactoryGirl.create(:host_parameter, :host => renderer.host, :name => 'client_key', :value => 'RSA KEY') }
441
+ let(:parameter) { FactoryBot.create(:host_parameter, :host => renderer.host, :name => 'client_key', :value => 'RSA KEY') }
442
442
 
443
443
  describe 'rendering' do
444
444
  it 'renders the value from host parameter' do
@@ -459,15 +459,15 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
459
459
 
460
460
  context 'with existing variable implemented as smart variable' do
461
461
  let(:puppet_class) do
462
- puppetclass = FactoryGirl.create(:puppetclass, :environments => [environment])
462
+ puppetclass = FactoryBot.create(:puppetclass, :environments => [environment])
463
463
  puppetclass.update_attribute(:hosts, [renderer.host])
464
464
  puppetclass
465
465
  end
466
466
  let(:lookup_key) do
467
- FactoryGirl.create(:variable_lookup_key,
468
- :key => 'client_key',
469
- :puppetclass => puppet_class,
470
- :overrides => {"fqdn=#{renderer.host.fqdn}" => 'RSA KEY'})
467
+ FactoryBot.create(:variable_lookup_key,
468
+ :key => 'client_key',
469
+ :puppetclass => puppet_class,
470
+ :overrides => {"fqdn=#{renderer.host.fqdn}" => 'RSA KEY'})
471
471
  end
472
472
 
473
473
  describe 'rendering' do
@@ -496,16 +496,16 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
496
496
  end
497
497
 
498
498
  context 'renderer for template with puppet parameter input used' do
499
- let(:template) { FactoryGirl.build(:job_template, :template => 'echo "This is WebServer with nginx <%= input("nginx_version") -%>" > /etc/motd') }
499
+ let(:template) { FactoryBot.build(:job_template, :template => 'echo "This is WebServer with nginx <%= input("nginx_version") -%>" > /etc/motd') }
500
500
  let(:renderer) { InputTemplateRenderer.new(template) }
501
501
 
502
502
  context 'with matching input defined' do
503
503
  before do
504
- renderer.template.template_inputs<< FactoryGirl.build(:template_input,
505
- :name => 'nginx_version',
506
- :input_type => 'puppet_parameter',
507
- :puppet_parameter_name => 'version',
508
- :puppet_class_name => 'nginx')
504
+ renderer.template.template_inputs<< FactoryBot.build(:template_input,
505
+ :name => 'nginx_version',
506
+ :input_type => 'puppet_parameter',
507
+ :puppet_parameter_name => 'version',
508
+ :puppet_class_name => 'nginx')
509
509
  end
510
510
  let(:result) { renderer.render }
511
511
 
@@ -521,8 +521,8 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
521
521
  end
522
522
 
523
523
  context 'with host specified' do
524
- let(:environment) { FactoryGirl.create(:environment) }
525
- before { renderer.host = FactoryGirl.create(:host, :environment => environment) }
524
+ let(:environment) { FactoryBot.create(:environment) }
525
+ before { renderer.host = FactoryBot.create(:host, :environment => environment) }
526
526
 
527
527
  describe 'rendering' do
528
528
  it 'can\'t render the content without host since we don\'t have puppet parameter in classification' do
@@ -544,17 +544,17 @@ class InputTemplateRendererTest < ActiveSupport::TestCase
544
544
 
545
545
  context 'with existing puppet parameter with matching override' do
546
546
  let(:puppet_class) do
547
- puppetclass = FactoryGirl.create(:puppetclass, :environments => [environment], :name => 'nginx')
547
+ puppetclass = FactoryBot.create(:puppetclass, :environments => [environment], :name => 'nginx')
548
548
  puppetclass.update_attribute(:hosts, [renderer.host])
549
549
  puppetclass
550
550
  end
551
551
  let(:lookup_key) do
552
- FactoryGirl.create(:puppetclass_lookup_key, :as_smart_class_param,
553
- :key => 'version',
554
- :puppetclass => puppet_class,
555
- :path => 'fqdn',
556
- :override => true,
557
- :overrides => {"fqdn=#{renderer.host.fqdn}" => '1.4.7'})
552
+ FactoryBot.create(:puppetclass_lookup_key, :as_smart_class_param,
553
+ :key => 'version',
554
+ :puppetclass => puppet_class,
555
+ :path => 'fqdn',
556
+ :override => true,
557
+ :overrides => {"fqdn=#{renderer.host.fqdn}" => '1.4.7'})
558
558
  end
559
559
 
560
560
  describe 'rendering' do