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