ProfilePreviewCard serializes the user's created at, not the profile (#14392)

This matches what happens for the html preview ("Joined" is the user's
created_at timestamp), and what the json builder does:

    json.created_at utc_iso_timestamp(@user.created_at)

Update the test cases to assert the profile preview is showing the
user's created_at, not the profile's created at.

Since these are almost always the same thing, we didn't notice
this. However, if a user is created just before the second boundary,
and their profile created immediately after the second boundary (so
that the iso8601 values have distinct seconds) this could fail when
looking at the wrong objects timestamp.

To test this locally I modified the user let block to update the
timestamp to be a day earlier (this would not have happened in
practice but was sufficient to cover the use case).

     let(:user) { create(:profile).user.tap {|u| u.update(created_at: 1.day.ago) } }
This commit is contained in:
Daniel Uber 2021-08-02 15:03:11 -05:00 committed by GitHub
parent b8edc3c185
commit b6a1d59c28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -65,7 +65,7 @@ RSpec.describe "ProfilePreviewCards", type: :request do
expect(preview_card["work"]).to eq(profile.work)
expect(preview_card["location"]).to eq(profile.location)
expect(preview_card["education"]).to eq(profile.education)
expect(preview_card["created_at"]).to eq(profile.created_at.utc.iso8601)
expect(preview_card["created_at"]).to eq(user.created_at.utc.iso8601)
end
it "has the correct card color" do
@ -117,7 +117,7 @@ RSpec.describe "ProfilePreviewCards", type: :request do
expect(preview_card["work"]).to eq(profile.work)
expect(preview_card["location"]).to eq(profile.location)
expect(preview_card["education"]).to eq(profile.education)
expect(preview_card["created_at"]).to eq(profile.created_at.utc.iso8601)
expect(preview_card["created_at"]).to eq(user.created_at.utc.iso8601)
end
it "has the correct card color" do