@other_user = Factory( :user_yas)
@other_author = @other_user.author
@other_artist = Factory :artist_yas, :author_id => @other_author.id
- @license = Factory :license
+ @sp = Factory :system_picture
+ @lg = Factory :license_group
+ @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
describe '検証に於いて' do
before do
@op = Factory :original_picture, :artist_id => @artist.id
end
- it '指定のコミックを返す' do
- pic = OriginalPicture.show @op.id, @author
+ it '指定の原画を返す' do
+ pic = OriginalPicture.show @op.id, @artist
pic.should eq @op
end
context '関連テーブルオプションがないとき' do
- it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\83\87ã\83¼ã\82¿ã\81 ã\81\91を含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81¨ç´ æ\9d\90を含んでいる' do
r = OriginalPicture.show_include_opt
- r.should eq [:license]
+ r.should eq [:license, :resource_picture]
end
end
context '関連テーブルオプションで絵師を含ませたとき' do
- it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\83\87ã\83¼ã\82¿と作者データを含んでいる' do
+ it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81¨ç´ æ\9d\90と作者データを含んでいる' do
r = OriginalPicture.show_include_opt(:include => :artist)
- r.should eq [:license, :artist]
+ r.should eq [:license, :resource_picture, :artist]
+ end
+ end
+ context '他人の原画を開こうとしたとき' do
+ it '403Forbidden例外を返す' do
+ lambda{
+ pic = OriginalPicture.show @op.id, @other_artist
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ context '存在しない原画を開こうとしたとき' do
+ it '404RecordNotFound例外を返す' do
+ lambda{
+ pic = OriginalPicture.show 0, @artist
+ }.should raise_error(ActiveRecord::RecordNotFound)
end
end
end
+ describe 'json単体出力オプションに於いて' do
+ it 'includeキーがライセンスと素材を含んでいる' do
+ r = OriginalPicture.show_json_include_opt
+ r[:include].should eq [:license, :resource_picture]
+ end
+ end
describe '一覧取得に於いて' do
before do
@op = Factory :original_picture, :artist_id => @artist.id
end
end
end
+ describe 'json一覧出力オプションに於いて' do
+ it 'includeキーがライセンスと素材を含んでいる' do
+ r = OriginalPicture.list_json_opt
+ r[:include].should eq [:license, :resource_picture]
+ end
+ end
describe 'RMagick変換に於いて' do
before do
@op = Factory.build :original_picture, :artist_id => @artist.id