Rename user.friend_users to user.friends

This is possible now since we've renamed Friend to Friendship
This commit is contained in:
Andy Allan 2019-06-19 16:51:35 +02:00
parent 1cf8fec58d
commit 2169c503ef
6 changed files with 10 additions and 10 deletions

View 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

View 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

View 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) }

View file

@ -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 %>
<div class="activity-block column-1">

View 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
##

View 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