]> git.openstreetmap.org Git - rails.git/commitdiff
Rename user.friend_users to user.friends
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 19 Jun 2019 14:51:35 +0000 (16:51 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 19 Jun 2019 14:51:35 +0000 (16:51 +0200)
This is possible now since we've renamed Friend to Friendship

app/controllers/changesets_controller.rb
app/controllers/diary_entries_controller.rb
app/models/user.rb
app/views/users/show.html.erb
test/controllers/changesets_controller_test.rb
test/models/user_test.rb

index 3b20130d00829eb29a4ae71e1aa3b8f011c23281..82966a353437d1d0a0837b527d1583c9798f11ca 100644 (file)
@@ -53,7 +53,7 @@ class ChangesetsController < ApplicationController
       elsif @params[:bbox]
         changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
       elsif @params[:friends] && current_user
-        changesets = changesets.where(:user_id => current_user.friend_users.identifiable)
+        changesets = changesets.where(:user_id => current_user.friends.identifiable)
       elsif @params[:nearby] && current_user
         changesets = changesets.where(:user_id => current_user.nearby)
       end
index f827bac3f165a00d1f94313975c291fbcf329979..d4a32efb212c8b9cfbf45e0b88a5ae0b80276fa6 100644 (file)
@@ -129,7 +129,7 @@ class DiaryEntriesController < ApplicationController
     elsif params[:friends]
       if current_user
         @title = t "diary_entries.index.title_friends"
-        @entries = DiaryEntry.where(:user_id => current_user.friend_users)
+        @entries = DiaryEntry.where(:user_id => current_user.friends)
       else
         require_user
         return
index 36c98ed3eb10d133a94a951e8ed2a8f240bb56fb..284efe34e17e55fc5be657ffbd1e4b5362d82308 100644 (file)
@@ -58,7 +58,7 @@ class User < ActiveRecord::Base
   has_many :new_messages, -> { where(:to_user_visible => true, :message_read => false).order(:sent_on => :desc) }, :class_name => "Message", :foreign_key => :to_user_id
   has_many :sent_messages, -> { where(:from_user_visible => true).order(:sent_on => :desc).preload(:sender, :recipient) }, :class_name => "Message", :foreign_key => :from_user_id
   has_many :friendships, -> { joins(:befriendee).where(:users => { :status => %w[active confirmed] }) }
-  has_many :friend_users, :through => :friendships, :source => :befriendee
+  has_many :friends, :through => :friendships, :source => :befriendee
   has_many :tokens, :class_name => "UserToken"
   has_many :preferences, :class_name => "UserPreference"
   has_many :changesets, -> { order(:created_at => :desc) }
index b9266c836f08f9184b01f71fe2e4349cfde709f0..aee000a97b001571d78f45603082afbd08443f7d 100644 (file)
       <%= content_tag "div", "", :id => "map", :class => "content_map", :data => { :user => user_data } %>
     <% end %>
 
-    <% friends = @user.friend_users %>
+    <% friends = @user.friends %>
     <% nearby = @user.nearby - friends %>
 
   <div class="activity-block column-1">
index 4501997b77f7a9219fcefafca487ed6f5d61dc1e..caf7721cd4ab425e483e7720f9147fc62cc41450 100644 (file)
@@ -147,7 +147,7 @@ class ChangesetsControllerTest < ActionController::TestCase
     assert_response :success
     assert_template "index"
 
-    check_index_result(Changeset.where(:user => private_user.friend_users.identifiable))
+    check_index_result(Changeset.where(:user => private_user.friends.identifiable))
   end
 
   ##
index 42ea9a8740817154019eaa19ca12a882128870a3..96c6632ffcbcac8e9b85aadac8f91d2901d4cea7 100644 (file)
@@ -136,16 +136,16 @@ class UserTest < ActiveSupport::TestCase
     assert_equal [], vagrant_user.nearby
   end
 
-  def test_friend_users
+  def test_friends
     norm = create(:user, :active)
     sec = create(:user, :active)
     create(:friendship, :befriender => norm, :befriendee => sec)
 
-    assert_equal [sec], norm.friend_users
-    assert_equal 1, norm.friend_users.size
+    assert_equal [sec], norm.friends
+    assert_equal 1, norm.friends.size
 
-    assert_equal [], sec.friend_users
-    assert_equal 0, sec.friend_users.size
+    assert_equal [], sec.friends
+    assert_equal 0, sec.friends.size
   end
 
   def test_user_preferred_editor