From 345ea2102f7058c982985398eb4f616739b4e968 Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Wed, 20 Dec 2023 14:14:13 -0600 Subject: [PATCH 1/4] Add valid_email & confirmed_at to /me-only attributes --- app/serializers/user_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index c8edf087b..b4b72cf1b 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 valid_email confirmed_at ).freeze attributes :id, :login, :display_name, :credited_name, :email, :languages, From 3dbd44f1b11457585b67e047286da25177eb487b Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Fri, 5 Jan 2024 13:50:48 -0600 Subject: [PATCH 2/4] Add confirmed_at to attributes, remove dupe --- app/serializers/user_serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index b4b72cf1b..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 valid_email confirmed_at + 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" }, From b7e36fc1b696aa8d744cbe8fc4881203a1648622 Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Fri, 5 Jan 2024 13:51:09 -0600 Subject: [PATCH 3/4] Don't use Time.current in factories --- spec/factories/users.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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}" } From cfb316c48a1f23f8307ea2a5390904cf9a22ca9d Mon Sep 17 00:00:00 2001 From: Zach Wolfenbarger Date: Fri, 5 Jan 2024 15:38:32 -0600 Subject: [PATCH 4/4] Add usercontroller#me spec for confirmed_at --- spec/controllers/api/v1/users_controller_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) 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