foreman-tasks 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/lib/actions/middleware/keep_current_taxonomies.rb +2 -2
- data/app/lib/actions/middleware/keep_current_user.rb +2 -1
- data/foreman-tasks.gemspec +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/test/lib/actions/middleware/keep_current_taxonomies_test.rb +24 -0
- data/test/lib/actions/middleware/keep_current_user_test.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eeb338059e6663ed8fffe8dc6bee396a1eb96bae7a695c2f56eff9ac5e44763
|
4
|
+
data.tar.gz: 7b9d63c8663eeece3479d9c3628dd514d00e5ff00595ee66097cae917342bd29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d46d737bcfe6f9aef1ce43c53de352e598653e3de2134d72d913cc63047d1867697c00b0aae5373c31d3664023167f332b277c0eaa352c80e62e03688a51271
|
7
|
+
data.tar.gz: 783a5b165f308ddb6571660598f19d85e5e20323be9a467851569f57ebf15f9bb1b4e35390d2f412510feb1a4c6f91269726800be8e18acf9fdf365785516a1f
|
@@ -39,12 +39,12 @@ module Actions
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def restore_current_taxonomies
|
42
|
+
old_taxonomies = [Organization, Location].reduce({}) { |acc, taxonomy| acc.merge(taxonomy => taxonomy.current) }
|
42
43
|
Organization.current = Organization.unscoped.find(action.input[:current_organization_id]) if action.input[:current_organization_id].present?
|
43
44
|
Location.current = Location.unscoped.find(action.input[:current_location_id]) if action.input[:current_location_id].present?
|
44
45
|
yield
|
45
46
|
ensure
|
46
|
-
|
47
|
-
Location.current = nil
|
47
|
+
old_taxonomies.each { |taxonomy, value| taxonomy.current = value }
|
48
48
|
end
|
49
49
|
|
50
50
|
def current_taxonomies?
|
@@ -39,10 +39,11 @@ module Actions
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def restore_curent_user
|
42
|
+
old_user = User.current
|
42
43
|
User.current = User.unscoped.find(action.input[:current_user_id]) if action.input[:current_user_id].present?
|
43
44
|
yield
|
44
45
|
ensure
|
45
|
-
User.current =
|
46
|
+
User.current = old_user
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
data/foreman-tasks.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.authors = ["Ivan Nečas"]
|
12
12
|
s.email = ["inecas@redhat.com"]
|
13
13
|
s.homepage = "https://github.com/theforeman/foreman-tasks"
|
14
|
-
s.summary = "Foreman plugin for showing tasks information for
|
14
|
+
s.summary = "Foreman plugin for showing tasks information for resources and users"
|
15
15
|
s.description = <<-DESC
|
16
16
|
The goal of this plugin is to unify the way of showing task statuses across the Foreman instance.
|
17
17
|
It defines Task model for keeping the information about the tasks and Lock for assigning the tasks
|
@@ -11,6 +11,13 @@ module Actions
|
|
11
11
|
def run; end
|
12
12
|
end
|
13
13
|
|
14
|
+
class TestHookAction < Support::DummyDynflowAction
|
15
|
+
middleware.use KeepCurrentTaxonomies
|
16
|
+
execution_plan_hooks.use :null_hook, :on => :planning
|
17
|
+
|
18
|
+
def null_hook; end
|
19
|
+
end
|
20
|
+
|
14
21
|
before do
|
15
22
|
@org = mock('organization')
|
16
23
|
@org.stubs(:id).returns(1)
|
@@ -62,6 +69,23 @@ module Actions
|
|
62
69
|
@action = run_action(@action)
|
63
70
|
end
|
64
71
|
end
|
72
|
+
|
73
|
+
describe 'hook' do
|
74
|
+
test 'does not unset taxonomies before planning' do
|
75
|
+
Organization.stubs(:current).returns(@org)
|
76
|
+
Location.stubs(:current).returns(@loc)
|
77
|
+
|
78
|
+
Organization.stubs(:current=)
|
79
|
+
Location.stubs(:current=)
|
80
|
+
|
81
|
+
triggered = ForemanTasks.trigger(TestHookAction)
|
82
|
+
task = ForemanTasks::Task.where(:external_id => triggered.id).first
|
83
|
+
wait_for { task.reload.state == 'stopped' }
|
84
|
+
|
85
|
+
assert_equal(@org.id, task.execution_plan.entry_action.input['current_organization_id'])
|
86
|
+
assert_equal(@loc.id, task.execution_plan.entry_action.input['current_location_id'])
|
87
|
+
end
|
88
|
+
end
|
65
89
|
end
|
66
90
|
end
|
67
91
|
end
|
@@ -11,11 +11,28 @@ module Actions
|
|
11
11
|
def run; end
|
12
12
|
end
|
13
13
|
|
14
|
+
class TestHookAction < Support::DummyDynflowAction
|
15
|
+
middleware.use KeepCurrentUser
|
16
|
+
execution_plan_hooks.use :null_hook, :on => :planning
|
17
|
+
|
18
|
+
def null_hook; end
|
19
|
+
end
|
20
|
+
|
14
21
|
before do
|
15
22
|
@user = mock('user')
|
16
23
|
@user.stubs(:id).returns(1)
|
17
24
|
end
|
18
25
|
|
26
|
+
describe 'hook' do
|
27
|
+
test 'does not reset current user before planning' do
|
28
|
+
triggered = ForemanTasks.trigger(TestHookAction)
|
29
|
+
task = ForemanTasks::Task.where(:external_id => triggered.id).first
|
30
|
+
wait_for { task.reload.state == 'stopped' }
|
31
|
+
|
32
|
+
assert_equal(User.current.id, task.execution_plan.entry_action.input['current_user_id'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
19
36
|
describe 'plan' do
|
20
37
|
test 'with current user set' do
|
21
38
|
User.expects(:current).twice.returns(@user)
|
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.15.
|
4
|
+
version: 0.15.3
|
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: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks-core
|
@@ -434,7 +434,7 @@ rubyforge_project:
|
|
434
434
|
rubygems_version: 2.7.6
|
435
435
|
signing_key:
|
436
436
|
specification_version: 4
|
437
|
-
summary: Foreman plugin for showing tasks information for
|
437
|
+
summary: Foreman plugin for showing tasks information for resources and users
|
438
438
|
test_files:
|
439
439
|
- test/controllers/api/recurring_logics_controller_test.rb
|
440
440
|
- test/controllers/api/tasks_controller_test.rb
|