opt = {}
opt.merge!(Artist.list_opt)
opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
- opt.merge!({:order => 'created_at desc'})
+ opt.merge!({:conditions => ['artists.author_id is not null'], :order => 'artists.created_at desc'})
Artist.find(:all, opt)
end
end
def self.visible_count
- Artist.count
+ Artist.count :conditions => ['artists.author_id is not null']
end
end
l = Artist.list
l.should eq [n, @artist]
end
+ it 'ただし、内絵師(作家idが空)だけとする' do
+ n = FactoryGirl.create :artist, :author_id => nil
+ l = Artist.list
+ l.should eq [@artist]
+ end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
@artist2 = FactoryGirl.create :artist, :author_id => @author.id, :name => 'artist2', :created_at => Time.now + 100
i.has_key?('author').should be_true
end
end
+
+ describe '有効絵師数に於いて' do
+ before do
+ @artist = FactoryGirl.create :artist, :author_id => @author.id
+ @artist = FactoryGirl.create :artist, :author_id => @other_author.id
+ @artist = FactoryGirl.create :artist, :author_id => nil
+ end
+ it '内絵師数を返す' do
+ r = Artist.visible_count
+ r.should eq 2
+ end
+ end
+
end