foreman-tasks 0.10.9 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -1
  3. data/.rubocop_todo.yml +69 -50
  4. data/app/models/foreman_tasks/concerns/action_triggering.rb +8 -6
  5. data/db/migrate/20131205204140_create_foreman_tasks.rb +1 -1
  6. data/db/migrate/20131209122644_create_foreman_tasks_locks.rb +1 -1
  7. data/db/migrate/20140324104010_remove_foreman_tasks_progress.rb +1 -1
  8. data/db/migrate/20140813215942_add_parent_task_id.rb +1 -1
  9. data/db/migrate/20150814204140_add_task_type_value_index.rb +1 -1
  10. data/db/migrate/20150817102538_add_delay_attributes.rb +1 -1
  11. data/db/migrate/20150907124936_create_recurring_logic.rb +1 -1
  12. data/db/migrate/20150907131503_create_task_groups.rb +1 -1
  13. data/db/migrate/20151022123457_add_recurring_logic_state.rb +1 -1
  14. data/db/migrate/20151112152108_create_triggerings.rb +1 -1
  15. data/db/migrate/20160920151810_add_more_lock_indexes.rb +1 -1
  16. data/db/migrate/20160924213030_change_tasks_widget_names.rb +1 -1
  17. data/db/migrate/20161003091412_add_missing_indexes.rb +1 -1
  18. data/deploy/foreman-tasks.sysconfig +1 -0
  19. data/foreman-tasks.gemspec +2 -0
  20. data/lib/foreman_tasks/authorizer_ext.rb +2 -6
  21. data/lib/foreman_tasks/engine.rb +1 -1
  22. data/lib/foreman_tasks/version.rb +1 -1
  23. data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
  24. data/test/controllers/api/tasks_controller_test.rb +1 -1
  25. data/test/controllers/recurring_logics_controller_test.rb +2 -2
  26. data/test/controllers/tasks_controller_test.rb +2 -2
  27. data/test/factories/recurring_logic_factory.rb +1 -1
  28. data/test/factories/task_factory.rb +1 -1
  29. data/test/factories/triggering_factory.rb +1 -1
  30. data/test/foreman_tasks_test_helper.rb +2 -2
  31. data/test/helpers/foreman_tasks/tasks_helper_test.rb +2 -2
  32. data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
  33. data/test/unit/cleaner_test.rb +12 -12
  34. data/test/unit/dynflow_console_authorizer_test.rb +11 -11
  35. data/test/unit/proxy_selector_test.rb +4 -4
  36. data/test/unit/recurring_logic_test.rb +2 -2
  37. data/test/unit/task_groups_test.rb +2 -2
  38. data/test/unit/task_test.rb +18 -20
  39. data/test/unit/triggering_test.rb +4 -4
  40. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f56949ea2cda099243fd048786274ee80dd94920
4
- data.tar.gz: 307449f1fe7f6a18fa029bf6f418e257231f2484
3
+ metadata.gz: abb4a2ffa0ff0ef6082c2ebe1a8a90d89b5b3b27
4
+ data.tar.gz: 35f084894f1692002cc5a76458b28f34763d9778
5
5
  SHA512:
6
- metadata.gz: 7a9d26057cf27ab1255eec075b935c201864ea4e47b46f3aae45e61a121b65d8817bdec5e878fd8822962e2d32cadb2e0fff3ab41c58a62f5a5c23a77dca9750
7
- data.tar.gz: 99a89d2b357dd0a8a96dbcf3f9651bfafe14ad125b75c26455291e65ea064260f77715d45d936b6874ddf9659ba5a92794bdad6d5efe6b3dde6ada0b12b3f8e3
6
+ metadata.gz: da1b67abb754259dddb59013b176c38cfcb4c2f69d09640bf89a862f784b08d53ee30ca228723ab24aabb1db2770249e57b07cce9bb756df214feac2becd3393
7
+ data.tar.gz: 02be42c80788f710e700f8c502177c584a421517e76678299859258a08b2c1267c9134afd088b0801bce3390f9e19feafc3afb3affa0cd5c65df31c23cb0698e
data/.rubocop.yml CHANGED
@@ -64,7 +64,7 @@ Metrics/BlockLength:
64
64
  Exclude:
65
65
  - lib/foreman_tasks/tasks/**/*
66
66
 
67
- Style/FileName:
67
+ Naming/FileName:
68
68
  Exclude:
69
69
  - '*.gemspec'
70
70
  - Gemfile
@@ -76,6 +76,9 @@ Layout/IndentHeredoc:
76
76
  - '*.gemspec'
