Skip to content
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

Add valid_email & confirmed_at to /me-only attributes #4272

Merged
merged 6 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/serializers/user_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UserSerializer
project_email_communication beta_email_communication nasa_email_communication
uploaded_subjects_count subject_limit admin login_prompt zooniverse_id
upload_whitelist valid_email ux_testing_email_communication
intervention_notifications banned
intervention_notifications banned confirmed_at
).freeze

attributes :id, :login, :display_name, :credited_name, :email, :languages,
Expand All @@ -18,7 +18,7 @@ class UserSerializer
:subject_limit, :uploaded_subjects_count, :admin, :href, :login_prompt,
:private_profile, :zooniverse_id, :upload_whitelist, :avatar_src,
:valid_email, :ux_testing_email_communication, :intervention_notifications,
:banned
:banned, :confirmed_at
zwolf marked this conversation as resolved.
Show resolved Hide resolved

can_include :classifications, :project_preferences, :collection_preferences,
projects: { param: "owner", value: "login" },
Expand Down
6 changes: 6 additions & 0 deletions spec/controllers/api/v1/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@
expect(result).to eq(user.upload_whitelist)
end

it "should have the confirmed_at for the user" do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
RSpec/ExampleWording: Do not use should when describing your tests.

result = user_response["confirmed_at"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

# Dates are JSON serialized via iso8601 and .to_json adds quotes
expect(result).to eq(user.confirmed_at.iso8601(3))
end

it_behaves_like "an api response"
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
sequence(:email) {|n| "example#{n}@example.com"}
password { 'password' }
encrypted_password { User.new.send(:password_digest, 'password') }
confirmed_at { Time.current }
confirmation_sent_at { Time.current }
confirmed_at { Time.utc(2024, 1, 1, 12, 0, 0) }
confirmation_sent_at { Time.utc(2024, 1, 1, 12, 0, 0) }
credited_name { 'Dr User' }
activated_state { :active }
sequence(:login) { |n| "new_user_#{n}" }
Expand Down