From 2169c503efbbeb45c3842e9fa5eef6cc01e8e27b Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 19 Jun 2019 16:51:35 +0200 Subject: [PATCH] Rename user.friend_users to user.friends This is possible now since we've renamed Friend to Friendship --- app/controllers/changesets_controller.rb | 2 +- app/controllers/diary_entries_controller.rb | 2 +- app/models/user.rb | 2 +- app/views/users/show.html.erb | 2 +- test/controllers/changesets_controller_test.rb | 2 +- test/models/user_test.rb | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/changesets_controller.rb b/app/controllers/changesets_controller.rb index 3b20130d0..82966a353 100644 --- a/app/controllers/changesets_controller.rb +++ b/app/controllers/changesets_controller.rb @@ -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 diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index f827bac3f..d4a32efb2 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 36c98ed3e..284efe34e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) } diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b9266c836..aee000a97 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -194,7 +194,7 @@ <%= content_tag "div", "", :id => "map", :class => "content_map", :data => { :user => user_data } %> <% end %> - <% friends = @user.friend_users %> + <% friends = @user.friends %> <% nearby = @user.nearby - friends %>
diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index 4501997b7..caf7721cd 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -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 ## diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 42ea9a874..96c6632ff 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -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 -- 2.39.5