77
77
  - bin/*
78
78
 
79
+ Style/RescueStandardError:
80
+ Enabled: false
81
+
79
82
  Style/IfUnlessModifier:
80
83
  Enabled: false
81
84
 
@@ -91,5 +94,8 @@ Style/SafeNavigation:
91
94
  Performance/RegexpMatch:
92
95
  Enabled: false
93
96
 
97
+ Rails/InverseOf:
98
+ Enabled: false
99
+
94
100
  Style/FormatStringToken:
95
101
  Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,117 +1,136 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config --exclude-limit 0`
3
- # on 2017-12-20 11:41:34 +0100 using RuboCop version 0.49.1.
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-12-21 14:29:23 +0200 using RuboCop version 0.46.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: EnforcedStyle, SupportedStyles.
12
- # SupportedStyles: final_newline, final_blank_line
13
- Layout/TrailingBlankLines:
14
- Enabled: false
15
-
16
- # Offense count: 1
17
9
  Lint/EmptyWhen:
18
- Enabled: false
10
+ Exclude:
11
+ - 'app/lib/actions/proxy_action.rb'
12
+
13
+ Lint/ShadowingOuterLocalVariable:
14
+ Exclude:
15
+ - 'bin/dynflow-executor'
19
16
 
20
- # Offense count: 2
21
17
  Lint/UselessAssignment:
22
- Enabled: false
18
+ Exclude:
19
+ - 'lib/foreman_tasks/tasks/export_tasks.rake'
23
20
 
24
- # Offense count: 32
25
21
  Metrics/AbcSize:
26
22
  Max: 41
27
23
 
28
- # Offense count: 15
29
- # Configuration parameters: CountComments, ExcludedMethods.
24
+ # Configuration parameters: CountComments.
30
25
  Metrics/BlockLength:
31
26
  Max: 105
32
27
 
33
- # Offense count: 12
34
28
  # Configuration parameters: CountComments.
35
29
  Metrics/ClassLength:
36
30
  Max: 230
37
31
 
38
- # Offense count: 9
39
32
  Metrics/CyclomaticComplexity:
40
- Max: 9
33
+ Max: 10
41
34
 
42
- # Offense count: 453
43
35
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
44
36
  # URISchemes: http, https
45
37
  Metrics/LineLength:
46
- Max: 211
38
+ Max: 244
47
39
 
48
- # Offense count: 51
49
40
  # Configuration parameters: CountComments.
50
41
  Metrics/MethodLength:
51
- Max: 29
42
+ Max: 37
52
43
 
53
- # Offense count: 2
54
44
  # Configuration parameters: CountComments.
55
45
  Metrics/ModuleLength:
56
- Max: 168
46
+ Max: 170
57
47
 
58
- # Offense count: 1
59
48
  # Configuration parameters: CountKeywordArgs.
60
49
  Metrics/ParameterLists:
61
50
  Max: 6
62
51
 
63
- # Offense count: 4
64
52
  Metrics/PerceivedComplexity:
65
- Max: 9
53
+ Max: 10
66
54
 
67
- # Offense count: 4
68
- # Cop supports --auto-correct.
69
55
  # Configuration parameters: Include.
70
- # Include: spec/**/*, test/**/*
56
+ # Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb
57
+ Rails/Exit:
58
+ Exclude:
59
+ - 'lib/**/*.rake'
60
+
71
61
  Rails/HttpPositionalArguments:
72
62
  Enabled: false
73
63
 
74
- # Offense count: 1
75
64
  # Configuration parameters: Include.
76
65
  # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
77
66
  Rails/Output:
78
- Enabled: false
67
+ Exclude:
68
+ - 'lib/foreman_tasks/cleaner.rb'
79
69
 
80
- # Offense count: 5
81
70
  Rails/OutputSafety:
82
- Enabled: false
71
+ Exclude:
72
+ - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
83
73
 
84
- # Offense count: 11
85
74
  # Configuration parameters: EnforcedStyle, SupportedStyles.
86
75
  # SupportedStyles: nested, compact
87
76
  Style/ClassAndModuleChildren:
88
- Enabled: false
77
+ Exclude:
78
+ - 'app/lib/actions/action_with_sub_plans.rb'
79
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
80
+ - 'app/models/foreman_tasks/task/status_explicator.rb'
81
+ - 'app/models/foreman_tasks/task/summarizer.rb'
82
+ - 'app/models/foreman_tasks/task/task_cancelled_exception.rb'
83
+ - 'app/models/setting/foreman_tasks.rb'
84
+ - 'lib/foreman_tasks/dynflow/configuration.rb'
85
+ - 'lib/foreman_tasks/dynflow/console_authorizer.rb'
86
+ - 'lib/foreman_tasks/dynflow/persistence.rb'
87
+ - 'test/controllers/api/recurring_logics_controller_test.rb'
88
+ - 'test/controllers/api/tasks_controller_test.rb'
89
+ - 'test/unit/actions/action_with_sub_plans_test.rb'
89
90
 
90
- # Offense count: 2
91
91
  Style/DoubleNegation:
92
- Enabled: false
92
+ Exclude:
93
+ - 'app/models/foreman_tasks/lock.rb'
94
+ - 'app/models/foreman_tasks/recurring_logic.rb'
95
+
96
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
97
+ Naming/FileName:
98
+ Exclude:
99
+ - 'db/seeds.d/20-foreman_tasks_permissions.rb'
100
+ - 'db/seeds.d/60-dynflow_proxy_feature.rb'
101
+ - 'db/seeds.d/61-foreman_tasks_bookmarks.rb'
102
+ - 'lib/foreman-tasks.rb'
103
+
104
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
105
+ # SupportedStyles: format, sprintf, percent
106
+ Style/FormatString:
107
+ Exclude:
108
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
109
+ - 'lib/foreman_tasks/tasks/export_tasks.rake'
93
110
 
94
- # Offense count: 31
95
111
  # Configuration parameters: MinBodyLength.
96
112
  Style/GuardClause:
97
113
  Enabled: false
98
114
 
99
- # Offense count: 1
100
115
  # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
101
116
  # NamePrefix: is_, has_, have_
102
117
  # NamePrefixBlacklist: is_, has_, have_
103
118
  # NameWhitelist: is_a?
104
- Style/PredicateName:
105
- Enabled: false
119
+ Naming/PredicateName:
120
+ Exclude:
121
+ - 'spec/**/*'
122
+ - 'app/models/foreman_tasks/task/status_explicator.rb'
106
123
 
107
- # Offense count: 1
108
- # Cop supports --auto-correct.
109
- Style/RedundantSelf:
110
- Enabled: false
111
-
112
- # Offense count: 1
113
124
  # Cop supports --auto-correct.
114
125
  # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
115
126
  # SupportedStyles: slashes, percent_r, mixed
116
127
  Style/RegexpLiteral:
117
- Enabled: false
128
+ Exclude:
129
+ - 'lib/foreman_tasks/dynflow/console_authorizer.rb'
130
+
131
+ # Configuration parameters: Methods.
132
+ # Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
133
+ Style/SingleLineBlockParams:
134
+ Exclude:
135
+ - 'app/models/foreman_tasks/concerns/action_subject.rb'
136
+ - 'app/models/foreman_tasks/lock.rb'
@@ -4,11 +4,13 @@ module ForemanTasks
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- after_create :plan_hook_action
8
- after_update :plan_hook_action
9
- after_destroy :plan_hook_action
7
+ raise "Use 'prepend' instead of 'include' for ForemanTasks::Concerns::ActionTriggering"
8
+ end
10
9
 
11
- alias_method_chain :save, :dynflow_task_wrap
10
+ def self.prepended(base)
11
+ base.after_create :plan_hook_action
12
+ base.after_update :plan_hook_action
13
+ base.after_destroy :plan_hook_action
12
14
  end
13
15
 
14
16
  # These three *_action methods are called before the save/destroy actually occurs
@@ -21,8 +23,8 @@ module ForemanTasks
21
23
  # @override
22
24
  def destroy_action; end
23
25
 
24
- def save_with_dynflow_task_wrap(*args)
25
- dynflow_task_wrap(:save) { save_without_dynflow_task_wrap(*args) }
26
+ def save(*args)
27
+ dynflow_task_wrap(:save) { super(*args) }
26
28
  end
27
29
 
28
30
  def save!(*args)
@@ -1,4 +1,4 @@
1
- class CreateForemanTasks < ActiveRecord::Migration
1
+ class CreateForemanTasks < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreman_tasks_tasks, :id => false, :primary_key => :id do |t|
4
4
  t.string :id, null: false
@@ -1,4 +1,4 @@
1
- class CreateForemanTasksLocks < ActiveRecord::Migration
1
+ class CreateForemanTasksLocks < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreman_tasks_locks do |t|
4
4
  t.string :task_id, index: true, null: false
@@ -1,4 +1,4 @@
1
- class RemoveForemanTasksProgress < ActiveRecord::Migration
1
+ class RemoveForemanTasksProgress < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  remove_column :foreman_tasks_tasks, :progress
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddParentTaskId < ActiveRecord::Migration
1
+ class AddParentTaskId < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_tasks_tasks, :parent_task_id, :string, index: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddTaskTypeValueIndex < ActiveRecord::Migration
1
+ class AddTaskTypeValueIndex < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_index :foreman_tasks_tasks, [:type, :label]
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddDelayAttributes < ActiveRecord::Migration
1
+ class AddDelayAttributes < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_tasks_tasks, :start_at, :datetime, index: true, default: nil, null: true
4
4
  add_column :foreman_tasks_tasks, :start_before, :datetime, index: true, default: nil, null: true
@@ -1,4 +1,4 @@
1
- class CreateRecurringLogic < ActiveRecord::Migration
1
+ class CreateRecurringLogic < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreman_tasks_recurring_logics do |t|
4
4
  t.string :cron_line, :null => false
@@ -1,4 +1,4 @@
1
- class CreateTaskGroups < ActiveRecord::Migration
1
+ class CreateTaskGroups < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  create_table :foreman_tasks_task_groups do |t|
4
4
  t.string :type, index: true, null: false
@@ -1,4 +1,4 @@
1
- class AddRecurringLogicState < ActiveRecord::Migration
1
+ class AddRecurringLogicState < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  add_column :foreman_tasks_recurring_logics, :state, :string, :index => true
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreateTriggerings < ActiveRecord::Migration
1
+ class CreateTriggerings < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  create_table :foreman_tasks_triggerings do |t|
4
4
  t.string :mode, null: false
