end
end
end
- describe 'list関連テーブルプションに於いて' do
+ describe '一覧取得オプションに於いて' do
it 'includeキーを含んでいる' do
r = Comic.list_opt
r.has_key?(:include).should be_true
end
end
describe 'json一覧出力オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Comic.list_json_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = Comic.list_json_opt[:include]
- r.should have(2).items
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @sbt = FactoryGirl.create :speech_balloon_template\r
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
end
it 'ストーリーを含んでいる' do
- r = Comic.list_json_opt[:include]
- r.has_key?(:stories).should be_true
+ r = Comic.list.to_json Comic.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('stories').should be_true
end
it 'ストーリーはコマを含んでいる' do
- r = Comic.list_json_opt[:include]
- r[:stories].has_key?(:panel).should be_true
+ r = Comic.list.to_json Comic.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['stories'].first
+ s.has_key?('panel').should be_true
end
it '作家を含んでいる' do
- r = Comic.list_json_opt[:include]
- r.has_key?(:author).should be_true
+ r = Comic.list.to_json Comic.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('author').should be_true
end
end
end
end
end
- describe '関連テーブルプションに於いて' do
+ describe '単体取得オプションに於いて' do
it 'includeキーを含んでいる' do
r = Comic.show_opt
r.has_key?(:include).should be_true
end
end
describe 'json単体出力オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Comic.show_json_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = Comic.show_json_opt[:include]
- r.should have(2).items
- end
- it '作家を含んでいる' do
- r = Comic.show_json_opt[:include]
- r.has_key?(:author).should be_true
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
+ @sbt = FactoryGirl.create :speech_balloon_template\r
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
end
it 'ストーリーを含んでいる' do
- r = Comic.show_json_opt[:include]
- r.has_key?(:stories).should be_true
+ r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt
+ j = JSON.parse r
+ i = j
+ i.has_key?('stories').should be_true
end
it 'ストーリーはコマを含んでいる' do
- r = Comic.show_json_opt[:include]
- r[:stories].has_key?(:panel).should be_true
+ r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt
+ j = JSON.parse r
+ i = j
+ s = i['stories'].first
+ s.has_key?('panel').should be_true
end
+ it '作家を含んでいる' do
+ r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt
+ j = JSON.parse r
+ i = j
+ i.has_key?('author').should be_true
+ end
end
end