foreman-tasks 0.7.5 → 0.7.6
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 +8 -8
- data/app/helpers/foreman_tasks/tasks_helper.rb +2 -2
- data/app/lib/actions/proxy_action.rb +4 -3
- data/app/models/foreman_tasks/task.rb +3 -3
- data/app/models/foreman_tasks/task/dynflow_task.rb +13 -7
- data/lib/foreman_tasks/version.rb +1 -1
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +5 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWM5N2ZhYzFhMzkxNDFhYTk2MGE4ZGRkNzNjNzRiZTlkNjJmNDdhNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODZiMDI1YmY1MDQ1ODBiMGZiZjE0NjMwNDhiNGUzMzY3YmIwM2FjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjIxYzA5NDE2YTlhMzVlZDdhYWFhOWY2ODg2MWNjNTI5ZjkyM2ZlMWU4MmY1
|
10
|
+
MzYzNGVjZTM4NDUyYTc2NDEwNWMxMjQyODdlYjU1YjM4ZjA5ZWRiYmExZjNj
|
11
|
+
NzI2OTkzMGIzZjA5MDI2YTFkMTUzZjdkNDdkY2RhMTM5MjkwZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDNkMGZlMDkzMTg1MjQ4YmUxZmRhNGFhZTQ5N2Y4YzUxMTBiM2EyZTIzMDIw
|
14
|
+
MGZlM2E0NDQyYzRiZTIwNDU2ZDBjNzQ5OGI1NmFlNTMyZGE2OWVmMGM2NzBl
|
15
|
+
YWMzNDUyMzViYWMxYmI4MjcwOWExNTFlYzI3NmM2MThmODRlZjk=
|
@@ -2,8 +2,8 @@ module ForemanTasks
|
|
2
2
|
module TasksHelper
|
3
3
|
def format_task_input(task, include_action = false)
|
4
4
|
parts = []
|
5
|
-
parts << task.
|
6
|
-
parts << Array(task.
|
5
|
+
parts << task.get_humanized(:name) if include_action
|
6
|
+
parts << Array(task.get_humanized(:input)).map do |part|
|
7
7
|
if part.is_a? Array
|
8
8
|
part[1][:text]
|
9
9
|
else
|
@@ -147,9 +147,10 @@ module Actions
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def format_exception(exception)
|
150
|
-
{ output[:proxy_task_id]
|
151
|
-
|
152
|
-
|
150
|
+
{ :proxy_task_id => output[:proxy_task_id],
|
151
|
+
:exception_class => exception.class.name,
|
152
|
+
:exception_message => exception.message,
|
153
|
+
:timestamp => Time.now.to_f }
|
153
154
|
end
|
154
155
|
|
155
156
|
def handle_connection_exception(exception, event = nil)
|
@@ -31,14 +31,14 @@ module ForemanTasks
|
|
31
31
|
scoped_search :in => :owners, :on => :login, :complete_value => true, :rename => "owner.login", :ext_method => :search_by_owner
|
32
32
|
scoped_search :in => :owners, :on => :firstname, :complete_value => true, :rename => "owner.firstname", :ext_method => :search_by_owner
|
33
33
|
|
34
|
-
scope :active, -> { where('state != ?', :stopped) }
|
35
|
-
scope :running, -> { where("state NOT IN ('stopped', 'paused')") }
|
34
|
+
scope :active, -> { where('foreman_tasks_tasks.state != ?', :stopped) }
|
35
|
+
scope :running, -> { where("foreman_tasks_tasks.state NOT IN ('stopped', 'paused')") }
|
36
36
|
scope :for_resource,
|
37
37
|
(lambda do |resource|
|
38
38
|
joins(:locks).where(:"foreman_tasks_locks.resource_id" => resource.id,
|
39
39
|
:"foreman_tasks_locks.resource_type" => resource.class.name)
|
40
40
|
end)
|
41
|
-
scope :for_action_types, (lambda { |action_types| where('label IN (?)', Array(action_types)) })
|
41
|
+
scope :for_action_types, (lambda { |action_types| where('foreman_tasks_tasks.label IN (?)', Array(action_types)) })
|
42
42
|
|
43
43
|
def input
|
44
44
|
{}
|
@@ -83,14 +83,20 @@ module ForemanTasks
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def get_humanized(method)
|
86
|
-
|
87
|
-
if
|
88
|
-
|
89
|
-
main_action.send method
|
90
|
-
rescue => error
|
91
|
-
"#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
|
92
|
-
end
|
86
|
+
@humanized_cache ||= {}
|
87
|
+
if [:name, :input, :output, :error].include?(method)
|
88
|
+
method = "humanized_#{method}".to_sym
|
93
89
|
end
|
90
|
+
Match! method, :humanized_name, :humanized_input, :humanized_output, :humanized_errors
|
91
|
+
@humanized_cache[method] ||= begin
|
92
|
+
if main_action.respond_to? method
|
93
|
+
begin
|
94
|
+
main_action.send method
|
95
|
+
rescue Exception => error # rubocop:disable Lint/RescueException
|
96
|
+
"#{error.message} (#{error.class})\n#{error.backtrace.join "\n"}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
94
100
|
end
|
95
101
|
|
96
102
|
def self.consistency_check
|
@@ -2,13 +2,12 @@ require "foreman_tasks_test_helper"
|
|
2
2
|
|
3
3
|
module ForemanTasks
|
4
4
|
class TasksHelperTest < ActionView::TestCase
|
5
|
-
|
6
5
|
describe 'when formatting simple input' do
|
7
6
|
before do
|
8
7
|
@task = FactoryGirl.build(:dynflow_task, :user_create_task)
|
9
|
-
humanized = {:
|
8
|
+
humanized = { :humanized_name => "Create", :humanized_input => [[:user, {:text => "user 'Anonymous Admin'", :link => nil}]] }
|
9
|
+
@task.instance_variable_set('@humanized_cache', humanized)
|
10
10
|
@task.stubs(:input).returns({"user"=>{"id"=>1, "name"=>"Anonymous Admin"}, "locale"=>"en"})
|
11
|
-
@task.stubs(:humanized).returns(humanized)
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'formats the task input properly' do
|
@@ -21,17 +20,15 @@ module ForemanTasks
|
|
21
20
|
describe 'when formatting input' do
|
22
21
|
before do
|
23
22
|
@task = FactoryGirl.build(:dynflow_task, :product_create_task)
|
24
|
-
humanized = {:
|
25
|
-
|
26
|
-
|
27
|
-
:errors=>[]}
|
23
|
+
humanized = { :humanized_name => "Create",
|
24
|
+
:humanized_input => [[:product, { :text => "product 'product-2'", :link => "#/products/3/info"}], [:organization, { :text => "organization 'test-0'", :link => "/organizations/3/edit" }]]}
|
25
|
+
@task.instance_variable_set('@humanized_cache', humanized)
|
28
26
|
input = {"product"=>{"id"=>3, "name"=>"product-2", "label"=>"product-2", "cp_id"=>nil},
|
29
27
|
"provider"=>{"id"=>3, "name"=>"Anonymous"},
|
30
28
|
"organization"=>{"id"=>3, "name"=>"test-0", "label"=>"test-0"},
|
31
29
|
"cp_id"=>"1412251033866",
|
32
30
|
"locale"=>"en"}
|
33
31
|
@task.stubs(:input).returns(input)
|
34
|
-
@task.stubs(:humanized).returns(humanized)
|
35
32
|
end
|
36
33
|
|
37
34
|
it 'formats the task input properly' do
|
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.7.
|
4
|
+
version: 0.7.6
|
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: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|