From bc630bca87e81150b71fe02c5af838365db5130e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 17 Jan 2025 22:42:35 +0000 Subject: [PATCH] Rename friends_with to follows --- app/controllers/follows_controller.rb | 6 +++--- app/models/user.rb | 4 ++-- app/views/dashboards/_contact.html.erb | 2 +- .../user_mailer/friendship_notification.html.erb | 2 +- .../user_mailer/friendship_notification.text.erb | 2 +- app/views/users/show.html.erb | 2 +- test/models/user_test.rb | 14 +++++++------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index d267777c1..09a98f98f 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -13,14 +13,14 @@ class FollowsController < ApplicationController before_action :lookup_friend def show - @already_follows = current_user.friends_with?(@friend) + @already_follows = current_user.follows?(@friend) end def create follow = Follow.new follow.follower = current_user follow.following = @friend - if current_user.friends_with?(@friend) + if current_user.follows?(@friend) flash[:warning] = t ".already_followed", :name => @friend.display_name elsif current_user.follows.where(:created_at => Time.now.utc - 1.hour..).count >= current_user.max_friends_per_hour flash[:error] = t ".limit_exceeded" @@ -37,7 +37,7 @@ class FollowsController < ApplicationController end def destroy - if current_user.friends_with?(@friend) + if current_user.follows?(@friend) Follow.where(:follower => current_user, :following => @friend).delete_all flash[:notice] = t ".success", :name => @friend.display_name else diff --git a/app/models/user.rb b/app/models/user.rb index ec3883bc6..92664a763 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -282,8 +282,8 @@ class User < ApplicationRecord OSM::GreatCircle.new(home_lat, home_lon).distance(nearby_user.home_lat, nearby_user.home_lon) end - def friends_with?(new_friend) - follows.exists?(:following => new_friend) + def follows?(user) + follows.exists?(:following => user) end ## diff --git a/app/views/dashboards/_contact.html.erb b/app/views/dashboards/_contact.html.erb index 4547a2d75..8e78524de 100644 --- a/app/views/dashboards/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -35,7 +35,7 @@