OSDN Git Service

t#29620:json output include child
authoryasushiito <yas@pen-chan.jp>
Fri, 28 Sep 2012 23:53:59 +0000 (08:53 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 28 Sep 2012 23:53:59 +0000 (08:53 +0900)
18 files changed:
app/models/artist.rb
app/models/comic.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/panel_color.rb
app/models/panel_picture.rb
spec/models/artist_spec.rb
spec/models/author_spec.rb
spec/models/comic_spec.rb
spec/models/ground_color_spec.rb
spec/models/ground_picture_spec.rb
spec/models/license_group_spec.rb
spec/models/license_spec.rb
spec/models/original_picture_spec.rb
spec/models/panel_color_spec.rb
spec/models/panel_picture_spec.rb
spec/models/panel_spec.rb
spec/models/resource_picture_spec.rb

index 63a1f20..56ae09a 100644 (file)
@@ -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
index 107c094..56b593a 100644 (file)
@@ -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
index 95568a3..e2fe846 100644 (file)
@@ -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
index c98e9dd..ebb5959 100644 (file)
@@ -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
index deb2931..f97eb55 100644 (file)
@@ -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
index 772f9a0..013ae96 100644 (file)
@@ -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
index 815edbc..3bfff22 100644 (file)
@@ -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
index 981102c..3444f9a 100644 (file)
@@ -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
   
index f83e83f..adf62c5 100644 (file)
@@ -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\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
   
@@ -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\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
index 38c56cf..1810457 100644 (file)
@@ -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\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
+      @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
   
index 94714dd..a44c371 100644 (file)
@@ -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\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
+      @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
   
index 97cc5d2..181cb7c 100644 (file)
@@ -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\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 = 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\r
     end\r
   end
-  describe 'å\8d\98ä½\93å\87ºå\8a\9bオプションに於いて' do
+  describe 'å\8d\98ä½\93å\8f\96å¾\97オプションに於いて' 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\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 = 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
   
index b6b2ccb..b865aa3 100644 (file)
@@ -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
   
index 73b1f80..c787b6f 100644 (file)
@@ -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\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 = 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 'å\8d\98ä½\93å\87ºå\8a\9bオプションに於いて' do
+  describe 'å\8d\98ä½\93å\8f\96å¾\97オプションに於いて' 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\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 = 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
index 7740421..1e960de 100644 (file)
@@ -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\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
+      @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
   
index bed7168..3a399c8 100644 (file)
@@ -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\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
+      @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
   
index af02387..01f9470 100644 (file)
@@ -331,7 +331,7 @@ describe Panel do
       end
     end
   end\r
-  describe 'list関連テーブルプションに於いて' do\r
+  describe '一覧取得オプションに於いて' do\r
     it 'includeキーを含んでいる' do\r
       r = Panel.list_opt\r
       r.has_key?(:include).should be_true\r
@@ -541,7 +541,7 @@ describe Panel do
       end\r
     end\r
   end\r
-  describe '関連テーブルプションに於いて' do\r
+  describe '単体取得オプションに於いて' do\r
     it 'includeキーを含んでいる' do\r
       r = Panel.show_opt\r
       r.has_key?(:include).should be_true\r
index ba5d62a..20f6d93 100644 (file)
@@ -385,7 +385,7 @@ describe ResourcePicture do
       end
     end
   end\r
-  describe 'ä¸\80覧å\87ºå\8a\9bオプションに於いて' do\r
+  describe 'ä¸\80覧å\8f\96å¾\97オプションに於いて' do\r
     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\r
-  describe 'json一覧出力オプションに於いて' do\r
-    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\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 = 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\r
+  end
   \r
   describe '単体取得に於いて' do\r
     before do\r
@@ -468,7 +475,7 @@ describe ResourcePicture do
       end\r
     end\r
   end\r
-  describe 'å\8d\98ä½\93å\87ºå\8a\9bオプションに於いて' do\r
+  describe 'å\8d\98ä½\93å\8f\96å¾\97オプションに於いて' do\r
     it 'includeキーを含んでいる' do
       r = ResourcePicture.show_opt
       r.has_key?(:include).should be_true
@@ -491,25 +498,32 @@ describe ResourcePicture do
     end
   end\r
   describe 'json単体出力オプションに於いて' do\r
-    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\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 = 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\r
   \r