Return 406 on people/guid/contacts, format json
This commit is contained in:
parent
4b841ef076
commit
a6b9c6c057
2 changed files with 28 additions and 17 deletions
|
|
@ -135,24 +135,30 @@ class PeopleController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts
|
def contacts
|
||||||
@person = Person.find_by_guid(params[:person_id])
|
respond_to do |format|
|
||||||
|
format.json { render nothing: true, status: 406 }
|
||||||
|
|
||||||
if @person
|
format.any do
|
||||||
@contact = current_user.contact_for(@person)
|
@person = Person.find_by_guid(params[:person_id])
|
||||||
@contacts_of_contact = Contact.contact_contacts_for(current_user, @person)
|
|
||||||
gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile
|
if @person
|
||||||
gon.preloads[:photos] = {
|
@contact = current_user.contact_for(@person)
|
||||||
count: photos_from(@person, :all).count(:all)
|
@contacts_of_contact = Contact.contact_contacts_for(current_user, @person)
|
||||||
}
|
gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile
|
||||||
gon.preloads[:contacts] = {
|
gon.preloads[:photos] = {
|
||||||
count: @contacts_of_contact.count(:all),
|
count: photos_from(@person, :all).count(:all)
|
||||||
}
|
}
|
||||||
@contacts_of_contact = @contacts_of_contact.paginate(:page => params[:page], :per_page => (params[:limit] || 15))
|
gon.preloads[:contacts] = {
|
||||||
@hashes = hashes_for_people @contacts_of_contact, @aspects
|
count: @contacts_of_contact.count(:all),
|
||||||
respond_with @person, layout: "with_header"
|
}
|
||||||
else
|
@contacts_of_contact = @contacts_of_contact.paginate(page: params[:page], per_page: (params[:limit] || 15))
|
||||||
flash[:error] = I18n.t 'people.show.does_not_exist'
|
@hashes = hashes_for_people @contacts_of_contact, @aspects
|
||||||
redirect_to people_path
|
respond_with @person, layout: "with_header"
|
||||||
|
else
|
||||||
|
flash[:error] = I18n.t "people.show.does_not_exist"
|
||||||
|
redirect_to people_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -497,6 +497,11 @@ describe PeopleController, :type => :controller do
|
||||||
get :contacts, :person_id => eve.person.to_param
|
get :contacts, :person_id => eve.person.to_param
|
||||||
expect(response.body).to include '"photos":{"count":16}' # eve is not sharing with alice
|
expect(response.body).to include '"photos":{"count":16}' # eve is not sharing with alice
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns a 406 for json format" do
|
||||||
|
get :contacts, person_id: "foo", format: :json
|
||||||
|
expect(response.code).to eq("406")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#diaspora_id?' do
|
describe '#diaspora_id?' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue