Skip to content

Commit

Permalink
Add valid_email & confirmed_at to /me-only attributes (#4272)
Browse files Browse the repository at this point in the history
* Add valid_email & confirmed_at to /me-only attributes

* Add confirmed_at to attributes, remove dupe

* Don't use Time.current in factories

* Add usercontroller#me spec for confirmed_at
  • Loading branch information
zwolf authored Jan 8, 2024
1 parent 5fd77a4 commit 226e5cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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

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
result = user_response["confirmed_at"]
# 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

0 comments on commit 226e5cb

Please sign in to comment.