diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 76de92450..5ae782d95 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -24,7 +24,7 @@ class AlbumsController < ApplicationController respond_to :json, :only => [:index, :show] def index - @albums = Album.mine_or_friends(params[:friends], current_user).paginate :page => params[:page], :order => 'created_at DESC' + @albums = current_user.albums_by_aspect(@aspect) respond_with @albums end diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index b185dadcf..7481cc328 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -79,7 +79,7 @@ module Diaspora end def albums_by_aspect aspect - aspect.posts.find_all_by__type("Album") + aspect == :all ? raw_visible_posts.find_all_by__type("Album") : aspect.posts.find_all_by__type("Album") end end end diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index f45b06e99..af024575f 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -77,6 +77,10 @@ describe User do @user.reload end + it 'should find all albums if passed :all' do + @user.albums_by_aspect(:all).size.should == 3 + end + it 'should return the right number of albums' do @user.albums_by_aspect(@aspect).size.should == 2 @user.albums_by_aspect(@aspect2).size.should == 1