end
end
+ describe '文字コード検証に於いて' do
+ before do
+ @artist = FactoryGirl.build :artist, :author_id => @author.id
+ end
+
+ context 'nameを検証するとき' do
+ it 'Shift JISなら失敗する' do
+ @artist.name = "\x83G\x83r\x83]\x83D"
+ lambda{
+ @artist.valid_encode
+ }.should raise_error(Pettanr::BadRequest)
+ end
+ end
+
+ end
+
describe 'デフォルト値補充に於いて' do
it '名前がno nameになっている' do
@artist = FactoryGirl.build :artist, :name => nil
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
+
+ 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