end
end
+ describe '文字コード検証に於いて' do
+ before do
+ @pp = FactoryGirl.build :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ end
+
+ context 'linkを検証するとき' do
+ it 'Shift JISなら失敗する' do
+ @pp.link = "\x83G\x83r\x83]\x83D"
+ lambda{
+ @pp.valid_encode
+ }.should raise_error(Pettanr::BadRequest)
+ end
+ end
+
+ context 'captionを検証するとき' do
+ it 'Shift JISなら失敗する' do
+ @pp.caption = "\x83G\x83r\x83]\x83D"
+ lambda{
+ @pp.valid_encode
+ }.should raise_error(Pettanr::BadRequest)
+ end
+ end
+ end
+
describe '閲覧許可に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = PanelPicture.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.should have(2).items
- end
- it 'コマを含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- it '実素材を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.has_key?(:picture).should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:picture].has_key?(:artist).should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:picture].has_key?(:license).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- before do
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
- @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
- @sbt = FactoryGirl.create :speech_balloon_template
- @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
- :width => @p.width, :height => @p.height
- end
- it 'コマを含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('panel').should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['panel']
- s.has_key?('author').should be_true
- end
- it '実素材を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('picture').should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['picture']
- s.has_key?('artist').should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['picture']
- s.has_key?('license').should be_true
- end
- end
describe '自分のコマ絵一覧取得に於いて' do
before do
end
end
+ describe '他作家のコマ絵一覧取得に於いて' do
+ before do
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_pp = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ end
+ it 'リストを返す' do
+ r = PanelPicture.himlist @other_author
+ r.should eq [@other_pp]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_pc = FactoryGirl.create :panel_picture, :panel_id => new_panel.id, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ r = PanelPicture.himlist @other_author
+ r.should eq [new_pc, @other_pp]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_pp = FactoryGirl.create :panel_picture, :panel_id => hidden_panel.id, :picture_id => @p.id, :width => @p.width, :height => @p.height
+ r = PanelPicture.himlist @other_author
+ r.should eq [@other_pp]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_pp2 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 1, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ @other_pp3 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 2, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
+ @other_pp4 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 3, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
+ @other_pp5 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 4, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = PanelPicture.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = PanelPicture.himlist @other_author, 1, 2
+ pl.should eq [@other_pp5, @other_pp4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = PanelPicture.himlist @other_author, 2, 2
+ pl.should eq [@other_pp3, @other_pp2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = PanelPicture.himlist @other_author, 3, 2
+ pl.should eq [@other_pp]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_pp2 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 1, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ @other_pp3 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 2, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
+ @other_pp4 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 3, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
+ @other_pp5 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 4, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
+ Author.stub(:default_panel_picture_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = PanelPicture.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = PanelPicture.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '2つの項目を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.should have(2).items
+ end
+ it 'コマを含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.has_key?(:panel).should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:panel].has_key?(:author).should be_true
+ end
+ it '実素材を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.has_key?(:picture).should be_true
+ end
+ it '実素材は絵師を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:picture].has_key?(:artist).should be_true
+ end
+ it '実素材はライセンスを含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:picture].has_key?(:license).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+ @sbt = FactoryGirl.create :speech_balloon_template
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ end
+ it 'コマを含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('panel').should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['panel']
+ s.has_key?('author').should be_true
+ end
+ it '実素材を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('picture').should be_true
+ end
+ it '実素材は絵師を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['picture']
+ s.has_key?('artist').should be_true
+ end
+ it '実素材はライセンスを含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['picture']
+ s.has_key?('license').should be_true
+ end
+ end
+
describe '単体取得に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,