@@ -1,4 +1,4 @@
1
- class AddMoreLockIndexes < ActiveRecord::Migration
1
+ class AddMoreLockIndexes < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_index(:foreman_tasks_tasks, [:id, :state],
4
4
  :name => 'index_foreman_tasks_id_state')
@@ -1,4 +1,4 @@
1
- class ChangeTasksWidgetNames < ActiveRecord::Migration
1
+ class ChangeTasksWidgetNames < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  Widget.where(:name => 'Tasks Status table')\
4
4
  .update_all(:name => 'Task Status')
@@ -1,4 +1,4 @@
1
- class AddMissingIndexes < ActiveRecord::Migration
1
+ class AddMissingIndexes < ActiveRecord::Migration[4.2]
2
2
  # since this is just making sure the indexes we defined before are
3
3
  # really added we don't define the down direction here.
4
4
  # The support for defining index at column definition was added in Rails here
@@ -1,5 +1,6 @@
1
1
  FOREMAN_USER=foreman
2
2
  BUNDLER_EXT_HOME=/usr/share/foreman
3
+ RAILS_RELATIVE_URL_ROOT=$FOREMAN_PREFIX
3
4
  RAILS_ENV=production
4
5
  FOREMAN_LOGGING=warn
5
6
  FOREMAN_LOGGING_SQL=warn
@@ -33,4 +33,6 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
33
33
  s.add_dependency "sinatra" # for Dynflow web console
34
34
  s.add_dependency "parse-cron", '~> 0.1.4'
35
35
  s.add_dependency "get_process_mem" # for memory polling
36
+
37
+ s.add_development_dependency 'factory_bot_rails', '~> 4.8.0'
36
38
  end
@@ -4,15 +4,11 @@ module ForemanTasks
4
4
  module AuthorizerExt
5
5
  extend ActiveSupport::Concern
6
6
 
7
- included do
8
- alias_method_chain :resource_name, :authorized_resource_name
9
- end
10
-
11
- def resource_name_with_authorized_resource_name(klass)
7
+ def resource_name(klass)
12
8
  if klass.respond_to?(:authorized_resource_name)
13
9
  klass.authorized_resource_name
14
10
  else
15
- resource_name_without_authorized_resource_name(klass)
11
+ super klass
16
12
  end
17
13
  end
18
14
  end
@@ -140,7 +140,7 @@ module ForemanTasks
140
140
  config.to_prepare do
141
141
  ForemanTasks.dynflow.eager_load_actions! if ForemanTasks.dynflow.initialized?
142
142
 
143
- Authorizer.send(:include, AuthorizerExt)
143
+ Authorizer.send(:prepend, AuthorizerExt)
144
144
  end
145
145
 
146
146
  config.after_initialize do
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.10.9'.freeze
2
+ VERSION = '0.11.0'.freeze
3
3
  end
@@ -9,7 +9,7 @@ module ForemanRecurringLogic
9
9
  User.current = User.where(:login => 'apiadmin').first
10
10
  @request.env['HTTP_ACCEPT'] = 'application/json'
11
11
  @request.env['CONTENT_TYPE'] = 'application/json'
12
- @recurring_logic = FactoryGirl.create(:recurring_logic)
12
+ @recurring_logic = FactoryBot.create(:recurring_logic)
13
13
  end
14
14
 
15
15
  describe 'GET /api/recurring_logics' do
@@ -13,7 +13,7 @@ module ForemanTasks
13
13
 
14
14
  describe 'GET /api/tasks/show' do
15
15
  it 'searches for task' do
16
- task = FactoryGirl.create(:dynflow_task, :user_create_task)
16
+ task = FactoryBot.create(:dynflow_task, :user_create_task)
17
17
  get :show, :id => task.id
18
18
  assert_response :success
19
19
  assert_template 'api/tasks/show'
@@ -5,10 +5,10 @@ module ForemanTasks
5
5
  basic_index_test('recurring_logics')
6
6
  basic_pagination_per_page_test
7
7
 
8
- # rubocop:disable Style/AccessorMethodName
8
+ # rubocop:disable Naming/AccessorMethodName
9
9
  def get_factory_name
10
10
  :recurring_logic
11
11
  end
12
- # rubocop:enable Style/AccessorMethodName
12
+ # rubocop:enable Naming/AccessorMethodName
13
13
  end
14
14
  end
@@ -7,11 +7,11 @@ module ForemanTasks
7
7
  basic_pagination_per_page_test
8
8
  basic_pagination_rendered_test
9
9
 
10
- # rubocop:disable Style/AccessorMethodName
10
+ # rubocop:disable Naming/AccessorMethodName
11
11
  def get_factory_name
12
12
  :dynflow_task
13
13
  end
14
- # rubocop:enable Style/AccessorMethodName
14
+ # rubocop:enable Naming/AccessorMethodName
15
15
  end
16
16
  end
17
17
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :recurring_logic, :class => ForemanTasks::RecurringLogic do
3
3
  cron_line '* * * * *'
4
4
  after(:build) { |logic| logic.task_group = build(:recurring_logic_task_group) }
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :some_task, :class => ForemanTasks::Task do
3
3
  sequence(:label) { |n| "task#{n}" }
