Rename photos[:count] to photos_count in gon
This commit is contained in:
parent
d8687ccb3a
commit
15e0f88758
7 changed files with 15 additions and 21 deletions
|
|
@ -21,8 +21,8 @@ app.pages.Profile = app.views.Base.extend({
|
|||
this._populateModel(opts);
|
||||
}
|
||||
|
||||
if(app.hasPreload("photos")){
|
||||
this.photos = app.parsePreload("photos");
|
||||
if (app.hasPreload("photos_count")) {
|
||||
this.photos = app.parsePreload("photos_count");
|
||||
}
|
||||
if (app.hasPreload("contacts_count")) {
|
||||
this.contacts = app.parsePreload("contacts_count");
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ app.views.ProfileHeader = app.views.Base.extend({
|
|||
},
|
||||
|
||||
_shouldShowPhotos: function() {
|
||||
return (this.photos && this.photos.count > 0);
|
||||
return (this.photos && this.photos > 0);
|
||||
},
|
||||
|
||||
_shouldShowContacts: function() {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@
|
|||
<a href="{{urlTo 'personPhotos' guid}}" id="photos_link">
|
||||
<i class="entypo-picture"></i>
|
||||
{{t 'profile.photos'}}
|
||||
<div class="badge badge-default">{{photos.count}}</div>
|
||||
<div class="badge badge-default">{{photos}}</div>
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -75,9 +75,7 @@ class PeopleController < ApplicationController
|
|||
@contact = current_user.contact_for(@person)
|
||||
end
|
||||
gon.preloads[:person] = @person_json
|
||||
gon.preloads[:photos] = {
|
||||
count: Photo.visible(current_user, @person).count(:all)
|
||||
}
|
||||
gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all)
|
||||
gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all)
|
||||
respond_with @person, layout: "with_header"
|
||||
end
|
||||
|
|
@ -135,9 +133,7 @@ class PeopleController < ApplicationController
|
|||
@contact = current_user.contact_for(@person)
|
||||
@contacts_of_contact = Contact.contact_contacts_for(current_user, @person)
|
||||
gon.preloads[:person] = PersonPresenter.new(@person, current_user).as_json
|
||||
gon.preloads[:photos] = {
|
||||
count: Photo.visible(current_user, @person).count(:all)
|
||||
}
|
||||
gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all)
|
||||
gon.preloads[:contacts_count] = @contacts_of_contact.count(:all)
|
||||
@contacts_of_contact = @contacts_of_contact.paginate(page: params[:page], per_page: (params[:limit] || 15))
|
||||
@hashes = hashes_for_people @contacts_of_contact, @aspects
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ class PhotosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.all do
|
||||
gon.preloads[:person] = PersonPresenter.new(@person, current_user).as_json
|
||||
gon.preloads[:photos] = {
|
||||
count: Photo.visible(current_user, @person).count(:all)
|
||||
}
|
||||
gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all)
|
||||
gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all)
|
||||
render "people/show", layout: "with_header"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -195,11 +195,11 @@ describe PeopleController, :type => :controller do
|
|||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
|
||||
end
|
||||
get :show, :id => eve.person.to_param
|
||||
expect(response.body).to include '"photos":{"count":16}'
|
||||
expect(response.body).to include ',"photos_count":16'
|
||||
|
||||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
|
||||
get :show, :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
|
||||
|
||||
context "when the person is the current user" do
|
||||
|
|
@ -491,11 +491,11 @@ describe PeopleController, :type => :controller do
|
|||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
|
||||
end
|
||||
get :contacts, :person_id => eve.person.to_param
|
||||
expect(response.body).to include '"photos":{"count":16}'
|
||||
expect(response.body).to include ',"photos_count":16'
|
||||
|
||||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
|
||||
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
|
||||
|
||||
it "returns a 406 for json format" do
|
||||
|
|
|
|||
|
|
@ -109,11 +109,11 @@ describe PhotosController, :type => :controller do
|
|||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true)
|
||||
end
|
||||
get :index, :person_id => eve.person.to_param
|
||||
expect(response.body).to include '"photos":{"count":16}'
|
||||
expect(response.body).to include ',"photos_count":16'
|
||||
|
||||
eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false)
|
||||
get :index, :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
|
||||
|
||||
it "returns json when requested" do
|
||||
|
|
@ -160,11 +160,11 @@ describe PhotosController, :type => :controller do
|
|||
eve.post(:photo, user_file: uploaded_photo, to: eve.aspects.first.id, public: true)
|
||||
end
|
||||
get :index, person_id: eve.person.to_param
|
||||
expect(response.body).to include '"photos":{"count":16}'
|
||||
expect(response.body).to include ',"photos_count":16'
|
||||
|
||||
eve.post(:photo, user_file: uploaded_photo, to: eve.aspects.first.id, public: false)
|
||||
get :index, person_id: eve.person.to_param
|
||||
expect(response.body).to include '"photos":{"count":16}'
|
||||
expect(response.body).to include ',"photos_count":16'
|
||||
end
|
||||
|
||||
it "displays a person's pictures" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue