From 787c1cfce941581e55abe6db5b269d84abdfeb73 Mon Sep 17 00:00:00 2001 From: zaziemo Date: Thu, 9 Jul 2015 20:53:15 +0200 Subject: [PATCH 1/2] 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 From 9eadc251aefb4206884a1068dce6e62a914bc54c Mon Sep 17 00:00:00 2001 From: realtin Date: Fri, 10 Jul 2015 17:24:15 +0200 Subject: [PATCH 2/2] added post guid to the post_serializer closes #6185 --- Changelog.md | 1 + app/serializers/export/post_serializer.rb | 3 ++- spec/serializers/comment_serializer_spec.rb | 6 +++--- spec/serializers/post_serializer_spec.rb | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 spec/serializers/post_serializer_spec.rb diff --git a/Changelog.md b/Changelog.md index 493055112..e0ddba10b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ * Add configuration options for some debug logs [#6090](https://github.com/diaspora/diaspora/pull/6090) * Send new users a welcome message from the podmin [#6128](https://github.com/diaspora/diaspora/pull/6128) * Cleanup temporary upload files daily [#6147](https://github.com/diaspora/diaspora/pull/6147) +* Add guid to posts and comments in the user export [#6185](https://github.com/diaspora/diaspora/pull/6185) # 0.5.1.2 diff --git a/app/serializers/export/post_serializer.rb b/app/serializers/export/post_serializer.rb index 0a19d30b7..77a79c3e5 100644 --- a/app/serializers/export/post_serializer.rb +++ b/app/serializers/export/post_serializer.rb @@ -1,6 +1,7 @@ module Export class PostSerializer < ActiveModel::Serializer - attributes :text, + attributes :guid, + :text, :public, :diaspora_handle, :type, diff --git a/spec/serializers/comment_serializer_spec.rb b/spec/serializers/comment_serializer_spec.rb index 3c34bc655..36578a628 100644 --- a/spec/serializers/comment_serializer_spec.rb +++ b/spec/serializers/comment_serializer_spec.rb @@ -4,7 +4,7 @@ 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}\"") } + 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 diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb new file mode 100644 index 000000000..b891f2b5d --- /dev/null +++ b/spec/serializers/post_serializer_spec.rb @@ -0,0 +1,20 @@ +require "spec_helper" + +describe Export::PostSerializer do + let(:post) { create(:status_message_with_photo) } + subject(:json_output) { Export::PostSerializer.new(post).to_json } + + it { is_expected.to include %("guid":"#{post.guid}") } + it { is_expected.to include %("text":"#{post.text}") } + it { is_expected.to include %("public":#{post.public}) } + it { is_expected.to include %("diaspora_handle":"#{post.diaspora_handle}") } + it { is_expected.to include %("type":"#{post.type}") } + it { is_expected.to include %("image_url":#{post.image_url}) } + it { is_expected.to include %("image_height":#{post.image_height}) } + it { is_expected.to include %("image_width":#{post.image_width}) } + it { is_expected.to include %("likes_count":#{post.likes_count}) } + it { is_expected.to include %("comments_count":#{post.comments_count}) } + it { is_expected.to include %("reshares_count":#{post.reshares_count}) } + it { is_expected.to include %("created_at":"#{post.created_at.to_s[0, 4]}) } + it { is_expected.to include %("created_at":"#{post.created_at.strftime('%FT%T.%LZ')}) } +end