dradis-csv_export 5.2.0 → 5.4.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d840015580b7bcc0adc47e8ae23b247b0dc4c449b3cb2b9f37f93e2479f6d1db
|
|
4
|
+
data.tar.gz: 37e347fd9c6e7922a1aeaf98e493c8490fad84f3408b18d2f0091ae626420a83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94f636a6c29cdea20b1d044875d23ea8da58ae7c3c451b653cd359162c569fe6dbe15f5b6c0df019d65e0b43ce23b85f71ed73ed7d169a29e30cb2c329eb34c3
|
|
7
|
+
data.tar.gz: bc7cbe24a27c24a9c35de8c53423ec8002a91534009211b5601941b72b91c80f20f8804a215ef0f0d4673e74e30236feae29e17ea795a877d957a3798ca23083
|
data/CHANGELOG.md
CHANGED
|
@@ -7,20 +7,19 @@ module Dradis::Plugins::CSVExport
|
|
|
7
7
|
return "The project didn't contain any issues"
|
|
8
8
|
else
|
|
9
9
|
# All fields from all Issues in the project
|
|
10
|
-
issue_keys
|
|
10
|
+
issue_keys = issues.map(&:fields).map(&:keys).flatten.uniq
|
|
11
|
+
|
|
12
|
+
evidence_by_issue = content_service.all_evidence.where(issue_id: issues.map(&:id)).group_by(&:issue_id)
|
|
11
13
|
|
|
12
14
|
# All fields from all Evidence in the project
|
|
13
15
|
evidence_keys = issues.map do |issue|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else
|
|
17
|
-
[]
|
|
18
|
-
end
|
|
16
|
+
issue_evidence = evidence_by_issue.fetch(issue.id, [])
|
|
17
|
+
issue_evidence.map(&:fields).map(&:keys).flatten.uniq
|
|
19
18
|
end.flatten.uniq
|
|
20
19
|
|
|
21
20
|
keys = issue_keys + evidence_keys
|
|
22
21
|
|
|
23
|
-
issue_row
|
|
22
|
+
issue_row = []
|
|
24
23
|
evidence_row = []
|
|
25
24
|
|
|
26
25
|
# Create the CSV data
|
|
@@ -37,9 +36,11 @@ module Dradis::Plugins::CSVExport
|
|
|
37
36
|
issue.fields.fetch(key, 'n/a')
|
|
38
37
|
end
|
|
39
38
|
|
|
39
|
+
issue_evidence = evidence_by_issue.fetch(issue.id, [])
|
|
40
|
+
|
|
40
41
|
# If we've got multiple Evidence, we add one row per Evidence
|
|
41
|
-
if
|
|
42
|
-
|
|
42
|
+
if issue_evidence.any?
|
|
43
|
+
issue_evidence.each do |evidence|
|
|
43
44
|
evidence_row = evidence_keys.map do |key|
|
|
44
45
|
evidence.fields.fetch(key, 'n/a')
|
|
45
46
|
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Run the spec in CE/Pro context with:
|
|
2
|
+
# rspec <relative path to dradis-csv_export>/spec/lib/dradis/plugins/csv_export/exporter_spec.rb
|
|
3
|
+
|
|
4
|
+
require 'rails_helper'
|
|
5
|
+
|
|
6
|
+
describe Dradis::Plugins::CSVExport::Exporter do
|
|
7
|
+
let(:project) { create(:project) }
|
|
8
|
+
let(:exporter) { described_class.new(project_id: project.id, scope: scope) }
|
|
9
|
+
|
|
10
|
+
context 'when the project has no issues' do
|
|
11
|
+
let(:scope) { :published }
|
|
12
|
+
|
|
13
|
+
it "returns a message saying the project didn't contain any issues" do
|
|
14
|
+
expect(exporter.export).to eq("The project didn't contain any issues")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context 'scope' do
|
|
19
|
+
let(:node) { create(:node, project: project) }
|
|
20
|
+
let!(:published_issue) do
|
|
21
|
+
create(:issue, node: project.issue_library, state: :published, text: "#[Title]#\nPublished issue\n")
|
|
22
|
+
end
|
|
23
|
+
let!(:draft_issue) do
|
|
24
|
+
create(:issue, node: project.issue_library, state: :draft, text: "#[Title]#\nDraft issue\n")
|
|
25
|
+
end
|
|
26
|
+
let!(:published_evidence) do
|
|
27
|
+
create(:evidence, issue: published_issue, node: node, state: :published, content: "#[EvidenceField]#\nPublished evidence\n")
|
|
28
|
+
end
|
|
29
|
+
let!(:draft_evidence) do
|
|
30
|
+
create(:evidence, issue: published_issue, node: node, state: :draft, content: "#[EvidenceField]#\nDraft evidence\n")
|
|
31
|
+
end
|
|
32
|
+
let!(:published_evidence_on_draft_issue) do
|
|
33
|
+
create(:evidence, issue: draft_issue, node: node, state: :published, content: "#[EvidenceField]#\nEvidence on draft issue\n")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'published scope' do
|
|
37
|
+
let(:scope) { :published }
|
|
38
|
+
|
|
39
|
+
it 'only includes published issues and evidence' do
|
|
40
|
+
csv = exporter.export
|
|
41
|
+
|
|
42
|
+
expect(csv).to include('Published issue')
|
|
43
|
+
expect(csv).not_to include('Draft issue')
|
|
44
|
+
expect(csv).to include('Published evidence')
|
|
45
|
+
expect(csv).not_to include('Draft evidence')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'excludes published evidence belonging to a non-published issue' do
|
|
49
|
+
csv = exporter.export
|
|
50
|
+
|
|
51
|
+
expect(csv).not_to include('Draft issue')
|
|
52
|
+
expect(csv).not_to include('Evidence on draft issue')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'all scope' do
|
|
57
|
+
let(:scope) { :all }
|
|
58
|
+
|
|
59
|
+
it 'includes issues and evidence regardless of state' do
|
|
60
|
+
csv = exporter.export
|
|
61
|
+
|
|
62
|
+
expect(csv).to include('Published issue')
|
|
63
|
+
expect(csv).to include('Draft issue')
|
|
64
|
+
expect(csv).to include('Published evidence')
|
|
65
|
+
expect(csv).to include('Draft evidence')
|
|
66
|
+
expect(csv).to include('Evidence on draft issue')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dradis-csv_export
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Martin
|
|
@@ -95,6 +95,7 @@ files:
|
|
|
95
95
|
- lib/dradis/plugins/csv_export/version.rb
|
|
96
96
|
- lib/tasks/thorfile.rb
|
|
97
97
|
- spec/csv_export_spec.rb
|
|
98
|
+
- spec/lib/dradis/plugins/csv_export/exporter_spec.rb
|
|
98
99
|
- spec/spec_helper.rb
|
|
99
100
|
homepage: https://dradis.com/support/guides/reporting/export_csv.html
|
|
100
101
|
licenses:
|
|
@@ -119,4 +120,5 @@ specification_version: 4
|
|
|
119
120
|
summary: CSV export plugin for the Dradis Framework.
|
|
120
121
|
test_files:
|
|
121
122
|
- spec/csv_export_spec.rb
|
|
123
|
+
- spec/lib/dradis/plugins/csv_export/exporter_spec.rb
|
|
122
124
|
- spec/spec_helper.rb
|