Fix aspect edit page
This commit is contained in:
parent
6eb0dfb43f
commit
6410355d71
2 changed files with 12 additions and 5 deletions
|
|
@ -28,8 +28,7 @@ class AspectsController < ApplicationController
|
|||
:page => params[:page], :per_page => 15, :order => 'created_at DESC')
|
||||
@post_hashes = hashes_for_posts @posts
|
||||
|
||||
@contacts = Contact.joins(:aspect_memberships).where(
|
||||
:aspect_memberships => {:aspect_id => @aspect_ids}, :user_id => current_user.id, :pending => false)
|
||||
@contacts = current_user.contacts.includes(:person).where(:pending => false)
|
||||
@contact_hashes = hashes_for_contacts @contacts
|
||||
@aspect_hashes = hashes_for_aspects @aspects, @contacts, :limit => 16
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ class AspectsController < ApplicationController
|
|||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@aspect_ids = [@aspect.id]
|
||||
@aspect_contacts = hashes_for_contacts Contact.all(:user_id => current_user.id, :aspect_ids.in => [@aspect.id], :pending => false)
|
||||
@aspect_contacts = hashes_for_contacts @aspect.contacts.where(:pending => false).all
|
||||
@aspect_contacts_count = @aspect_contacts.count
|
||||
|
||||
@all_contacts = hashes_for_contacts @contacts
|
||||
|
|
|
|||
|
|
@ -227,16 +227,21 @@ describe AspectsController do
|
|||
end
|
||||
describe "#hashes_for_aspects" do
|
||||
before do
|
||||
@aspect1 = @user.aspects.create(:name => "SecondAspect")
|
||||
@people = []
|
||||
10.times {@people << Factory.create(:person)}
|
||||
@people.each{|p| @user.reload.activate_contact(p, @user.aspects.first.reload)}
|
||||
|
||||
@people.each do |p|
|
||||
@user.reload.activate_contact(p, @user.aspects.first.reload)
|
||||
@user.add_contact_to_aspect(@user.contact_for(p), @aspect1)
|
||||
end
|
||||
@user.reload
|
||||
@hashes = @controller.send(:hashes_for_aspects, @user.aspects, @user.contacts, :limit => 9)
|
||||
@hash = @hashes.first
|
||||
@aspect0 = @user.aspects.first
|
||||
end
|
||||
it 'has aspects' do
|
||||
@hashes.length.should == 2
|
||||
@hashes.length.should == @user.aspects.count
|
||||
@hash[:aspect].should == @aspect0
|
||||
end
|
||||
it 'has a contact_count' do
|
||||
|
|
@ -255,6 +260,9 @@ describe AspectsController do
|
|||
it 'has a contact in each hash' do
|
||||
@aspect0.contacts.include?(@hash[:contacts].first[:contact]).should be_true
|
||||
end
|
||||
it 'does not retreive duplicate contacts' do
|
||||
@hash[:contacts].uniq.count.should == @hash[:contacts].count
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue