From: yasushiito Date: Fri, 28 Sep 2012 23:53:59 +0000 (+0900) Subject: t#29620:json output include child X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e994abdaf74bc9d7c62d28f4e5a2caaffbc2fb48;p=pettanr%2Fpettanr.git t#29620:json output include child --- diff --git a/app/models/artist.rb b/app/models/artist.rb index 63a1f20f..56ae09ae 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -67,11 +67,11 @@ class Artist < ActiveRecord::Base end def self.list_opt - {:include => {:author => {}, :original_pictures => {}, :pictures => {}, :resource_pictures => {}} } + {:include => {:author => {}} } end def self.list_json_opt - {:include => {:author => {}, :original_pictures => {}, :pictures => {}, :resource_pictures => {}} } + {:include => {:author => {}} } end def self.show aid, au @@ -91,11 +91,11 @@ class Artist < ActiveRecord::Base end def self.show_opt - {:include => {:author => {}, :original_pictures => {}, :pictures => {}, :resource_pictures => {}} } + {:include => {:author => {}} } end def self.show_json_opt - {:include => {:author => {}, :original_pictures => {}, :pictures => {}, :resource_pictures => {}} } + {:include => {:author => {}} } end def self.visible_count diff --git a/app/models/comic.rb b/app/models/comic.rb index 107c0946..56b593a1 100644 --- a/app/models/comic.rb +++ b/app/models/comic.rb @@ -70,7 +70,7 @@ class Comic < ActiveRecord::Base end def self.list_json_opt - {:include => {:stories => {:panel => {}}, :author => {}}} + {:include => {:stories => {:include => {:panel => {}}}, :author => {}}} end def self.mylist au, page = 1, page_size = Author.default_comic_page_size @@ -102,7 +102,7 @@ class Comic < ActiveRecord::Base end def self.show_json_opt - {:include => {:stories => {:panel => {}}, :author => {}}} + {:include => {:stories => {:include => {:panel => {}}}, :author => {}}} end def self.visible_count diff --git a/app/models/ground_color.rb b/app/models/ground_color.rb index 95568a3e..e2fe8469 100644 --- a/app/models/ground_color.rb +++ b/app/models/ground_color.rb @@ -46,7 +46,7 @@ class GroundColor < ActiveRecord::Base end def self.list_json_opt - {:include => {:panel => {:author => {}}, :color => {} }} + {:include => {:panel => {:include => {:author => {}}}, :color => {} }} end def self.mylist au, page = 1, page_size = Author.default_ground_color_page_size diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index c98e9dd3..ebb59596 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -46,7 +46,7 @@ class GroundPicture < ActiveRecord::Base end def self.list_json_opt - {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}} + {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }} end def self.mylist au, page = 1, page_size = Author.default_ground_picture_page_size diff --git a/app/models/panel_color.rb b/app/models/panel_color.rb index deb29312..f97eb554 100644 --- a/app/models/panel_color.rb +++ b/app/models/panel_color.rb @@ -45,7 +45,7 @@ class PanelColor < ActiveRecord::Base end def self.list_json_opt - {:include => {:panel => {:author => {}} }} + {:include => {:panel => {:include => {:author => {}}} }} end def self.mylist au, page = 1, page_size = Author.default_panel_color_page_size diff --git a/app/models/panel_picture.rb b/app/models/panel_picture.rb index 772f9a09..013ae964 100644 --- a/app/models/panel_picture.rb +++ b/app/models/panel_picture.rb @@ -60,7 +60,7 @@ class PanelPicture < ActiveRecord::Base end def self.list_json_opt - {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}} + {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }} end def self.mylist au, page = 1, page_size = Author.default_panel_picture_page_size diff --git a/spec/models/artist_spec.rb b/spec/models/artist_spec.rb index 815edbc4..3bfff22a 100644 --- a/spec/models/artist_spec.rb +++ b/spec/models/artist_spec.rb @@ -185,51 +185,24 @@ describe Artist do r = Artist.list_opt r.has_key?(:include).should be_true end - it '4つの項目を含んでいる' do + it '1つの項目を含んでいる' do r = Artist.list_opt[:include] - r.should have(4).items + r.should have(1).items end it '作家を含んでいる' do r = Artist.list_opt[:include] r.has_key?(:author).should be_true end - it '原画を含んでいる' do - r = Artist.list_opt[:include] - r.has_key?(:original_pictures).should be_true - end - it '実素材を含んでいる' do - r = Artist.list_opt[:include] - r.has_key?(:pictures).should be_true - end - it '素材を含んでいる' do - r = Artist.list_opt[:include] - r.has_key?(:resource_pictures).should be_true - end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = Artist.list_json_opt - r.has_key?(:include).should be_true - end - it '4つの項目を含んでいる' do - r = Artist.list_json_opt[:include] - r.should have(4).items + before do + @artist = FactoryGirl.create :artist, :author_id => @author.id end it '作家を含んでいる' do - r = Artist.list_json_opt[:include] - r.has_key?(:author).should be_true - end - it '原画を含んでいる' do - r = Artist.list_json_opt[:include] - r.has_key?(:original_pictures).should be_true - end - it '実素材を含んでいる' do - r = Artist.list_json_opt[:include] - r.has_key?(:pictures).should be_true - end - it '素材を含んでいる' do - r = Artist.list_json_opt[:include] - r.has_key?(:resource_pictures).should be_true + r = Artist.list.to_json Artist.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('author').should be_true end end @@ -311,51 +284,20 @@ describe Artist do r = Artist.show_opt r.has_key?(:include).should be_true end - it '4つの項目を含んでいる' do - r = Artist.show_opt[:include] - r.should have(4).items - end - it '作家を含んでいる' do + it '1つの項目を含んでいる' do r = Artist.show_opt[:include] - r.has_key?(:author).should be_true - end - it '原画を含んでいる' do - r = Artist.show_opt[:include] - r.has_key?(:original_pictures).should be_true - end - it '実素材を含んでいる' do - r = Artist.show_opt[:include] - r.has_key?(:pictures).should be_true - end - it '素材を含んでいる' do - r = Artist.show_opt[:include] - r.has_key?(:resource_pictures).should be_true + r.should have(1).items end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = Artist.show_json_opt - r.has_key?(:include).should be_true - end - it '4つの項目を含んでいる' do - r = Artist.show_json_opt[:include] - r.should have(4).items + before do + @artist = FactoryGirl.create :artist, :author_id => @author.id end it '作家を含んでいる' do - r = Artist.show_json_opt[:include] - r.has_key?(:author).should be_true - end - it '原画を含んでいる' do - r = Artist.show_json_opt[:include] - r.has_key?(:original_pictures).should be_true - end - it '実素材を含んでいる' do - r = Artist.show_json_opt[:include] - r.has_key?(:pictures).should be_true - end - it '素材を含んでいる' do - r = Artist.show_json_opt[:include] - r.has_key?(:resource_pictures).should be_true + r = Artist.show(@artist.id, @author).to_json Artist.show_json_opt + j = JSON.parse r + i = j + i.has_key?('author').should be_true end end end diff --git a/spec/models/author_spec.rb b/spec/models/author_spec.rb index 981102c1..3444f9a6 100644 --- a/spec/models/author_spec.rb +++ b/spec/models/author_spec.rb @@ -228,17 +228,14 @@ describe Author do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = Author.list_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = Author.list_json_opt[:include] - r.should have(1).items + before do + @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end it '絵師を含んでいる' do - r = Author.list_json_opt[:include] - r.has_key?(:artist).should be_true + r = Author.list.to_json Author.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('artist').should be_true end end @@ -328,17 +325,14 @@ describe Author do end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = Author.show_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = Author.show_json_opt[:include] - r.should have(1).items + before do + @artist = FactoryGirl.create :artist_yas, :author_id => @author.id end it '絵師を含んでいる' do - r = Author.show_json_opt[:include] - r.has_key?(:artist).should be_true + r = Author.show(@author.id, @author).to_json Author.show_json_opt + j = JSON.parse r + i = j + i.has_key?('artist').should be_true end end diff --git a/spec/models/comic_spec.rb b/spec/models/comic_spec.rb index f83e83fc..adf62c5a 100644 --- a/spec/models/comic_spec.rb +++ b/spec/models/comic_spec.rb @@ -212,7 +212,7 @@ describe Comic do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = Comic.list_opt r.has_key?(:include).should be_true @@ -235,25 +235,33 @@ describe Comic do 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 + @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 + @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 @@ -401,7 +409,7 @@ describe Comic do end end end - describe '関連テーブルプションに於いて' do + describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do r = Comic.show_opt r.has_key?(:include).should be_true @@ -424,25 +432,33 @@ describe Comic do 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 + @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 + @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 diff --git a/spec/models/ground_color_spec.rb b/spec/models/ground_color_spec.rb index 38c56cf1..18104573 100644 --- a/spec/models/ground_color_spec.rb +++ b/spec/models/ground_color_spec.rb @@ -185,7 +185,7 @@ describe GroundColor do end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = GroundColor.list_opt r.has_key?(:include).should be_true @@ -208,25 +208,34 @@ describe GroundColor do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = GroundColor.list_json_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = GroundColor.list_json_opt[:include] - r.should have(2).items + 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 + @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 + @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id end it 'コマを含んでいる' do - r = GroundColor.list_json_opt[:include] - r.has_key?(:panel).should be_true + r = GroundColor.list.to_json GroundColor.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('panel').should be_true end it 'コマは作家を含んでいる' do - r = GroundColor.list_json_opt[:include] - r[:panel].has_key?(:author).should be_true + r = GroundColor.list.to_json GroundColor.list_json_opt + j = JSON.parse r + i = j.first + s = i['panel'] + s.has_key?('author').should be_true end it '色を含んでいる' do - r = GroundColor.list_json_opt[:include] - r.has_key?(:color).should be_true + r = GroundColor.list.to_json GroundColor.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('color').should be_true end end diff --git a/spec/models/ground_picture_spec.rb b/spec/models/ground_picture_spec.rb index 94714dd0..a44c371e 100644 --- a/spec/models/ground_picture_spec.rb +++ b/spec/models/ground_picture_spec.rb @@ -184,7 +184,7 @@ describe GroundPicture do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = GroundPicture.list_opt r.has_key?(:include).should be_true @@ -215,33 +215,48 @@ describe GroundPicture do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = GroundPicture.list_json_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = GroundPicture.list_json_opt[:include] - r.should have(2).items + 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 + @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 + @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id end it 'コマを含んでいる' do - r = GroundPicture.list_json_opt[:include] - r.has_key?(:panel).should be_true + r = GroundPicture.list.to_json GroundPicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('panel').should be_true end it 'コマは作家を含んでいる' do - r = GroundPicture.list_json_opt[:include] - r[:panel].has_key?(:author).should be_true + r = GroundPicture.list.to_json GroundPicture.list_json_opt + j = JSON.parse r + i = j.first + s = i['panel'] + s.has_key?('author').should be_true end it '実素材を含んでいる' do - r = GroundPicture.list_json_opt[:include] - r.has_key?(:picture).should be_true + r = GroundPicture.list.to_json GroundPicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('picture').should be_true end it '実素材は絵師を含んでいる' do - r = GroundPicture.list_json_opt[:include] - r[:picture].has_key?(:artist).should be_true + r = GroundPicture.list.to_json GroundPicture.list_json_opt + j = JSON.parse r + i = j.first + s = i['picture'] + s.has_key?('artist').should be_true end it '実素材はライセンスを含んでいる' do - r = GroundPicture.list_json_opt[:include] - r[:picture].has_key?(:license).should be_true + r = GroundPicture.list.to_json GroundPicture.list_json_opt + j = JSON.parse r + i = j.first + s = i['picture'] + s.has_key?('license').should be_true end end diff --git a/spec/models/license_group_spec.rb b/spec/models/license_group_spec.rb index 97cc5d24..181cb7c9 100644 --- a/spec/models/license_group_spec.rb +++ b/spec/models/license_group_spec.rb @@ -122,7 +122,7 @@ describe LicenseGroup do l.should eq [@lg, @lg2] end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = LicenseGroup.list_opt r.has_key?(:include).should be_true @@ -137,17 +137,26 @@ describe LicenseGroup do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = LicenseGroup.list_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = LicenseGroup.list_json_opt[:include] - r.should have(1).items + before do + @sp = FactoryGirl.create :system_picture + @lg = FactoryGirl.create :license_group + @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id + @user = FactoryGirl.create( :user_yas) + @author = @user.author + @artist = FactoryGirl.create :artist_yas, :author_id => @author.id + @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 + @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 = LicenseGroup.list_json_opt[:include] - r.has_key?(:licenses).should be_true + r = LicenseGroup.list.to_json LicenseGroup.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('licenses').should be_true end end @@ -174,7 +183,7 @@ describe LicenseGroup do end end end - describe '単体出力オプションに於いて' do + describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do r = LicenseGroup.show_opt r.has_key?(:include).should be_true @@ -189,17 +198,26 @@ describe LicenseGroup do end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = LicenseGroup.show_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = LicenseGroup.show_json_opt[:include] - r.should have(1).items + before do + @sp = FactoryGirl.create :system_picture + @lg = FactoryGirl.create :license_group + @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id + @user = FactoryGirl.create( :user_yas) + @author = @user.author + @artist = FactoryGirl.create :artist_yas, :author_id => @author.id + @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 + @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 = LicenseGroup.show_json_opt[:include] - r.has_key?(:licenses).should be_true + r = LicenseGroup.show(@lg.id).to_json LicenseGroup.show_json_opt + j = JSON.parse r + i = j + i.has_key?('licenses').should be_true end end diff --git a/spec/models/license_spec.rb b/spec/models/license_spec.rb index b6b2ccb7..b865aa3f 100644 --- a/spec/models/license_spec.rb +++ b/spec/models/license_spec.rb @@ -142,7 +142,7 @@ describe License do l.should eq [@l3, @l, @l2] end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = License.list_opt r.has_key?(:include).should be_true @@ -157,17 +157,16 @@ describe License do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = License.list_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = License.list_json_opt[:include] - r.should have(1).items + before do + @sp = FactoryGirl.create :system_picture + @lg = FactoryGirl.create :license_group + @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id end it 'ライセンスグループを含んでいる' do - r = License.list_json_opt[:include] - r.has_key?(:license_group).should be_true + r = License.list.to_json License.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('license_group').should be_true end end @@ -211,17 +210,16 @@ describe License do end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = License.show_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = License.show_json_opt[:include] - r.should have(1).items + before do + @sp = FactoryGirl.create :system_picture + @lg = FactoryGirl.create :license_group + @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id end it 'ライセンスグループを含んでいる' do - r = License.show_json_opt[:include] - r.has_key?(:license_group).should be_true + r = License.show(@l.id).to_json License.show_json_opt + j = JSON.parse r + i = j + i.has_key?('license_group').should be_true end end diff --git a/spec/models/original_picture_spec.rb b/spec/models/original_picture_spec.rb index 73b1f802..c787b6fa 100644 --- a/spec/models/original_picture_spec.rb +++ b/spec/models/original_picture_spec.rb @@ -278,7 +278,7 @@ describe OriginalPicture do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = OriginalPicture.list_opt r.has_key?(:include).should be_true @@ -297,21 +297,26 @@ describe OriginalPicture do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = OriginalPicture.list_json_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = OriginalPicture.list_json_opt[:include] - r.should have(2).items + 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 + @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 = OriginalPicture.list_json_opt[:include] - r.has_key?(:resource_picture).should be_true + r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('resource_picture').should be_true end it '実素材を含んでいる' do - r = OriginalPicture.list_json_opt[:include] - r.has_key?(:pictures).should be_true + r = OriginalPicture.mylist(@artist).to_json OriginalPicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('pictures').should be_true end end @@ -481,7 +486,7 @@ describe OriginalPicture do end end end - describe '単体出力オプションに於いて' do + describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do r = OriginalPicture.show_opt r.has_key?(:include).should be_true @@ -500,21 +505,26 @@ describe OriginalPicture do end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = OriginalPicture.show_json_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = OriginalPicture.show_json_opt[:include] - r.should have(2).items + 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 + @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 = OriginalPicture.show_json_opt[:include] - r.has_key?(:resource_picture).should be_true + r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('resource_picture').should be_true end it '実素材を含んでいる' do - r = OriginalPicture.show_json_opt[:include] - r.has_key?(:pictures).should be_true + r = OriginalPicture.show(@op.id, @artist).to_json OriginalPicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('pictures').should be_true end end describe '作成・更新に於いて' do diff --git a/spec/models/panel_color_spec.rb b/spec/models/panel_color_spec.rb index 7740421a..1e960dee 100644 --- a/spec/models/panel_color_spec.rb +++ b/spec/models/panel_color_spec.rb @@ -195,7 +195,7 @@ describe PanelColor do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = PanelColor.list_opt r.has_key?(:include).should be_true @@ -214,21 +214,28 @@ describe PanelColor do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = PanelColor.list_json_opt - r.has_key?(:include).should be_true - end - it '1つの項目を含んでいる' do - r = PanelColor.list_json_opt[:include] - r.should have(1).items + 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 + @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1 + @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 + @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id + @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id end it 'コマを含んでいる' do - r = PanelColor.list_json_opt[:include] - r.has_key?(:panel).should be_true + r = PanelColor.list.to_json PanelColor.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('panel').should be_true end it 'コマは作家を含んでいる' do - r = PanelColor.list_json_opt[:include] - r[:panel].has_key?(:author).should be_true + r = PanelColor.list.to_json PanelColor.list_json_opt + j = JSON.parse r + i = j.first + s = i['panel'] + s.has_key?('author').should be_true end end diff --git a/spec/models/panel_picture_spec.rb b/spec/models/panel_picture_spec.rb index bed7168d..3a399c84 100644 --- a/spec/models/panel_picture_spec.rb +++ b/spec/models/panel_picture_spec.rb @@ -392,7 +392,7 @@ describe PanelPicture do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = PanelPicture.list_opt r.has_key?(:include).should be_true @@ -423,33 +423,49 @@ describe PanelPicture do end end describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = PanelPicture.list_json_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = PanelPicture.list_json_opt[:include] - r.should have(2).items + 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 + @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 + @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_json_opt[:include] - r.has_key?(:panel).should be_true + 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_json_opt[:include] - r[:panel].has_key?(:author).should be_true + 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_json_opt[:include] - r.has_key?(:picture).should be_true + 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_json_opt[:include] - r[:picture].has_key?(:artist).should be_true + 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_json_opt[:include] - r[:picture].has_key?(:license).should be_true + 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 diff --git a/spec/models/panel_spec.rb b/spec/models/panel_spec.rb index af02387a..01f94702 100644 --- a/spec/models/panel_spec.rb +++ b/spec/models/panel_spec.rb @@ -331,7 +331,7 @@ describe Panel do end end end - describe 'list関連テーブルプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = Panel.list_opt r.has_key?(:include).should be_true @@ -541,7 +541,7 @@ describe Panel do end end end - describe '関連テーブルプションに於いて' do + describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do r = Panel.show_opt r.has_key?(:include).should be_true diff --git a/spec/models/resource_picture_spec.rb b/spec/models/resource_picture_spec.rb index ba5d62a7..20f6d936 100644 --- a/spec/models/resource_picture_spec.rb +++ b/spec/models/resource_picture_spec.rb @@ -385,7 +385,7 @@ describe ResourcePicture do end end end - describe '一覧出力オプションに於いて' do + describe '一覧取得オプションに於いて' do it 'includeキーを含んでいる' do r = ResourcePicture.list_opt r.has_key?(:include).should be_true @@ -407,28 +407,35 @@ describe ResourcePicture do r.has_key?(:picture).should be_true end end - describe 'json一覧出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = ResourcePicture.list_json_opt - r.has_key?(:include).should be_true - end - it '3つの項目を含んでいる' do - r = ResourcePicture.list_json_opt[:include] - r.should have(3).items + 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 + @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 = ResourcePicture.list_json_opt[:include] - r.has_key?(:license).should be_true + r = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('license').should be_true end it '絵師を含んでいる' do - r = ResourcePicture.list_json_opt[:include] - r.has_key?(:artist).should be_true + r = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('artist').should be_true end it '実素材を含んでいる' do - r = ResourcePicture.list_json_opt[:include] - r.has_key?(:picture).should be_true + r = ResourcePicture.list.to_json ResourcePicture.list_json_opt + j = JSON.parse r + i = j.first + i.has_key?('picture').should be_true end - end + end describe '単体取得に於いて' do before do @@ -468,7 +475,7 @@ describe ResourcePicture do end end end - describe '単体出力オプションに於いて' do + describe '単体取得オプションに於いて' do it 'includeキーを含んでいる' do r = ResourcePicture.show_opt r.has_key?(:include).should be_true @@ -491,25 +498,32 @@ describe ResourcePicture do end end describe 'json単体出力オプションに於いて' do - it 'includeキーを含んでいる' do - r = ResourcePicture.show_json_opt - r.has_key?(:include).should be_true - end - it '3つの項目を含んでいる' do - r = ResourcePicture.show_json_opt[:include] - r.should have(3).items + 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 + @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 = ResourcePicture.show_json_opt[:include] - r.has_key?(:license).should be_true + r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('license').should be_true end it '絵師を含んでいる' do - r = ResourcePicture.show_json_opt[:include] - r.has_key?(:artist).should be_true + r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('artist').should be_true end it '実素材を含んでいる' do - r = ResourcePicture.show_json_opt[:include] - r.has_key?(:picture).should be_true + r = ResourcePicture.show(@rp.id, @author).to_json ResourcePicture.show_json_opt + j = JSON.parse r + i = j + i.has_key?('picture').should be_true end end