]> git.openstreetmap.org Git - rails.git/commitdiff
Rename friends_with to follows
authorTom Hughes <tom@compton.nu>
Fri, 17 Jan 2025 22:42:35 +0000 (22:42 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 17 Jan 2025 22:58:35 +0000 (22:58 +0000)
app/controllers/follows_controller.rb
app/models/user.rb
app/views/dashboards/_contact.html.erb
app/views/user_mailer/friendship_notification.html.erb
app/views/user_mailer/friendship_notification.text.erb
app/views/users/show.html.erb
test/models/user_test.rb

index d267777c19ed1fc2e66403264bce498c8e1d0d42..09a98f98f92314fbaf892a2049c12660dd1afefc 100644 (file)
@@ -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
index ec3883bc6f0fd9cde8aaf91334eae86af05567b2..92664a76398f53ab6cc7da7b040a8ffe67738d47 100644 (file)
@@ -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
 
   ##
index 4547a2d7514f086a06fe95317d61caf92ebfbdc4..8e78524decb463730cfc2f863151aba6639b8fa1 100644 (file)
@@ -35,7 +35,7 @@
       <ul class='clearfix text-body-secondary'>
         <li><%= link_to t("users.show.send message"), new_message_path(contact) %></li>
         <li>
-          <% if current_user.friends_with?(contact) %>
+          <% if current_user.follows?(contact) %>
             <%= link_to t("users.show.unfollow"), follow_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :delete %>
           <% else %>
             <%= link_to t("users.show.follow"), follow_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
index 16ddcad4916488580057151189c9258cc512bbfc..48b037d57e551aad10d2cd4d737701fc18fc72ed 100644 (file)
@@ -5,7 +5,7 @@
 <%= message_body do %>
   <p><%= t ".see_their_profile_html", :userurl => link_to(@viewurl, @viewurl) %></p>
 
-  <% unless @follow.following.friends_with?(@follow.follower) -%>
+  <% unless @follow.following.follows?(@follow.follower) -%>
   <p><%= t ".follow_them_html", :followurl => link_to(@followurl, @followurl) %></p>
   <% end -%>
 <% end %>
index 624ba92b76825610c8ef41c7c7276d064c0ee6cb..7f9ba202efa10c6f28821328ee1f766d74594fb7 100644 (file)
@@ -4,6 +4,6 @@
 
 <%= t '.see_their_profile', :userurl => @viewurl %>
 
-<% unless @follow.following.friends_with?(@follow.follower) -%>
+<% unless @follow.following.follows?(@follow.follower) -%>
 <%= t '.follow_them', :followurl => @followurl %>
 <% end -%>
index 76bedf60e61af3c4bef491c03601dca0387b4318..b2247c0d01455d59cf68b9843a4bad4d6e9cdcbf 100644 (file)
@@ -83,7 +83,7 @@
             </li>
             <% if current_user %>
               <li>
-                <% if current_user.friends_with?(@user) %>
+                <% if current_user.follows?(@user) %>
                   <%= link_to t(".unfollow"), follow_path(:display_name => @user.display_name), :method => :delete %>
                 <% else %>
                   <%= link_to t(".follow"), follow_path(:display_name => @user.display_name), :method => :post %>
index 3b600fc8787b26a92895af4ac5480c5bde0d3153..5c1c5a26f2a37f2520a10d1f368743c088804681 100644 (file)
@@ -136,18 +136,18 @@ class UserTest < ActiveSupport::TestCase
     assert_predicate user, :valid?, "user_0 display_name is invalid but it hasn't been changed"
   end
 
-  def test_friends_with
+  def test_follows
     alice = create(:user, :active)
     bob = create(:user, :active)
     charlie = create(:user, :active)
     create(:follow, :follower => alice, :following => bob)
 
-    assert alice.friends_with?(bob)
-    assert_not alice.friends_with?(charlie)
-    assert_not bob.friends_with?(alice)
-    assert_not bob.friends_with?(charlie)
-    assert_not charlie.friends_with?(bob)
-    assert_not charlie.friends_with?(alice)
+    assert alice.follows?(bob)
+    assert_not alice.follows?(charlie)
+    assert_not bob.follows?(alice)
+    assert_not bob.follows?(charlie)
+    assert_not charlie.follows?(bob)
+    assert_not charlie.follows?(alice)
   end
 
   def test_users_nearby