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

6115 add guid to comments and posts for user export #6185

Closed
wants to merge 5 commits into
base: develop
from

Conversation

Projects
None yet
4 participants
@Realtin
Copy link
Contributor

Realtin commented Jul 10, 2015

We (@zaziemo and I) added the guid for posts & comments in the user export and also some tests for the serializers.

We can add more tests for the other serializers that would be something useful.

Note: In the post_serializer_spec the check for the created_at Date only checks for the year because the to_json method ruins the Date Format.
I tried setting:
ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
but it didn't help much.

We can try to look into it more or maybe it is not that important.

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]}") }
end

This comment has been minimized.

@jhass

jhass Jul 10, 2015

Member

This file lacks the .rb extension ;)

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]}") }

This comment has been minimized.

@jhass

jhass Jul 10, 2015

Member

What do you mean by mess up? That the format doesn't match post.created_at.to_s? That would be correct, just get the same format with post.created_at.strftime("...") with ... being the right format of course.

This comment has been minimized.

@Realtin

Realtin Jul 10, 2015

Contributor

post.created_at.to_s is perfect but Export::PostSerializer.new(post).to_json results in:

expected "{\"post\":{\"guid\":\"15b5e700096d0133dc4548d705df9e7b\",\"text\":\"There are 10 ninjas in this photo.\",\"public\":false,\"diaspora_handle\":\"bob-person-1044ae13@example.net\",\"type\":\"StatusMessage\",\"image_url\":null,\"image_height\":null,\"image_width\":null,\"likes_count\":0,\"comments_count\":0,\"reshares_count\":0,\"created_at\":\"2015-07-10T20:06:33.300Z\"}}" to include "\"created_at\":\"2015-07-10 20:06:33 UTC\""

=> created_at\":\"2015-07-10T20:06:33.300Z\"

This comment has been minimized.

@jhass

jhass Jul 10, 2015

Member

That's simply ISO 8601:

[107] pry(main)> Time.now.utc.iso8601(3)                                                                                                                                
=> "2015-07-10T20:22:00.833Z"

@jhass jhass added this to the 0.5.2.0 milestone Jul 10, 2015

let(:comment) { create(:comment) }
subject(:json_output) { Export::CommentSerializer.new(comment).to_json }

it { is_expected.to include("\"guid\":\"#{comment.guid}\"") }

This comment has been minimized.

@jhass

jhass Jul 10, 2015

Member

Actually it would be good to use percent literals for all these to avoid all the escaping:

it { is_expected.to include %("guid":"#{comment.guid}") }

This comment has been minimized.

@Realtin

Realtin Jul 10, 2015

Contributor

I wasn't aware of this! Thank you!

@jhass

This comment has been minimized.

Copy link
Member

jhass commented Jul 10, 2015

Merged as 9eadc25 787c1cf

Thank you!

@jhass jhass closed this in 9eadc25 Jul 10, 2015

@finnp

This comment has been minimized.

Copy link

finnp commented Jul 11, 2015

wooo 🍸

@zaziemo zaziemo deleted the TeamDeltaQuadrant:6115-add-guid-to-comments-and-posts branch Jul 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment