Albums_by_aspect now takes :all

This commit is contained in:
Daniel Vincent Grippi 2010-09-13 17:32:29 -07:00
parent 1b92bcd17c
commit b2b60af8aa
3 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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