foreman-tasks 0.15.9 → 0.15.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d07f034015f51e6df43b28bbef6155ec69b6a7de6060e76342f8da044231fadb
4
- data.tar.gz: dd9919d3c5ea799e734494a628519f958dcdc00f8e0b9a2891ee1afd04ac07df
3
+ metadata.gz: c59c8e933514a6d3ca2f5f0cfa17da2335c24d1821aa9a9d96c8abcf0a935fe7
4
+ data.tar.gz: 3d7b88cdd625b8ac450b5f36dec1de26374c8a2b265e49c779e581ffc93cef48
5
5
  SHA512:
6
- metadata.gz: aae83a81b3efa9de6a56044c5c61489564cba70ccde2e0e19ca1224151dcb80341856f75dafd93eb6e57fd73d1416a744f92cd6701b3b7276aa36988d8308537
7
- data.tar.gz: d65aee899c9a75b1bdbfeca54b1cd089aa39bd44bd003d76b89a0455d782a27182f72df2f2d8708220d7b6ed33812ea2f90aaac1b8caa43ae3d2d2ba6de0e1df
6
+ metadata.gz: acd6a37cd6260beece7fc8729b6aa91d40c4b9fff1c8f64620a84ca67cf528e7dcefffc132e010076da9d8083f4da4863753a1eb1b9eaaa10bc8f60d18655d2a
7
+ data.tar.gz: 4e7aa88a764c0716b28396479cc9c82fdfbf9c00ec4f66576bff55ebc42a630c9814ee7a8528d399c56b10ce297ea662e861cf836a97f5be52bc3d3fd44cd89e
@@ -16,7 +16,8 @@ module ForemanTasks
16
16
  end
17
17
 
18
18
  def summary
19
- render json: Task::Summarizer.new(resource_base, params[:recent_timeframe].to_i).summary
19
+ scope = resource_base.search_for(current_taxonomy_search).select(:id)
20
+ render json: Task::Summarizer.new(Task.where(:id => scope), params[:recent_timeframe].to_i).summary
20
21
  end
21
22
 
22
23
  def sub_tasks
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.15.9'.freeze
2
+ VERSION = '0.15.10'.freeze
3
3
  end
@@ -41,6 +41,41 @@ module ForemanTasks
41
41
  response = JSON.parse(@response.body)
42
42
  assert_equal 0, response['stopped']['total']
43
43
  end
44
+
45
+ describe 'taxonomy scoping' do
46
+ before do
47
+ @organizations = [0, 0].map { FactoryBot.create(:organization) }
48
+ @locations = [0, 0].map { FactoryBot.create(:location) }
49
+ @tasks = [0, 0].map { FactoryBot.create(:some_task) }
50
+ @tasks.zip(@organizations, @locations).each do |task, org, loc|
51
+ Lock.link!(org, task.id)
52
+ Lock.link!(loc, task.id)
53
+ end
54
+ end
55
+
56
+ it 'does not limit if unset' do
57
+ get(:summary, params: { recent_timeframe: 24 }, session: set_session_user)
58
+ assert_response :success
59
+ response = JSON.parse(@response.body)
60
+ assert_equal 2, response['stopped']['total']
61
+ end
62
+
63
+ it 'finds only tasks with matching taxonomies' do
64
+ get(:summary, params: { recent_timeframe: 24 },
65
+ session: set_session_user.merge(:organization_id => @organizations.first, :location_id => @locations.first))
66
+ assert_response :success
67
+ response = JSON.parse(@response.body)
68
+ assert_equal 1, response['stopped']['total']
69
+ end
70
+
71
+ it 'find no tasks when taxonomy combination contains no tasks' do
72
+ get(:summary, params: { recent_timeframe: 24 },
73
+ session: set_session_user.merge(:organization_id => @organizations.first, :location_id => @locations.last))
74
+ assert_response :success
75
+ response = JSON.parse(@response.body)
76
+ assert_equal 0, response['stopped']['total']
77
+ end
78
+ end
44
79
  end
45
80
 
46
81
  it 'supports csv export' 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.15.9
4
+ version: 0.15.10
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-09-05 00:00:00.000000000 Z
11
+ date: 2019-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core