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 all 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 export for comments in cards
- Bug tracker items:
- [item]
- New integrations:
Expand Down
10 changes: 6 additions & 4 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def self.mentionable_users(resource, extra_scope = nil)
end

def to_xml(xml_builder, version: 3)
xml_builder.content do
xml_builder.cdata!(content)
xml_builder.comment do |comment_builder|
comment_builder.content do
comment_builder.cdata!(content)
end
comment_builder.author(user.email)
comment_builder.created_at(created_at.to_i)
end
xml_builder.author(user.email)
xml_builder.created_at(created_at.to_i)
end

private
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