4
4
  type 'ForemanTasks::Task'
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :triggering, :class => ForemanTasks::Triggering do
3
3
  mode :immediate
4
4
 
@@ -4,8 +4,8 @@ require_relative './support/dummy_proxy_action'
4
4
 
5
5
  require 'dynflow/testing'
6
6
 
7
- FactoryGirl.definition_file_paths = ["#{ForemanTasks::Engine.root}/test/factories"]
8
- FactoryGirl.find_definitions
7
+ FactoryBot.definition_file_paths = ["#{ForemanTasks::Engine.root}/test/factories"]
8
+ FactoryBot.find_definitions
9
9
 
10
10
  ForemanTasks.dynflow.require!
11
11
  ForemanTasks.dynflow.config.disable_active_record_actions = true
@@ -4,7 +4,7 @@ module ForemanTasks
4
4
  class TasksHelperTest < ActionView::TestCase
5
5
  describe 'when formatting simple input' do
6
6
  before do
7
- @task = FactoryGirl.build(:dynflow_task, :user_create_task)
7
+ @task = FactoryBot.build(:dynflow_task, :user_create_task)
8
8
  humanized = { :humanized_name => 'Create', :humanized_input => [[:user, { :text => "user 'Anonymous Admin'", :link => nil }]] }
9
9
  @task.instance_variable_set('@humanized_cache', humanized)
10
10
  @task.stubs(:input).returns('user' => { 'id' => 1, 'name' => 'Anonymous Admin' }, 'locale' => 'en')
@@ -21,7 +21,7 @@ module ForemanTasks
21
21
 
22
22
  describe 'when formatting input' do
23
23
  before do
24
- @task = FactoryGirl.build(:dynflow_task, :product_create_task)
24
+ @task = FactoryBot.build(:dynflow_task, :product_create_task)
25
25
  humanized = { :humanized_name => 'Create',
26
26
  :humanized_input => [[:product, { :text => "product 'product-2'", :link => '#/products/3/info' }], [:organization, { :text => "organization 'test-0'", :link => '/organizations/3/edit' }]] }
27
27
  @task.instance_variable_set('@humanized_cache', humanized)
@@ -34,7 +34,7 @@ module ForemanTasks
34
34
 
35
35
  describe Actions::ActionWithSubPlans do
36
36
  let(:task) do
37
- user = FactoryGirl.create(:user)
37
+ user = FactoryBot.create(:user)
38
38
  triggered = ForemanTasks.trigger(ParentAction, user)
39
39
  raise triggered.error if triggered.respond_to?(:error)
40
40
  triggered.finished.wait(2)
@@ -10,13 +10,13 @@ class TasksTest < ActiveSupport::TestCase
10
10
  it 'is able to delete tasks (including the dynflow plans) based on filter' do
11
11
  cleaner = ForemanTasks::Cleaner.new(:filter => 'label = "Actions::User::Create"', :after => '10d')
12
12
 
13
- tasks_to_delete = [FactoryGirl.create(:dynflow_task, :user_create_task),
14
- FactoryGirl.create(:dynflow_task, :user_create_task)]
15
- tasks_to_keep = [FactoryGirl.create(:dynflow_task, :user_create_task) do |task|
13
+ tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
14
+ FactoryBot.create(:dynflow_task, :user_create_task)]
15
+ tasks_to_keep = [FactoryBot.create(:dynflow_task, :user_create_task) do |task|
16
16
  task.started_at = task.ended_at = Time.zone.now
17
17
  task.save
18
18
  end,
19
- FactoryGirl.create(:dynflow_task, :product_create_task)]
19
+ FactoryBot.create(:dynflow_task, :product_create_task)]
20
20
  cleaner.expects(:tasks_to_csv)
21
21
  cleaner.delete
22
22
  ForemanTasks::Task.where(id: tasks_to_delete).must_be_empty
@@ -31,13 +31,13 @@ class TasksTest < ActiveSupport::TestCase
31
31
 
32
32
  it 'deletes all tasks matching the filter when the time limit is not specified' do
33
33
  cleaner = ForemanTasks::Cleaner.new(:filter => 'label = "Actions::User::Create"')
34
- tasks_to_delete = [FactoryGirl.create(:dynflow_task, :user_create_task),
35
- FactoryGirl.create(:dynflow_task, :user_create_task) do |task|
34
+ tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
35
+ FactoryBot.create(:dynflow_task, :user_create_task) do |task|
36
36
  task.started_at = task.ended_at = Time.zone.now
37
37
  task.save
38
38
  end]
39
39
 
40
- tasks_to_keep = [FactoryGirl.create(:dynflow_task, :product_create_task)]
40
+ tasks_to_keep = [FactoryBot.create(:dynflow_task, :product_create_task)]
41
41
  cleaner.expects(:tasks_to_csv)
42
42
  cleaner.delete
43
43
  ForemanTasks::Task.where(id: tasks_to_delete).must_be_empty
@@ -46,10 +46,10 @@ class TasksTest < ActiveSupport::TestCase
46
46
 
47
47
  it 'supports passing empty filter (just delete all)' do
48
48
  cleaner = ForemanTasks::Cleaner.new(:filter => '', :after => '10d')
49
- tasks_to_delete = [FactoryGirl.create(:dynflow_task, :user_create_task),
50
- FactoryGirl.create(:dynflow_task, :product_create_task)]
49
+ tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
50
+ FactoryBot.create(:dynflow_task, :product_create_task)]
51
51
 
52
- tasks_to_keep = [FactoryGirl.create(:dynflow_task, :user_create_task) do |task|
52
+ tasks_to_keep = [FactoryBot.create(:dynflow_task, :user_create_task) do |task|
53
53
  task.started_at = task.ended_at = Time.zone.now
54
54
  task.save
55
55
  end]
@@ -62,8 +62,8 @@ class TasksTest < ActiveSupport::TestCase
62
62
  it 'backs tasks up before deleting' do
63
63
  dir = '/tmp'
64
64
  cleaner = ForemanTasks::Cleaner.new(:filter => '', :after => '10d', :backup_dir => dir)
65
- tasks_to_delete = [FactoryGirl.create(:dynflow_task, :user_create_task),
66
- FactoryGirl.create(:dynflow_task, :product_create_task)]
65
+ tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
66
+ FactoryBot.create(:dynflow_task, :product_create_task)]
67
67
 
68
68
  r, w = IO.pipe
69
69
  cleaner.expects(:with_backup_file)
@@ -8,8 +8,8 @@ module ForemanTasks
8
8
  User.current = User.where(:login => 'apiadmin').first
9
9
  end
10
10
 
11
- let(:own_task) { FactoryGirl.create(:dynflow_task, :set_owner => user) }
12
- let(:foreign_task) { FactoryGirl.create(:dynflow_task) }
11
+ let(:own_task) { FactoryBot.create(:dynflow_task, :set_owner => user) }
12
+ let(:foreign_task) { FactoryBot.create(:dynflow_task) }
13
13
 
14
14
  let(:edit_foreman_tasks_permission) do
15
15
  Permission.where(:name => :edit_foreman_tasks).first
@@ -24,7 +24,7 @@ module ForemanTasks
24
24
  end
25
25
 
26
26
  describe 'admin user' do
27
- let(:user) { FactoryGirl.create(:user, :admin) }
27
+ let(:user) { FactoryBot.create(:user, :admin) }
28
28
  it 'can see all tasks' do
29
29
  assert dynflow_console_authorized?
30
30
  assert dynflow_console_authorized?(own_task)
@@ -34,9 +34,9 @@ module ForemanTasks
34
34
 
35
35
  describe 'user with unlimited edit_foreman_tasks permissions' do
36
36
  let(:user) do
37
- user_role = FactoryGirl.create(:user_user_role)
38
- FactoryGirl.create(:filter,
39
- :role => user_role.role, :permissions => [edit_foreman_tasks_permission])
37
+ user_role = FactoryBot.create(:user_user_role)
38
+ FactoryBot.create(:filter,
39
+ :role => user_role.role, :permissions => [edit_foreman_tasks_permission])
40
40
  user_role.owner
41
41
  end
42
42
 
@@ -49,10 +49,10 @@ module ForemanTasks
49
49
 
50
50
  describe 'user with limited edit_foreman_tasks permissions' do
51
51
  let(:user) do
52
- user_role = FactoryGirl.create(:user_user_role)
53
- FactoryGirl.create(:filter,
54
- :search => 'owner.id = current_user',
55
- :role => user_role.role, :permissions => [edit_foreman_tasks_permission])
52
+ user_role = FactoryBot.create(:user_user_role)
53
+ FactoryBot.create(:filter,
54
+ :search => 'owner.id = current_user',
55
+ :role => user_role.role, :permissions => [edit_foreman_tasks_permission])
56
56
  user_role.owner
57
57
  end
58
58
 
@@ -64,7 +64,7 @@ module ForemanTasks
64
64
  end
65
65
 
66
66
  describe 'user without edit_foreman_tasks permissions' do
67
- let(:user) { FactoryGirl.create(:user) }
67
+ let(:user) { FactoryBot.create(:user) }
68
68
  it 'can not see any tasks' do
69
69
  refute dynflow_console_authorized?
70
70
  refute dynflow_console_authorized?(own_task)
@@ -12,7 +12,7 @@ describe ForemanTasks::ProxySelector do
12
12
  count = 3
13
13
  ProxyAPI::ForemanDynflow::DynflowProxy.any_instance.expects(:tasks_count).raises
14
14
  .then.times(count - 1).returns(0)
15
- proxies = FactoryGirl.create_list(:smart_proxy, count)
15
+ proxies = FactoryBot.create_list(:smart_proxy, count)
16
16
 
17
17
  available = proxies.reduce([]) do |found, _|
18
18
  found << proxy_selector.select_by_jobs_count(proxies)
@@ -40,14 +40,14 @@ describe ForemanTasks::ProxySelector do
40
40
  count = 3
41
41
  ProxyAPI::ForemanDynflow::DynflowProxy.any_instance.expects(:tasks_count).times(count).raises
42
42
  proxy_selector.stubs(:available_proxies =>
43
- { :global => FactoryGirl.create_list(:smart_proxy, count) })
43
+ { :global => FactoryBot.create_list(:smart_proxy, count) })
44
44
  proxy_selector.determine_proxy.must_equal :not_available
45
45
  end
46
46
 
47
47
  it 'returns first available proxy, prioritizing by strategy' do
48
48
  ProxyAPI::ForemanDynflow::DynflowProxy.any_instance.expects(:tasks_count).returns(0)
49
- fallback_proxy = FactoryGirl.build(:smart_proxy)
50
- global_proxy = FactoryGirl.build(:smart_proxy)
49
+ fallback_proxy = FactoryBot.build(:smart_proxy)
50
+ global_proxy = FactoryBot.build(:smart_proxy)
51
51
  ForemanTasks::ProxySelector.any_instance.stubs(:available_proxies =>
52
52
  { :fallback => [fallback_proxy],
53
53
  :global => [global_proxy] })
@@ -89,14 +89,14 @@ class RecurringLogicsTest < ActiveSupport::TestCase
89
89
  end
90
90
 
91
91
  it 'can be created from triggering' do
92
- triggering = FactoryGirl.build(:triggering, :recurring, :end_time_limited)
92
+ triggering = FactoryBot.build(:triggering, :recurring, :end_time_limited)
93
93
  logic = ForemanTasks::RecurringLogic.new_from_triggering(triggering)
94
94
  # Mysql coerces the times a bit
95
95
  logic.end_time.must_be_close_to(triggering.end_time, 1.second)
96
96
  end
97
97
 
98
98
  describe 'validation' do
99
- let(:logic) { FactoryGirl.build(:recurring_logic) }
99
+ let(:logic) { FactoryBot.build(:recurring_logic) }
100
100
 
101
101
  it 'is valid by default' do
102
102
  logic.must_be :valid?
@@ -63,11 +63,11 @@ module ForemanTasks
63
63
  children_count = 3
64
64
  task = spawn_task.call ParentAction, children_count
65
65
  # Parent task has task groups of its children
66
- task.task_groups.map(&:id).must_equal [1, 2, 3, 4]
66
+ task.task_groups.map(&:id).sort.must_equal [1, 2, 3, 4]
67
67
  # Children have the parent's and their own, they don't have their siblings' task groups
68
68
  task.sub_tasks.count.must_equal children_count
69
69
  task.sub_tasks.each do |sub_task|
70
- sub_task.task_groups.map(&:id).must_equal [1, sub_task.input[:id]]
70
+ sub_task.task_groups.map(&:id).sort.must_equal [1, sub_task.input[:id]].sort
71
71
  end
72
72
  end
73
73
  end
@@ -4,11 +4,11 @@ class TasksTest < ActiveSupport::TestCase
4
4
  describe 'filtering by current user' do
5
5
  before do
6
6
  @original_current_user = User.current
7
- @user_one = FactoryGirl.create(:user)
8
- @user_two = FactoryGirl.create(:user)
7
+ @user_one = FactoryBot.create(:user)
8
+ @user_two = FactoryBot.create(:user)
9
9
 
10
- @task_one = FactoryGirl.create(:some_task, :set_owner => @user_one)
11
- FactoryGirl.create(:some_task, :set_owner => @user_two)
10
+ @task_one = FactoryBot.create(:some_task, :set_owner => @user_one)
11
+ FactoryBot.create(:some_task, :set_owner => @user_two)
12
12
 
13
13
  User.current = @user_one
14
14
  end
@@ -25,16 +25,16 @@ class TasksTest < ActiveSupport::TestCase
25
25
 
26
26
  describe 'authorization filtering' do
27
27
  it 'can filter by the task subject' do
28
- user_role = FactoryGirl.create(:user_user_role)
28
+ user_role = FactoryBot.create(:user_user_role)
29
29
  user = user_role.owner
30
30
  role = user_role.role
31
- permission = FactoryGirl.build(:permission)
31
+ permission = FactoryBot.build(:permission)
32
32
  permission.resource_type = 'ForemanTasks::Task'
33
33
  permission.save!
34
- FactoryGirl.create(:filter, :role => role, :permissions => [permission])
34
+ FactoryBot.create(:filter, :role => role, :permissions => [permission])
35
35
 
36
36
  User.current = user
37
- task = FactoryGirl.create(:dynflow_task)
37
+ task = FactoryBot.create(:dynflow_task)
38
38
 
39
39
  auth = Authorizer.new(user)
40
40
  assert auth.can?(permission.name.to_sym, task)
@@ -42,17 +42,15 @@ class TasksTest < ActiveSupport::TestCase
42
42
  end
43
43
 
44
44
  describe 'consistency check' do
45
- let(:consistent_task) { FactoryGirl.create(:dynflow_task, :sync_with_dynflow => true) }
46
- let(:inconsistent_task) { FactoryGirl.create(:dynflow_task, :inconsistent_dynflow_task) }
45
+ let(:consistent_task) { FactoryBot.create(:dynflow_task, :sync_with_dynflow => true) }
46
+ let(:inconsistent_task) { FactoryBot.create(:dynflow_task, :inconsistent_dynflow_task) }
47
47
 
