replace deprecated usages for all

This commit is contained in:
Jonne Haß 2013-08-31 18:36:36 +02:00
parent cc8a614c29
commit 09f0665225
8 changed files with 18 additions and 20 deletions

View file

@ -70,12 +70,12 @@ class AspectsController < ApplicationController
def edit def edit
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => {:person => :profile}).first @aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => {:person => :profile}).first
@contacts_in_aspect = @aspect.contacts.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } @contacts_in_aspect = @aspect.contacts.includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name }
c = Contact.arel_table c = Contact.arel_table
if @contacts_in_aspect.empty? if @contacts_in_aspect.empty?
@contacts_not_in_aspect = current_user.contacts.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } @contacts_not_in_aspect = current_user.contacts.includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name }
else else
@contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } @contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name }
end end
@contacts = @contacts_in_aspect + @contacts_not_in_aspect @contacts = @contacts_in_aspect + @contacts_not_in_aspect

View file

@ -36,7 +36,7 @@ class Conversation < ActiveRecord::Base
def first_unread_message(user) def first_unread_message(user)
if visibility = self.conversation_visibilities.where(:person_id => user.person.id).where('unread > 0').first if visibility = self.conversation_visibilities.where(:person_id => user.person.id).where('unread > 0').first
self.messages.all[-visibility.unread] self.messages.to_a[-visibility.unread]
end end
end end

View file

@ -256,7 +256,7 @@ class User < ActiveRecord::Base
if aspect_ids == "all" || aspect_ids == :all if aspect_ids == "all" || aspect_ids == :all
self.aspects self.aspects
else else
aspects.where(:id => aspect_ids) aspects.where(:id => aspect_ids).to_a
end end
end end

View file

@ -42,8 +42,6 @@ module User::Connecting
end end
def remove_contact(contact, opts={:force => false, :retracted => false}) def remove_contact(contact, opts={:force => false, :retracted => false})
posts = contact.posts.all
if !contact.mutual? || opts[:force] if !contact.mutual? || opts[:force]
contact.destroy contact.destroy
elsif opts[:retracted] elsif opts[:retracted]

View file

@ -99,7 +99,7 @@ class PostInteractionPresenter
end end
def as_api(collection) def as_api(collection)
collection.includes(:author => :profile).all.map do |element| collection.includes(:author => :profile).map do |element|
element.as_api_response(:backbone) element.as_api_response(:backbone)
end end
end end

View file

@ -115,7 +115,7 @@ class Stream::Base
# #
# @return [Array<Contact>] # @return [Array<Contact>]
def contacts_in_stream def contacts_in_stream
@contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map{|x| x.id}).all @contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map(&:id)).load
end end
# @param post [Post] # @param post [Post]

View file

@ -23,8 +23,8 @@ describe 'deleteing your account' do
create_conversation_with_message(alice, @bob2.person, "Subject", "Hey @bob2") create_conversation_with_message(alice, @bob2.person, "Subject", "Hey @bob2")
#join tables #join tables
@users_sv = ShareVisibility.where(:contact_id => @bobs_contact_ids).all @users_sv = ShareVisibility.where(:contact_id => @bobs_contact_ids).load
@persons_sv = ShareVisibility.where(:contact_id => bob.person.contacts.map(&:id)).all @persons_sv = ShareVisibility.where(:contact_id => bob.person.contacts.map(&:id)).load
#user associated objects #user associated objects
@prefs = [] @prefs = []

View file

@ -39,17 +39,17 @@ describe ShareVisibility do
end end
it 'searches for share visibilies for all users contacts' do it 'searches for share visibilies for all users contacts' do
contact_ids = alice.contacts.map{|c| c.id} contact_ids = alice.contacts.map(&:id)
ShareVisibility.for_a_users_contacts(alice).should == ShareVisibility.where(:contact_id => contact_ids).all ShareVisibility.for_a_users_contacts(alice).should == ShareVisibility.where(:contact_id => contact_ids).to_a
end end
end end
describe '.for_contacts_of_a_person' do describe '.for_contacts_of_a_person' do
it 'searches for share visibilties generated by a person' do it 'searches for share visibilties generated by a person' do
contact_ids = alice.person.contacts.map{|c| c.id} contact_ids = alice.person.contacts.map(&:id)
ShareVisibility.for_contacts_of_a_person(alice.person) == ShareVisibility.where(:contact_id => contact_ids).all ShareVisibility.for_contacts_of_a_person(alice.person) == ShareVisibility.where(:contact_id => contact_ids).to_a
end end
end end