Revert "FIX: Undefined method when serializing a user"

Revert “FIX: Undefined method when serializing a user”

This reverts commit 1fbe078ae074f29395d79db0856d1991f1675ab5.

UserProfile is created in a callback after the user has been created. As such, it should be impossible for a user to not have a blank UserProfile. This was also improved in 4f5c9bb8d31c47aee7acef34390bafffd88a2d47.

diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb
index 6b294c3..a093c83 100644
--- a/app/serializers/user_serializer.rb
+++ b/app/serializers/user_serializer.rb
@@ -220,15 +220,15 @@ class UserSerializer < BasicUserSerializer
   end
 
   def bio_raw
-    object.user_profile&.bio_raw
+    object.user_profile.bio_raw
   end
 
   def bio_cooked
-    object.user_profile&.bio_processed
+    object.user_profile.bio_processed
   end
 
   def website
-    object.user_profile&.website
+    object.user_profile.website
   end
 
   def website_name
@@ -246,7 +246,7 @@ class UserSerializer < BasicUserSerializer
   end
 
   def location
-    object.user_profile&.location
+    object.user_profile.location
   end
 
   def can_edit
@@ -300,7 +300,7 @@ class UserSerializer < BasicUserSerializer
   end
 
   def bio_excerpt
-    object.user_profile&.bio_excerpt(350 , keep_newlines: true, keep_emoji_images: true)
+    object.user_profile.bio_excerpt(350 , keep_newlines: true, keep_emoji_images: true)
   end
 
   def include_suspend_reason?
@@ -470,7 +470,7 @@ class UserSerializer < BasicUserSerializer
   end
 
   def profile_view_count
-    object.user_profile&.views
+    object.user_profile.views
   end
 
   def time_read
diff --git a/spec/serializers/user_serializer_spec.rb b/spec/serializers/user_serializer_spec.rb
index a02d4e9..7f896a2 100644
--- a/spec/serializers/user_serializer_spec.rb
+++ b/spec/serializers/user_serializer_spec.rb
@@ -250,17 +250,4 @@ describe UserSerializer do
       expect(json[:user_api_keys][2][:id]).to eq(user_api_key_2.id)
     end
   end
-
-  context "with missing user profile" do
-    fab!(:user) { Fabricate(:user) }
-
-    it "does not throw an error" do
-      id = user.id
-      UserProfile.delete(id)
-      user_b = User.find(id)
-      json = UserSerializer.new(user_b, scope: Guardian.new(user_b), root: false).as_json
-
-      expect(json[:bio_raw]).to eq nil
-    end
-  end
 end

GitHub sha: 55fd3ace