From 226e5cb5dd5779ae72b093b0dc291743ee462ee5 Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Mon, 8 Jan 2024 11:19:07 -0600 Subject: [PATCH] Add valid_email & confirmed_at to /me-only attributes (#4272) * 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 --- app/serializers/user_serializer.rb | 4 ++-- spec/controllers/api/v1/users_controller_spec.rb | 6 ++++++ spec/factories/users.rb | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index c8edf087b..b9b56840e 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -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, @@ -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" }, diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index 5190ecad0..6e042757c 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -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 diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 9d1a11be9..58cec5c91 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -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}" }