OSDN Git Service

t#30328:pull porting
[pettanr/pettanr.git] / spec / models / artist_spec.rb
index 31a5a74..6581fd7 100644 (file)
@@ -191,6 +191,11 @@ describe Artist do
       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
@@ -351,4 +356,34 @@ describe Artist do
       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
+  
+  describe 'エクスポートに於いて' do
+    before do
+      @artist = FactoryGirl.create :artist, :author_id => @author.id
+      @artist2 = FactoryGirl.create :artist, :author_id => @other_author.id, :updated_at => Time.now - 3000
+      @artist3 = FactoryGirl.create :artist, :author_id => nil
+    end
+    it '開始日時が省略された場合はすべての内絵師を返す' do
+      r = Artist.export 
+      r.should eq [@artist, @artist2]
+    end
+    it '開始日時以降に更新された内絵師を返す' do
+      r = Artist.export @artist.updated_at - 100
+      r.should eq [@artist]
+    end
+  end
+  
+
 end