DEV: Add test (#10064)

DEV: Add test (#10064)

Follow-up-to 84dfaad137a215bf722388cccbe22f593279f5a2

diff --git a/spec/components/email_updater_spec.rb b/spec/components/email_updater_spec.rb
index 3476f48..4370961 100644
--- a/spec/components/email_updater_spec.rb
+++ b/spec/components/email_updater_spec.rb
@@ -159,6 +159,8 @@ describe EmailUpdater do
 
       context 'confirming a valid token' do
         it "adds a user email" do
+          expect(UserHistory.where(action: UserHistory.actions[:add_email], acting_user_id: user.id).last).to be_present
+
           Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :notify_old_email_add, to_address: old_email))
           updater.confirm(@change_req.new_email_token.token)
           expect(updater.errors).to be_blank
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 4e91e14..ec5adf4 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -2581,7 +2581,8 @@ describe UsersController do
       expect(user_email.reload.primary).to eq(true)
       expect(other_email.reload.primary).to eq(false)
 
-      put "/u/#{user.username}/preferences/primary-email.json", params: { email: other_email.email }
+      expect { put "/u/#{user.username}/preferences/primary-email.json", params: { email: other_email.email } }
+        .to change { UserHistory.where(action: UserHistory.actions[:update_email], acting_user_id: user.id).count }.by(1)
       expect(response.status).to eq(200)
       expect(user_email.reload.primary).to eq(false)
       expect(other_email.reload.primary).to eq(true)
@@ -2604,7 +2605,8 @@ describe UsersController do
       expect(response.status).to eq(428)
       expect(user.reload.user_emails.pluck(:email)).to contain_exactly(user_email.email, other_email.email)
 
-      delete "/u/#{user.username}/preferences/email.json", params: { email: other_email.email }
+      expect { delete "/u/#{user.username}/preferences/email.json", params: { email: other_email.email } }
+        .to change { UserHistory.where(action: UserHistory.actions[:destroy_email], acting_user_id: user.id).count }.by(1)
       expect(response.status).to eq(200)
       expect(user.reload.user_emails.pluck(:email)).to contain_exactly(user_email.email)
     end

GitHub sha: 7ed7b1ef

This commit appears in #10064 which was approved by ZogStriP. It was merged by udan11.