diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 4692d8f370416e5a1e4ccdfddf46f016a0c0aba3..18203d8c9785c031e8f7b4cf416931a58031da28 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -31,7 +31,7 @@ class PhotosController < ApplicationController @contact = Contact.new end - @posts = current_user.photos_from(@person) + @posts = current_user.photos_from(@person, max_time: max_time) respond_to do |format| format.all { render 'people/show' } diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index 4f53e03517bb02b72931228f54e5fd76fb04076f..878d80d4f96cf2ae062d0791cedd0ab076de4b5c 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -133,8 +133,11 @@ module User::Querying ::EvilQuery::ShareablesFromPerson.new(self, Post, person).make_relation! end - def photos_from(person) + def photos_from(person, opts={}) + opts = prep_opts(Photo, opts) ::EvilQuery::ShareablesFromPerson.new(self, Photo, person).make_relation! + .by_max_time(opts[:max_time]) + .limit(opts[:limit]) end protected diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index a3eb76f04007bab95155ab7b16f4f59dbd51cac1..40d02acc3c91f0dc72800e6919cd55e606c9a634 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -101,6 +101,14 @@ describe PhotosController do response.headers['Content-Type'].should match 'application/json.*' save_fixture(response.body, "photos_json") end + + it 'displays by date of creation' do + max_time = bob.photos.first.created_at - 1.day + get :index, person_id: bob.person.guid.to_s, + max_time: max_time.to_i + + assigns[:posts].should be_empty + end end describe '#edit' do