From 787c1cfce941581e55abe6db5b269d84abdfeb73 Mon Sep 17 00:00:00 2001 From: zaziemo Date: Thu, 9 Jul 2015 20:53:15 +0200 Subject: [PATCH] add spec and code to include guid in comment's export #6115 --- app/serializers/export/comment_serializer.rb | 3 ++- spec/serializers/comment_serializer_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 spec/serializers/comment_serializer_spec.rb diff --git a/app/serializers/export/comment_serializer.rb b/app/serializers/export/comment_serializer.rb index 72e9ccbf5..58b5bde1a 100644 --- a/app/serializers/export/comment_serializer.rb +++ b/app/serializers/export/comment_serializer.rb @@ -1,6 +1,7 @@ module Export class CommentSerializer < ActiveModel::Serializer - attributes :text, + attributes :guid, + :text, :post_guid def post_guid diff --git a/spec/serializers/comment_serializer_spec.rb b/spec/serializers/comment_serializer_spec.rb new file mode 100644 index 000000000..3c34bc655 --- /dev/null +++ b/spec/serializers/comment_serializer_spec.rb @@ -0,0 +1,10 @@ +require "spec_helper" + +describe Export::CommentSerializer do + let(:comment) { create(:comment) } + subject(:json_output) { Export::CommentSerializer.new(comment).to_json } + + it { is_expected.to include("\"guid\":\"#{comment.guid}\"") } + it { is_expected.to include("\"post_guid\":\"#{comment.post.guid}\"") } + it { is_expected.to include("\"text\":\"#{comment.text}\"") } +end