48
48
  it 'ensures the tasks marked as running are really running in Dynflow' do
49
- running_task_count = ForemanTasks::Task::DynflowTask.running.count
50
49
  consistent_task.state.must_equal 'planned'
51
50
  inconsistent_task.state.must_equal 'running'
52
51
 
53
- fixed_count = ForemanTasks::Task::DynflowTask.consistency_check
52
+ ForemanTasks::Task::DynflowTask.consistency_check
54
53
 
55
- fixed_count.must_equal running_task_count + 1
56
54
  consistent_task.reload.state.must_equal 'planned'
57
55
  inconsistent_task.reload.state.must_equal 'planned'
58
56
  end
@@ -60,7 +58,7 @@ class TasksTest < ActiveSupport::TestCase
60
58
 
61
59
  describe 'task without valid execution plan' do
62
60
  let(:task) do
63
- FactoryGirl.create(:dynflow_task).tap do |task|
61
+ FactoryBot.create(:dynflow_task).tap do |task|
64
62
  task.external_id = 'missing-task'
65
63
  end
66
64
  end
@@ -86,7 +84,7 @@ class TasksTest < ActiveSupport::TestCase
86
84
  :pending => 0
87
85
  }
88
86
  end
89
- let(:task) { FactoryGirl.create(:dynflow_task) }
87
+ let(:task) { FactoryBot.create(:dynflow_task) }
90
88
 
91
89
  describe 'without sub tasks' do
92
90
  it 'calculates the progress report correctly' do
@@ -95,8 +93,8 @@ class TasksTest < ActiveSupport::TestCase
95
93
  end
96
94
 
97
95
  describe 'with sub tasks' do
98
- let(:failed) { FactoryGirl.create(:dynflow_task).tap { |t| t.result = :error } }
99
- let(:success) { FactoryGirl.create(:dynflow_task).tap { |t| t.result = :success } }
96
+ let(:failed) { FactoryBot.create(:dynflow_task).tap { |t| t.result = :error } }
97
+ let(:success) { FactoryBot.create(:dynflow_task).tap { |t| t.result = :success } }
100
98
  before { task.sub_tasks = [success, failed] }
101
99
 
102
100
  it 'calculate the progress report correctly' do
@@ -121,8 +119,8 @@ class TasksTest < ActiveSupport::TestCase
121
119
  end
122
120
 
123
121
  describe 'recurring task' do
124
- let(:logic) { FactoryGirl.build(:recurring_logic) }
125
- let(:task) { FactoryGirl.create(:some_task) }
122
+ let(:logic) { FactoryBot.build(:recurring_logic) }
123
+ let(:task) { FactoryBot.create(:some_task) }
126
124
 
127
125
  it 'can indicate it is recurring' do
128
126
  refute task.recurring?
@@ -133,7 +131,7 @@ class TasksTest < ActiveSupport::TestCase
133
131
  end
134
132
 
135
133
  describe 'delayed task' do
136
- let(:task) { FactoryGirl.create(:some_task) }
134
+ let(:task) { FactoryBot.create(:some_task) }
137
135
 
138
136
  it 'can indicate it is delayed' do
139
137
  refute task.delayed?
@@ -3,18 +3,18 @@ require 'foreman_tasks_test_helper'
3
3
  class TriggeringTest < ActiveSupport::TestCase
4
4
  describe 'validation' do
5
5
  it 'is valid when immediate' do
6
- FactoryGirl.build(:triggering).must_be :valid?
6
+ FactoryBot.build(:triggering).must_be :valid?
7
7
  end
8
8
 
9
9
  it 'is validates future execution' do
10
- triggering = FactoryGirl.build(:triggering, :future)
10
+ triggering = FactoryBot.build(:triggering, :future)
11
11
  triggering.must_be :valid?
12
12
  triggering.start_before = triggering.start_at - 120
13
13
  triggering.wont_be :valid?
14
14
  end
15
15
 
16
16
  it 'is invalid when recurring logic is invalid' do
17
- triggering = FactoryGirl.build(:triggering, :recurring)
17
+ triggering = FactoryBot.build(:triggering, :recurring)
18
18
  triggering.must_be :valid?
19
19
  triggering.recurring_logic.stubs(:valid?).returns(false)
20
20
  triggering.wont_be :valid?
@@ -22,7 +22,7 @@ class TriggeringTest < ActiveSupport::TestCase
22
22
  end
23
23
 
24
24
  it 'cannot have mode set to arbitrary value' do
25
- triggering = FactoryGirl.build(:triggering)
25
+ triggering = FactoryBot.build(:triggering)
26
26
  triggering.must_be :valid?
27
27
  proc { triggering.mode = 'bogus' }.must_raise ArgumentError
28
28
  proc { triggering.mode = 27 }.must_raise ArgumentError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.9
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-09 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot_rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 4.8.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 4.8.0
83
97
  description: |
84
98
  The goal of this plugin is to unify the way of showing task statuses across the Foreman instance.
85
99
  It defines Task model for keeping the information about the tasks and Lock for assigning the tasks