Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix card comments xml #1025

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Bugs fixes:
- [entity]:
- [future tense verb] [bug fix]
- Project export: Fix card comments not exported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Project export: Fix card comments not exported
- Project export: Fix export for comments in cards

- Bug tracker items:
- [item]
- New integrations:
Expand Down
8 changes: 5 additions & 3 deletions app/models/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def to_xml(xml_builder, includes: [], version: 3)
end

if includes.include?(:comments)
card_builder.comments do |comment_builder|
comments.each do |comment|
comment.to_xml(comment_builder)
card_builder.comments do |comments_builder|
comments_builder.comment do |comment_builder|
comments.each do |comment|
comment.to_xml(comment_builder)
end
end
end
end
Expand Down
32 changes: 32 additions & 0 deletions spec/features/export/v3/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,37 @@

expect(@result).to include(node_board_xml)
end

context 'card with a comment' do
let(:card) do
board = create(:board, node: current_project.methodology_library, project: current_project)
list = create(:list, board: board)
create(:card, list: list)
end

let(:comment) do
create(:comment,
content: 'Sample card comment',
commentable: card,
user: @logged_in_as
)
end

it 'creates the comment xml' do
export_options = {
plugin: Dradis::Plugins::Projects,
project_id: current_project.id
}
exporter =
Dradis::Plugins::Projects::Export::V3::Template.new(export_options)

comment_xml = "<comment>"\
"<content><![CDATA[Sample card comment]]></content>"\
"<author>#{@logged_in_as.email}</author>"\
"<created_at>#{comment.created_at.to_i}</created_at>"\
"</comment>"
expect(exporter.export).to include(comment_xml)
end
end
end
end