Remove pagination from json format of contacts#index; add explanatory comments. I KNOW. But it's super confusing and I can't find a way to rewrite the code to be more clear. Soloing FTL.
This commit is contained in:
parent
03e3d8e993
commit
0e0d40d00e
2 changed files with 11 additions and 7 deletions
|
|
@ -8,13 +8,16 @@ class ContactsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
|
# Used for normal requests to contacts#index and subsequent infinite scroll calls
|
||||||
format.html { set_up_contacts }
|
format.html { set_up_contacts }
|
||||||
|
|
||||||
|
# Used by the mobile site
|
||||||
format.mobile { set_up_contacts }
|
format.mobile { set_up_contacts }
|
||||||
|
|
||||||
|
# Used to populate mentions in the publisher
|
||||||
format.json {
|
format.json {
|
||||||
aspect_ids = params[:aspect_ids] || current_user.aspects.map(&:id)
|
aspect_ids = params[:aspect_ids] || current_user.aspects.map(&:id)
|
||||||
@people = Person.all_from_aspects(aspect_ids, current_user).for_json.paginate(:page => params[:page], :per_page => 25)
|
@people = Person.all_from_aspects(aspect_ids, current_user).for_json
|
||||||
render :json => @people.to_json
|
render :json => @people.to_json
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,13 @@ describe ContactsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
context 'format mobile' do
|
||||||
|
it "succeeds" do
|
||||||
|
get :index, :format => 'mobile'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'format html' do
|
context 'format html' do
|
||||||
it "succeeds" do
|
it "succeeds" do
|
||||||
get :index
|
get :index
|
||||||
|
|
@ -60,12 +67,6 @@ describe ContactsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'format json' do
|
context 'format json' do
|
||||||
it 'respects pagination' do
|
|
||||||
get :index, :format => 'json', :page => '2'
|
|
||||||
assigns[:people].should == []
|
|
||||||
response.should be_success
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'assumes all aspects if none are specified' do
|
it 'assumes all aspects if none are specified' do
|
||||||
get :index, :format => 'json'
|
get :index, :format => 'json'
|
||||||
assigns[:people].map(&:id).should =~ bob.contacts.map { |c| c.person.id }
|
assigns[:people].map(&:id).should =~ bob.contacts.map { |c| c.person.id }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue