OSDN Git Service

fix peta spec
authoryasushiito <yas@pen-chan.jp>
Thu, 31 Jul 2014 22:34:21 +0000 (07:34 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 31 Jul 2014 22:34:21 +0000 (07:34 +0900)
15 files changed:
app/assets/javascripts/work/system_resources.js.coffee.erb
public/manifest.json
spec/factories/comic_story.rb
spec/factories/license.rb
spec/factories/license_group.rb
spec/factories/panel.rb
spec/factories/scroll.rb
spec/factories/speech_balloon_template.rb
spec/factories/system_picture.rb
spec/factories/writing_format.rb
spec/peta/leaf_spec.rb
spec/peta/root_spec.rb
spec/peta/system_resource_spec.rb
spec/peta/template_spec.rb
spec/support/peta_macros.rb

index 1a98384..c6e52bc 100644 (file)
@@ -16,7 +16,6 @@
         CircleSpeechBalloon: 'circle_speech_balloon',\r
         PlainSpeechBalloon: 'plain_speech_balloon',\r
         SquareSpeechBalloon: 'square_speech_balloon',\r
-        TestSpeechBalloon: 'test_speech_balloon',\r
       },\r
     },\r
     writing_format: {\r
index b72ecdf..ffbb8b7 100644 (file)
         "template_items": {\r
           "CircleSpeechBalloon": "circle_speech_balloon",\r
           "PlainSpeechBalloon": "plain_speech_balloon",\r
-          "SquareSpeechBalloon": "square_speech_balloon",\r
-          "TestSpeechBalloon": "test_speech_balloon"\r
+          "SquareSpeechBalloon": "square_speech_balloon"\r
         }\r
       },\r
       "writing_format": {\r
index 8b2121e..3357bdf 100644 (file)
@@ -2,64 +2,4 @@
 FactoryGirl.define do\r
   factory :comic_story_plain, :class => ComicStory do |i|\r
   end\r
-  factory :comic_story002, :class => ComicStory do |i|\r
-    i.comic_id 2\r
-    i.story_id 2\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story003, :class => ComicStory do |i|\r
-    i.comic_id 2\r
-    i.story_id 3\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story004, :class => ComicStory do |i|\r
-    i.comic_id 2\r
-    i.story_id 4\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story005, :class => ComicStory do |i|\r
-    i.comic_id 7\r
-    i.story_id 5\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story006, :class => ComicStory do |i|\r
-    i.comic_id 7\r
-    i.story_id 2\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story007, :class => ComicStory do |i|\r
-    i.comic_id 7\r
-    i.story_id 3\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story008, :class => ComicStory do |i|\r
-    i.comic_id 8\r
-    i.story_id 4\r
-    i.t 3\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story009, :class => ComicStory do |i|\r
-    i.comic_id 8\r
-    i.story_id 3\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story010, :class => ComicStory do |i|\r
-    i.comic_id 8\r
-    i.story_id 2\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :comic_story011, :class => ComicStory do |i|\r
-    i.comic_id 8\r
-    i.story_id 5\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
 end\r
index 4e59cb4..50b38a1 100644 (file)
@@ -1,7 +1,6 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :license001, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_by, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY@us'\r
     i.caption 'BY'\r
@@ -10,115 +9,141 @@ FactoryGirl.define do
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license002, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_bync, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY-NC@us'\r
     i.caption 'BY-NC'\r
-    i.system_picture_id 4\r
     i.url 'http://creativecommons.org/licenses/by-nc/3.0/'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license003, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_bysa, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY-SA@us'\r
     i.caption 'BY-SA'\r
-    i.system_picture_id 5\r
     i.url 'http://creativecommons.org/licenses/by-sa/3.0/'\r
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license004, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_byncsa, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY-NC-SA@us'\r
     i.caption 'BY-NC-SA'\r
-    i.system_picture_id 6\r
     i.url 'http://creativecommons.org/licenses/by-nc-sa/3.0/'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license005, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_bynd, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY-ND@us'\r
     i.caption 'BY-ND'\r
-    i.system_picture_id 7\r
     i.url 'http://creativecommons.org/licenses/by-nd/3.0/'\r
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":-1,"thumbnail":-1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license006, :class => License do |i|\r
-    i.license_group_id 8\r
+  factory :license_cc_byndnc, :class => License do |i|\r
     i.license_group_module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.name 'CreativeCommonsV30Licenses:BY-ND-NC@us'\r
     i.caption 'BY-ND-NC'\r
-    i.system_picture_id 8\r
     i.url 'http://creativecommons.org/licenses/by-nc-nd/3.0/'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":-1,"thumbnail":-1,"gif_convert":-1,"reverse":-1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
   end\r
-  factory :license007, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_by, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY@pettanr'\r
     i.caption 'BY'\r
-    i.system_picture_id 9\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY'\r
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_by).id\r
+      end\r
+    end\r
+    factory :license_pc_by_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :license008, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_bync, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY-NC@pettanr'\r
     i.caption 'BY-NC'\r
-    i.system_picture_id 10\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY_NC'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_bync).id\r
+      end\r
+    end\r
+    factory :license_pc_bync_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :license009, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_bysa, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY-SA@pettanr'\r
     i.caption 'BY-SA'\r
-    i.system_picture_id 11\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY_SA'\r
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_bysa).id\r
+      end\r
+    end\r
+    factory :license_pc_bysa_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :license010, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_byncsa, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY-NC-SA@pettanr'\r
     i.caption 'BY-NC-SA'\r
-    i.system_picture_id 12\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY_NC_SA'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_byncsa).id\r
+      end\r
+    end\r
+    factory :license_pc_byncsa_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :license011, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_bynd, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY-ND@pettanr'\r
     i.caption 'BY-ND'\r
-    i.system_picture_id 13\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY_ND'\r
     i.license_group_settings '{"open":0,"commercial":1,"official":0,"attribution":1,"derive":-1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_bynd).id\r
+      end\r
+    end\r
+    factory :license_pc_bynd_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :license012, :class => License do |i|\r
-    i.license_group_id 7\r
+  factory :license_pc_byndnc, :class => License do |i|\r
     i.license_group_module_name 'PettanrPettanCommonsV01Licenses'\r
     i.name 'PettanCommonsV01Licenses:BY-ND-NC@pettanr'\r
     i.caption 'BY-ND-NC'\r
-    i.system_picture_id 14\r
     i.url 'https://github.com/yasushiito/pettanr_pcom_v01_licenses/wiki/BY_ND_NC'\r
     i.license_group_settings '{"open":0,"commercial":-1,"official":0,"attribution":1,"derive":-1,"thumbnail":1,"gif_convert":1,"reverse":1,"sync_vh":1,"overlap":1}'\r
     i.credit_picture_settings '{"source_url_btn_id":1,"source_url_off_btn_id":2}'\r
+    trait :with_system_picture do\r
+      after(:build) do |license, evaluator|\r
+        source_url_btn = SystemPicture.find_by_md5('05722b184172adef876604239842c18b') || create(:system_picture_source_url_btn)\r
+        source_url_off_btn = SystemPicture.find_by_md5('00c4246c193c7cec0425d44e34c43828') || create(:system_picture_source_url_off_btn)\r
+        license.system_picture_id = create(:system_picture_license_pc_byndnc).id\r
+      end\r
+    end\r
+    factory :license_pc_byndnc_with_system_picture, traits: [:with_system_picture]\r
   end\r
   factory :license013, :class => License do |i|\r
     i.license_group_id 9\r
index fad822f..b7d4170 100644 (file)
@@ -1,75 +1,55 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :license_group001, :class => LicenseGroup do |i|\r
-    i.name 'CreativeCommonsV30License@us'\r
-    i.module_name 'PettanrCreativeCommonsV30Licenses'\r
-    i.caption 'Creative Commons 3.0'\r
-    i.url 'http://creativecommons.org/'\r
-  end\r
-  factory :license_group002, :class => LicenseGroup do |i|\r
-    i.name 'PettanCommonsV01License@pettanr'\r
-    i.module_name 'PettanrPettanCommonsV01Licenses'\r
-    i.caption 'Pettan Commons 0.1'\r
-    i.url 'http://sourceforge.jp/projects/pettanr/wiki/PettanCommons'\r
-  end\r
-  factory :license_group003, :class => LicenseGroup do |i|\r
-    i.name 'PettanProtected01License@pettanr'\r
-    i.module_name 'PettanrPettanProtectedV01Licenses'\r
-    i.caption 'Pettan Protected 0.1'\r
-    i.url 'https://github.com/yasushiito/pettanr_ppro_v01_licenses/wiki'\r
-  end\r
-  factory :license_group004, :class => LicenseGroup do |i|\r
-    i.name 'PettanPublicV01License@pettanr'\r
-    i.module_name 'PettanrPettanPublicV01Licenses'\r
-    i.caption 'Pettan Public 0.1'\r
-    i.url 'https://github.com/yasushiito/pettanr_ppub_v01_licenses/wiki'\r
-  end\r
-  factory :license_group005, :class => LicenseGroup do |i|\r
-    i.name 'PublicDomainV01License@pettanr'\r
-    i.module_name 'PettanrPublicDomainV01Licenses'\r
-    i.caption 'Public Domain 0.1'\r
-    i.url 'https://github.com/yasushiito/pettanr_pd_v01_licenses/wiki'\r
-  end\r
-  factory :license_group006, :class => LicenseGroup do |i|\r
-    i.name 'UnknownV01License@pettanr'\r
-    i.module_name 'PettanrUnknownV01Licenses'\r
-    i.caption 'Unknown 0.1'\r
-    i.url 'https://github.com/yasushiito/pettanr_unknown_v01_licenses/wiki'\r
-  end\r
-  factory :license_group007, :class => LicenseGroup do |i|\r
+  factory :license_group_pc, :class => LicenseGroup do |i|\r
     i.name 'PettanCommonsV01Licenses@pettanr'\r
     i.module_name 'PettanrPettanCommonsV01Licenses'\r
     i.caption 'Pettan Commons 0.1'\r
     i.url 'http://sourceforge.jp/projects/pettanr/wiki/PettanCommons'\r
-  end\r
-  factory :license_group008, :class => LicenseGroup do |i|\r
+    trait :with_licenses do\r
+      after(:create) do |lg, evaluator|\r
+        create(:license_pc_by_with_system_picture)\r
+        create(:license_pc_bync_with_system_picture)\r
+        create(:license_pc_bysa_with_system_picture)\r
+        create(:license_pc_byncsa_with_system_picture)\r
+        create(:license_pc_bynd_with_system_picture)\r
+      end\r
+    end\r
+    factory :license_group_pc_with_licenses, traits: [:with_licenses]\r
+  end\r
+  factory :license_group_cc, :class => LicenseGroup do |i|\r
     i.name 'CreativeCommonsV30Licenses@us'\r
     i.module_name 'PettanrCreativeCommonsV30Licenses'\r
     i.caption 'Creative Commons 3.0'\r
     i.url 'http://creativecommons.org/'\r
   end\r
-  factory :license_group009, :class => LicenseGroup do |i|\r
+  factory :license_group_ppro, :class => LicenseGroup do |i|\r
     i.name 'PettanProtected01Licenses@pettanr'\r
     i.module_name 'PettanrPettanProtectedV01Licenses'\r
     i.caption 'Pettan Protected 0.1'\r
     i.url 'https://github.com/yasushiito/pettanr_ppro_v01_licenses/wiki'\r
   end\r
-  factory :license_group010, :class => LicenseGroup do |i|\r
+  factory :license_group_ppub, :class => LicenseGroup do |i|\r
     i.name 'PettanPublicV01Licenses@pettanr'\r
     i.module_name 'PettanrPettanPublicV01Licenses'\r
     i.caption 'Pettan Public 0.1'\r
     i.url 'https://github.com/yasushiito/pettanr_ppub_v01_licenses/wiki'\r
   end\r
-  factory :license_group011, :class => LicenseGroup do |i|\r
+  factory :license_group_pd, :class => LicenseGroup do |i|\r
     i.name 'PublicDomainV01Licenses@pettanr'\r
     i.module_name 'PettanrPublicDomainV01Licenses'\r
     i.caption 'Public Domain 0.1'\r
     i.url 'https://github.com/yasushiito/pettanr_pd_v01_licenses/wiki'\r
   end\r
-  factory :license_group012, :class => LicenseGroup do |i|\r
+  factory :license_group_uk, :class => LicenseGroup do |i|\r
     i.name 'UnknownV01Licenses@pettanr'\r
     i.module_name 'PettanrUnknownV01Licenses'\r
     i.caption 'Unknown 0.1'\r
     i.url 'https://github.com/yasushiito/pettanr_unknown_v01_licenses/wiki'\r
   end\r
+  factory :license_group_test, :class => LicenseGroup do |i|\r
+    i.name 'TestV01Licenses@pettanr'\r
+    i.module_name 'PettanrTestV01Licenses'\r
+    i.caption 'Test 0.1'\r
+    i.url 'https://github.com/yasushiito/pettanr_test_v01_licenses/wiki'\r
+  end\r
 end\r
index ebe99ab..0eceba5 100644 (file)
@@ -51,31 +51,27 @@ FactoryGirl.define do
     i.caption ''\r
     i.publish 0\r
   end\r
-  factory :panel004, :class => Panel do |i|\r
+  factory :panel_great, :class => Panel do |i|\r
     i.width 200\r
     i.height 80\r
     i.border 2\r
     i.caption ''\r
-    i.publish 0\r
-    i.author_id 1\r
   end\r
-  factory :panel005, :class => Panel do |i|\r
+  factory :panel_awesome, :class => Panel do |i|\r
     i.width 333\r
     i.height 240\r
     i.border 2\r
     i.caption ''\r
     i.publish 1\r
-    i.author_id 1\r
   end\r
-  factory :panel006, :class => Panel do |i|\r
+  factory :panel_wonderful, :class => Panel do |i|\r
     i.width 500\r
     i.height 300\r
     i.border 3\r
     i.caption ''\r
-    i.publish 0\r
-    i.author_id 1\r
+    i.publish 1\r
   end\r
-  factory :panel007, :class => Panel do |i|\r
+  factory :panel_, :class => Panel do |i|\r
     i.width 500\r
     i.height 300\r
     i.border 2\r
index c80f5e0..f74dd92 100644 (file)
@@ -29,6 +29,14 @@ FactoryGirl.define do
     i.title 'aaaaaaaa'\r
     i.description ''\r
     i.visible 1\r
+    trait :with_scroll_panels do\r
+      after(:create) do |scroll, evaluator|\r
+        create(:scroll_panel_plain, t: 0, scroll: scroll, panel: create(:panel_great, author: scroll.author))\r
+        create(:scroll_panel_plain, t: 1, scroll: scroll, panel: create(:panel_awesome, author: scroll.author))\r
+        create(:scroll_panel_plain, t: 2, scroll: scroll, panel: create(:panel_wonderful, author: scroll.author))\r
+      end\r
+    end\r
+    factory :scroll_great_with_scroll_panels, traits: [:with_scroll_panels]\r
   end\r
   factory :scroll_diary, :class => Scroll do |i|\r
     i.title '投稿した直後'\r
index 9047331..ac97ed3 100644 (file)
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :speech_balloon_template001, :class => SpeechBalloonTemplate do |i|\r
+  factory :speech_balloon_template_circle, :class => SpeechBalloonTemplate do |i|\r
     i.name 'circle@pettan.com'\r
     i.module_name 'CircleSpeechBalloon'\r
     i.caption '楕円'\r
     i.t 0\r
-    i.system_picture_id 41\r
-    i.settings '{"speech_balloon":{"quotes":"\u300c \u300d \u300e \u300f","default_width":200,"default_height":200,"default_font_size":1.0,"default_text_align":0,"default_fore_color":0,"default_r":140,"r_step":22.5},"0":{"balloon":{"system_picture_id":25},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"1":{"balloon":{"system_picture_id":26},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"2":{"balloon":{"system_picture_id":27},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"3":{"balloon":{"system_picture_id":28},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"4":{"balloon":{"system_picture_id":29},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"5":{"balloon":{"system_picture_id":30},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"6":{"balloon":{"system_picture_id":31},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"7":{"balloon":{"system_picture_id":32},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"8":{"balloon":{"system_picture_id":33},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"9":{"balloon":{"system_picture_id":34},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"10":{"balloon":{"system_picture_id":35},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"11":{"balloon":{"system_picture_id":36},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"12":{"balloon":{"system_picture_id":37},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"13":{"balloon":{"system_picture_id":38},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"14":{"balloon":{"system_picture_id":39},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}},"15":{"balloon":{"system_picture_id":40},"speech":{"x_rate":20,"y_rate":20,"width_rate":60,"height_rate":60}}}'\r
+    trait :with_system_picture do\r
+      after(:build) do |speech_balloon_template, evaluator|\r
+        icon = SystemPicture.find_by_md5('ca30a88b2e03bd149860325d5f3770a7') || \r
+          create(:system_picture_circle_icon)\r
+        speech_balloon_template.system_picture_id = icon.id\r
+        balloon0 = SystemPicture.find_by_md5('67d7c8acd3c52cb6e9abf7deb23be11d') || \r
+          create(:system_picture_circle_balloon_0)\r
+        balloon1 = SystemPicture.find_by_md5('58634a962f2126d6bc9119e843a07ed9') || \r
+          create(:system_picture_circle_balloon_1)\r
+        balloon2 = SystemPicture.find_by_md5('3e0d2528d0b58fb32414593a04daa7b3') || \r
+          create(:system_picture_circle_balloon_2)\r
+        balloon3 = SystemPicture.find_by_md5('dd3590336d7b69f2e85fc0c1b629d64a') || \r
+          create(:system_picture_circle_balloon_3)\r
+        balloon4 = SystemPicture.find_by_md5('a04f3ea06f95e33358ac57645031512d') || \r
+          create(:system_picture_circle_balloon_4)\r
+        balloon5 = SystemPicture.find_by_md5('d76cf38c3de4df74ae9f8bc76911a5a9') || \r
+          create(:system_picture_circle_balloon_5)\r
+        balloon6 = SystemPicture.find_by_md5('51974b0cc1d0283be6cda04114927dc5') || \r
+          create(:system_picture_circle_balloon_6)\r
+        balloon7 = SystemPicture.find_by_md5('68af2004a103a389d2c83b2cfcd98b22') || \r
+          create(:system_picture_circle_balloon_7)\r
+        balloon8 = SystemPicture.find_by_md5('9feac91d55ef144bad8389ee4f0751ac') || \r
+          create(:system_picture_circle_balloon_8)\r
+        balloon9 = SystemPicture.find_by_md5('50fb44750f5506cc9ed0783d92f58f00') || \r
+          create(:system_picture_circle_balloon_9)\r
+        balloon10 = SystemPicture.find_by_md5('bb65ca8d549401f6cc0bd6228cf6b79b') || \r
+          create(:system_picture_circle_balloon_10)\r
+        balloon11 = SystemPicture.find_by_md5('a6d32cb9218abc587fa732a21c94883e') || \r
+          create(:system_picture_circle_balloon_11)\r
+        balloon12 = SystemPicture.find_by_md5('b0aba72c940b80e9e32b87bd48ca2635') || \r
+          create(:system_picture_circle_balloon_12)\r
+        balloon13 = SystemPicture.find_by_md5('b886601235032b7006c23ba8bf309f74') || \r
+          create(:system_picture_circle_balloon_13)\r
+        balloon14 = SystemPicture.find_by_md5('e98e6b7bba74f8d166f0f69303b14a19') || \r
+          create(:system_picture_circle_balloon_14)\r
+        balloon15 = SystemPicture.find_by_md5('6756b435ba777f66dfea8e34d2e94567') || \r
+          create(:system_picture_circle_balloon_15)\r
+        speech_balloon_template.settings = {\r
+          "speech_balloon" => {\r
+            "quotes" => "\u300c \u300d \u300e \u300f",\r
+            "default_width" => 200,\r
+            "default_height" => 200,\r
+            "default_font_size" => 1.0,\r
+            "default_text_align" => 0,\r
+            "default_fore_color" => 0,\r
+            "default_r" => 140,\r
+            "r_step" => 22.5\r
+          },\r
+          "0" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon0.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "1" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon1.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "2" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon2.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "3" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon3.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "4" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon4.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "5" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon5.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "6" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon6.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "7" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon7.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "8" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon8.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "9" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon9.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "10" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon10.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "11" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon11.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "12" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon12.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "13" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon13.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "14" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon14.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          },\r
+          "15" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon15.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 20,\r
+              "y_rate" => 20,\r
+              "width_rate" => 60,\r
+              "height_rate" => 60\r
+            }\r
+          }\r
+        }.to_json\r
+      end\r
+    end\r
+    factory :speech_balloon_template_circle_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :speech_balloon_template002, :class => SpeechBalloonTemplate do |i|\r
+  factory :speech_balloon_template_plain, :class => SpeechBalloonTemplate do |i|\r
     i.name 'plain@pettan.com'\r
     i.module_name 'PlainSpeechBalloon'\r
     i.caption '透明'\r
     i.t 1\r
-    i.system_picture_id 43\r
-    i.settings '{"speech_balloon":{"quotes":"\u300c \u300d \u300e \u300f","default_width":150,"default_height":150,"default_font_size":1.0,"default_text_align":0,"default_fore_color":0},"all":{"balloon":{"system_picture_id":42},"speech":{"x_rate":0,"y_rate":0,"width_rate":100,"height_rate":100}}}'\r
+    trait :with_system_picture do\r
+      after(:build) do |speech_balloon_template, evaluator|\r
+        icon = SystemPicture.find_by_md5('d6b95a015cafe40f05f0a26b4ac3c51e') || \r
+          create(:system_picture_plain_icon)\r
+        speech_balloon_template.system_picture_id = icon.id\r
+        balloon0 = SystemPicture.find_by_md5('8197e42069aab7d15983425e6c121503') || \r
+          create(:system_picture_plain_balloon_0)\r
+        speech_balloon_template.settings = {\r
+          "speech_balloon" => {\r
+            "quotes" => "\u300c \u300d \u300e \u300f",\r
+            "default_width" => 150,\r
+            "default_height" => 150,\r
+            "default_font_size" => 1.0,\r
+            "default_text_align" => 0,\r
+            "default_fore_color" => 0\r
+          },\r
+          "all" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon0.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 0,\r
+              "y_rate" => 0,\r
+              "width_rate" => 100,\r
+              "height_rate" => 100\r
+            }\r
+          }\r
+        }.to_json\r
+      end\r
+    end\r
+    factory :speech_balloon_template_plain_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :speech_balloon_template003, :class => SpeechBalloonTemplate do |i|\r
+  factory :speech_balloon_template_square, :class => SpeechBalloonTemplate do |i|\r
     i.name 'square@pettan.com'\r
     i.module_name 'SquareSpeechBalloon'\r
     i.caption '長方形'\r
     i.t 2\r
-    i.system_picture_id 45\r
-    i.settings '{"speech_balloon":{"quotes":"\u300c \u300d \u300e \u300f","default_width":150,"default_height":150,"default_font_size":1.0,"default_text_align":3,"default_fore_color":0},"all":{"balloon":{"system_picture_id":44},"speech":{"x_rate":5,"y_rate":5,"width_rate":90,"height_rate":90}}}'\r
+    trait :with_system_picture do\r
+      after(:build) do |speech_balloon_template, evaluator|\r
+        icon = SystemPicture.find_by_md5('6f683574166286bb65d8ffa25a0af17f') || \r
+          create(:system_picture_square_icon)\r
+        speech_balloon_template.system_picture_id = icon.id\r
+        balloon0 = SystemPicture.find_by_md5('8159134d0af4b24ef21f30048f018ab1') || \r
+          create(:system_picture_square_balloon_0)\r
+        speech_balloon_template.settings = {\r
+          "speech_balloon" => {\r
+            "quotes" => "\u300c \u300d \u300e \u300f",\r
+            "default_width" => 150,\r
+            "default_height" => 150,\r
+            "default_font_size" => 1.0,\r
+            "default_text_align" => 3,\r
+            "default_fore_color" => 0\r
+          },\r
+          "all" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon0.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 5,\r
+              "y_rate" => 5,\r
+              "width_rate" => 90,\r
+              "height_rate" => 90\r
+            }\r
+          }\r
+        }.to_json\r
+      end\r
+    end\r
+    factory :speech_balloon_template_square_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :speech_balloon_template004, :class => SpeechBalloonTemplate do |i|\r
+  factory :speech_balloon_template_test, :class => SpeechBalloonTemplate do |i|\r
     i.name 'test@pettan.com'\r
     i.module_name 'TestSpeechBalloon'\r
     i.caption 'テスト'\r
     i.t 3\r
-    i.system_picture_id 47\r
-    i.settings '{"speech_balloon":{"quotes":"\u300c \u300d \u300e \u300f","default_width":150,"default_height":150,"default_font_size":1.0,"default_text_align":3,"default_fore_color":0},"all":{"balloon":{"system_picture_id":46},"speech":{"x_rate":5,"y_rate":5,"width_rate":90,"height_rate":90}}}'\r
+    trait :with_system_picture do\r
+      after(:build) do |speech_balloon_template, evaluator|\r
+        icon = SystemPicture.find_by_md5('a33a8a440701a6d3d68bc4df4687ab6d') || \r
+          create(:system_picture_test_icon)\r
+        speech_balloon_template.system_picture_id = icon.id\r
+        balloon0 = SystemPicture.find_by_md5('604a977cf756a4e8b2b74d05c3d647d2') || \r
+          create(:system_picture_test_balloon_0)\r
+        speech_balloon_template.settings = {\r
+          "speech_balloon" => {\r
+            "quotes" => "\u300c \u300d \u300e \u300f",\r
+            "default_width" => 150,\r
+            "default_height" => 150,\r
+            "default_font_size" => 1.0,\r
+            "default_text_align" => 3,\r
+            "default_fore_color" => 0\r
+          },\r
+          "all" => {\r
+            "balloon" => {\r
+              "system_picture_id" => balloon0.id\r
+            },\r
+            "speech" => {\r
+              "x_rate" => 5,\r
+              "y_rate" => 5,\r
+              "width_rate" => 90,\r
+              "height_rate" => 90\r
+            }\r
+          }\r
+        }.to_json\r
+      end\r
+    end\r
+    factory :speech_balloon_template_test_with_system_picture, traits: [:with_system_picture]\r
   end\r
 end\r
index 24d5247..4f19bff 100644 (file)
@@ -1,13 +1,13 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :system_picture001, :class => SystemPicture do |i|\r
+  factory :system_picture_source_url_btn, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 17\r
     i.height 17\r
     i.filesize 160\r
     i.md5 '05722b184172adef876604239842c18b'\r
   end\r
-  factory :system_picture002, :class => SystemPicture do |i|\r
+  factory :system_picture_source_url_off_btn, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 17\r
     i.height 17\r
@@ -56,42 +56,42 @@ FactoryGirl.define do
     i.filesize 3731\r
     i.md5 'ead5ffb65e66c1a7b022984be0220b9f'\r
   end\r
-  factory :system_picture009, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_by, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
     i.filesize 2307\r
     i.md5 '42748c6f32afa939feefbfd2898021fa'\r
   end\r
-  factory :system_picture010, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_bync, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
     i.filesize 3466\r
     i.md5 '1282a4e8a6c4ab748add11d89b51fc33'\r
   end\r
-  factory :system_picture011, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_bysa, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
     i.filesize 3410\r
     i.md5 'e85a1d09345728ded036630632ab11bd'\r
   end\r
-  factory :system_picture012, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_byncsa, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
     i.filesize 4487\r
     i.md5 '198e176b8648171c8e69350363f872f0'\r
   end\r
-  factory :system_picture013, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_bynd, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
     i.filesize 3375\r
     i.md5 '76a6d32b01bcfe71fb25d3ada91ebc71'\r
   end\r
-  factory :system_picture014, :class => SystemPicture do |i|\r
+  factory :system_picture_license_pc_byndnc, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 88\r
     i.height 31\r
@@ -168,168 +168,168 @@ FactoryGirl.define do
     i.filesize 1548\r
     i.md5 'dd94c3acb7c22f6cdb35ff69371407ed'\r
   end\r
-  factory :system_picture025, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_0, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 5662\r
     i.md5 '67d7c8acd3c52cb6e9abf7deb23be11d'\r
   end\r
-  factory :system_picture026, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_1, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9607\r
     i.md5 '58634a962f2126d6bc9119e843a07ed9'\r
   end\r
-  factory :system_picture027, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_2, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9362\r
     i.md5 '3e0d2528d0b58fb32414593a04daa7b3'\r
   end\r
-  factory :system_picture028, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_3, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9492\r
     i.md5 'dd3590336d7b69f2e85fc0c1b629d64a'\r
   end\r
-  factory :system_picture029, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_4, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 8478\r
     i.md5 'a04f3ea06f95e33358ac57645031512d'\r
   end\r
-  factory :system_picture030, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_5, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9599\r
     i.md5 'd76cf38c3de4df74ae9f8bc76911a5a9'\r
   end\r
-  factory :system_picture031, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_6, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9426\r
     i.md5 '51974b0cc1d0283be6cda04114927dc5'\r
   end\r
-  factory :system_picture032, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_7, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9588\r
     i.md5 '68af2004a103a389d2c83b2cfcd98b22'\r
   end\r
-  factory :system_picture033, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_8, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 8439\r
     i.md5 '9feac91d55ef144bad8389ee4f0751ac'\r
   end\r
-  factory :system_picture034, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_9, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 11054\r
     i.md5 '50fb44750f5506cc9ed0783d92f58f00'\r
   end\r
-  factory :system_picture035, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_10, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 10864\r
     i.md5 'bb65ca8d549401f6cc0bd6228cf6b79b'\r
   end\r
-  factory :system_picture036, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_11, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 10953\r
     i.md5 'a6d32cb9218abc587fa732a21c94883e'\r
   end\r
-  factory :system_picture037, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_12, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9534\r
     i.md5 'b0aba72c940b80e9e32b87bd48ca2635'\r
   end\r
-  factory :system_picture038, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_13, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 12008\r
     i.md5 'b886601235032b7006c23ba8bf309f74'\r
   end\r
-  factory :system_picture039, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_14, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 11751\r
     i.md5 'e98e6b7bba74f8d166f0f69303b14a19'\r
   end\r
-  factory :system_picture040, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_balloon_15, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 200\r
     i.height 200\r
     i.filesize 9609\r
     i.md5 '6756b435ba777f66dfea8e34d2e94567'\r
   end\r
-  factory :system_picture041, :class => SystemPicture do |i|\r
+  factory :system_picture_circle_icon, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 64\r
     i.height 64\r
     i.filesize 744\r
     i.md5 'ca30a88b2e03bd149860325d5f3770a7'\r
   end\r
-  factory :system_picture042, :class => SystemPicture do |i|\r
+  factory :system_picture_plain_balloon_0, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 150\r
     i.height 150\r
     i.filesize 464\r
     i.md5 '8197e42069aab7d15983425e6c121503'\r
   end\r
-  factory :system_picture043, :class => SystemPicture do |i|\r
+  factory :system_picture_plain_icon, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 64\r
     i.height 64\r
     i.filesize 492\r
     i.md5 'd6b95a015cafe40f05f0a26b4ac3c51e'\r
   end\r
-  factory :system_picture044, :class => SystemPicture do |i|\r
+  factory :system_picture_square_balloon_0, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 150\r
     i.height 150\r
     i.filesize 503\r
     i.md5 '8159134d0af4b24ef21f30048f018ab1'\r
   end\r
-  factory :system_picture045, :class => SystemPicture do |i|\r
+  factory :system_picture_square_icon, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 64\r
     i.height 64\r
     i.filesize 473\r
     i.md5 '6f683574166286bb65d8ffa25a0af17f'\r
   end\r
-  factory :system_picture046, :class => SystemPicture do |i|\r
+  factory :system_picture_test_balloon_0, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 150\r
     i.height 150\r
     i.filesize 730\r
     i.md5 '604a977cf756a4e8b2b74d05c3d647d2'\r
   end\r
-  factory :system_picture047, :class => SystemPicture do |i|\r
+  factory :system_picture_test_icon, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 64\r
     i.height 64\r
     i.filesize 608\r
     i.md5 'a33a8a440701a6d3d68bc4df4687ab6d'\r
   end\r
-  factory :system_picture048, :class => SystemPicture do |i|\r
+  factory :system_picture_writing_format_simple_format, :class => SystemPicture do |i|\r
     i.ext 'png'\r
     i.width 64\r
     i.height 64\r
index 1bf0f94..5a66f77 100644 (file)
@@ -1,17 +1,29 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :writing_format001, :class => WritingFormat do |i|\r
+  factory :writing_format_simple_format, :class => WritingFormat do |i|\r
     i.name 'simple_format@pettan.com'\r
     i.module_name 'PettanrSimpleFormat'\r
     i.caption 'シンプル'\r
-    i.system_picture_id 48\r
     i.settings '{}'\r
+    trait :with_system_picture do\r
+      after(:build) do |writing_format, evaluator|\r
+        icon = SystemPicture.find_by_md5('8d3659feb1f01fe84d1b723c8e67aaf5') || create(:system_picture_writing_format_simple_format)\r
+        writing_format.system_picture_id = icon.id\r
+      end\r
+    end\r
+    factory :writing_format_simple_format_with_system_picture, traits: [:with_system_picture]\r
   end\r
-  factory :writing_format002, :class => WritingFormat do |i|\r
-    i.name 'new'\r
+  factory :writing_format_test, :class => WritingFormat do |i|\r
+    i.name 'test@pettan.com'\r
     i.module_name 'PettanrSimpleFormat'\r
-    i.caption 'neew'\r
-    i.system_picture_id 1\r
+    i.caption 'test'\r
     i.settings '{}'\r
+    trait :with_system_picture do\r
+      after(:build) do |writing_format, evaluator|\r
+        icon = SystemPicture.find_by_md5('8d3659feb1f01fe84d1b723c8e67aaf5') || create(:system_picture_writing_format_simple_format)\r
+        writing_format.system_picture_id = icon.id\r
+      end\r
+    end\r
+    factory :writing_format_test_with_system_picture, traits: [:with_system_picture]\r
   end\r
 end\r
index fde33c1..ebaee0f 100644 (file)
@@ -9,27 +9,76 @@ describe ScrollPanel do
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @model = ScrollPanel
+    @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
+    @panel =  FactoryGirl.create :panel_hello, author: @author_yas
+    @item =  FactoryGirl.create :scroll_panel_plain, scroll: @scroll, panel: @panel
   end
   
   describe '生成メソッドに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.parent_model).to eq Scroll
+    end
+    it 'すべてのリーフを取得できる' do
+      expect(@model.destination_model).to eq Panel
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.binder_key).to eq 'scroll_id'
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.destination_key).to eq 'panel_id'
     end
     
   end
   
+  describe 'myに於いて' do
+    before do
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.binder_id).to eq @scroll.id
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.destination_id).to eq @panel.id
+    end
+  end
+  
+  describe 'cutに於いて' do
+    it 'cut' do
+      expect(@item.binder_key).to eq @model.binder_key
+    end
+    
+    it 'cut' do
+      expect(@item.destination_key).to eq @model.destination_key
+    end
+    
+  end
+  
+  describe 'playに於いて' do
+    it 'cut' do
+      expect(@model.play_list_order).to eq 'scroll_panels.t'
+    end
+    
+  end
+  
+  describe 'めんどいからチェックしない機能に於いて' do
+    it 'とりあえず呼び出すところまでは確認しておく' do
+      define_test @model
+    end
+    # max_t, find_t, 
+    # own?, visible?
+  end
+  
+    # new_t, collect_t, serial?, validate_t
+    # store, destroy_and_shorten, 
+    # insert_shift, lesser_shift, higher_shift, update_shift, rotate
 end
 
 describe SheetPanel do
@@ -39,29 +88,1186 @@ describe SheetPanel do
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @model = ScrollPanel
+    @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
+    @panel =  FactoryGirl.create :panel_hello, author: @author_yas
+    @item =  FactoryGirl.create :scroll_panel_plain, scroll: @scroll, panel: @panel
+  end
+  
+  describe '生成メソッドに於いて' do
+    before do
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.parent_model).to eq Scroll
+    end
+    it 'すべてのリーフを取得できる' do
+      expect(@model.destination_model).to eq Panel
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.binder_key).to eq 'scroll_id'
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.destination_key).to eq 'panel_id'
+    end
+    
   end
   
+  describe 'myに於いて' do
+    before do
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.binder_id).to eq @scroll.id
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.destination_id).to eq @panel.id
+    end
+  end
+  
+  describe 'cutに於いて' do
+    it 'cut' do
+      expect(@item.binder_key).to eq @model.binder_key
+    end
+    
+    it 'cut' do
+      expect(@item.destination_key).to eq @model.destination_key
+    end
+    
+  end
+  
+  describe 'playに於いて' do
+    it 'cut' do
+      expect(@model.play_list_order).to eq 'scroll_panels.t'
+    end
+    
+  end
+  
+  describe 'めんどいからチェックしない機能に於いて' do
+    it 'とりあえず呼び出すところまでは確認しておく' do
+      define_test @model
+    end
+    # max_t, find_t, 
+    # own?, visible?
+  end
+  
+    # new_t, collect_t, serial?, validate_t
+    # store, destroy_and_shorten, 
+    # insert_shift, lesser_shift, higher_shift, update_shift, rotate
 end
 
 describe ComicStory do
   include LeafMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
-    @author_yas =  @user_yas.author
+    @author_yas = @user_yas.author
+    
+    @model = ComicStory
+    @comic = FactoryGirl.create :comic_doc, author: @author_yas
+    @story = FactoryGirl.create :story_install, author: @author_yas
+    @item = FactoryGirl.create :comic_story_plain, comic: @comic, story: @story
+  end
+  
+  describe '生成メソッドに於いて' do
+    before do
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.parent_model).to eq Comic
+    end
+    it 'すべてのリーフを取得できる' do
+      expect(@model.destination_model).to eq Story
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.binder_key).to eq 'comic_id'
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.destination_key).to eq 'story_id'
+    end
+    
+  end
+  
+  describe 'myに於いて' do
+    before do
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.binder_id).to eq @comic.id
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.destination_id).to eq @story.id
+    end
+  end
+  
+  describe 'cutに於いて' do
+    it 'cut' do
+      expect(@item.binder_key).to eq @model.binder_key
+    end
+    
+    it 'cut' do
+      expect(@item.destination_key).to eq @model.destination_key
+    end
+    
+  end
+  
+  describe 'playに於いて' do
+    it 'cut' do
+      expect(@model.play_list_order).to eq 'comic_stories.t'
+    end
+    
+  end
+  
+  describe 'めんどいからチェックしない機能に於いて' do
+    it 'とりあえず呼び出すところまでは確認しておく' do
+      define_test @model
+    end
+    # max_t, find_t, 
+    # own?, visible?
   end
   
+    # new_t, collect_t, serial?, validate_t
+    # store, destroy_and_shorten, 
+    # insert_shift, lesser_shift, higher_shift, update_shift, rotate
 end
 
 describe StorySheet do
   include LeafMacros
   before do
+    @admin = FactoryGirl.create :admin
+    @user_yas = FactoryGirl.create :user_yas_with_owner
+    @user_rom = FactoryGirl.create :user_rom
+    @author_yas =  @user_yas.author
+    
+    @model = StorySheet
+    @story = FactoryGirl.create :story_install, author: @author_yas
+    @sheet = FactoryGirl.create :sheet_install_a, author: @author_yas
+    @item = FactoryGirl.create :story_sheet_plain, story: @story, sheet: @sheet
+  end
+  
+  describe '生成メソッドに於いて' do
+    before do
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.parent_model).to eq Story
+    end
+    it 'すべてのリーフを取得できる' do
+      expect(@model.destination_model).to eq Sheet
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.binder_key).to eq 'story_id'
+    end
+    
+    it 'ぶら下がるそれぞれのリーフを取得できる' do
+      expect(@model.destination_key).to eq 'sheet_id'
+    end
+    
+  end
+  
+  describe 'myに於いて' do
+    before do
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.binder_id).to eq @story.id
+    end
+    
+    it '名前の活用に於いて' do
+      expect(@item.destination_id).to eq @sheet.id
+    end
+  end
+  
+  describe 'cutに於いて' do
+    it 'cut' do
+      expect(@item.binder_key).to eq @model.binder_key
+    end
+    
+    it 'cut' do
+      expect(@item.destination_key).to eq @model.destination_key
+    end
+    
+  end
+  
+  describe 'playに於いて' do
+    it 'cut' do
+      expect(@model.play_list_order).to eq 'story_sheets.t'
+    end
+    
+  end
+  
+  describe 'めんどいからチェックしない機能に於いて' do
+    it 'とりあえず呼び出すところまでは確認しておく' do
+      define_test @model
+    end
+    # max_t, find_t, 
+    # own?, visible?
+  end
+  
+    # new_t, collect_t, serial?, validate_t
+    # store, destroy_and_shorten, 
+    # insert_shift, lesser_shift, higher_shift, update_shift, rotate
+end
+
+# 
+describe ScrollPanel do
+  include LeafMacros
+  before do
     @admin =FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @model = ScrollPanel
+  end
+  
+  describe 'new_tに於いて' do
+    before do
+      @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        expect(@model.new_t(@scroll.id)).to eq 0
+      end
+      
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        expect(@model.new_t(@scroll.id)).to eq 1
+      end
+      
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
+        expect(@model.new_t(@scroll.id)).to eq 3
+      end
+      
+    end
+    
+  end
+  
+  describe 'collect_tに於いて' do
+    before do
+      @dummy =  FactoryGirl.create :scroll_great_with_scroll_panels, author: @author_yas
+      @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        expect(@model.collect_t(@scroll.id)).to be_empty
+      end
+      
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        expect(@model.collect_t(@scroll.id)).to eq [0]
+      end
+      
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
+        expect(@model.collect_t(@scroll.id)).to eq [0, 1, 2]
+      end
+      
+    end
+    
   end
   
+  describe 'tチェックに於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it 't収集を依頼している' do
+        SheetPanel.should_receive(:collect_t).with(any_args).exactly(1)
+        SheetPanel.stub(:collect_t).with(any_args).and_return([])
+        SheetPanel.stub(:serial?).with(any_args).and_return(true)
+        r = SheetPanel.validate_t @item
+      end
+      it '収集したtをシリアライズチェック依頼している' do
+        SheetPanel.stub(:collect_t).with(any_args).and_return([])
+        SheetPanel.should_receive(:serial?).with(any_args).exactly(1)
+        SheetPanel.stub(:serial?).with(any_args).and_return(true)
+        r = SheetPanel.validate_t @item
+      end
+    end
+    #実データでチェック
+    #依頼チェックだけでは不安なので最低限のチェックを
+    context '新規のとき' do
+      it '一件だけで正常通過している' do
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        r = SheetPanel.validate_t @item
+        r.should be_true 
+      end
+    end
+    context '既存のとき' do
+      it '2件目を作っても正常通過している' do
+        @item = FactoryGirl.create :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        @item2 = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
+        r = SheetPanel.validate_t @item2
+        r.should be_true 
+      end
+    end
+  end
+  describe '挿入シフトに於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+    end
+    context '依頼チェック' do
+      #テーブルが空で0に挿入
+      it 'Updateを依頼している' do
+        SheetPanel.stub(:update_all).with(any_args)
+        SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
+        @item = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item.insert_shift
+      end
+    end
+    context 'テーブルに1件(t:0)で0に挿入したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存の行を1にシフトしている' do
+        @item2.insert_shift
+        l = SheetPanel.find :all
+        l.first.t.should eq 1
+      end
+      it 'これから挿入するt(0)が欠番になっている' do
+        @item2.insert_shift
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.include?(0).should_not be_true
+      end
+    end
+    context 'テーブルに2件(t:0,1)で1に挿入したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
+        @item3.insert_shift
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 2]
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)で2に挿入したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
+        @item6.insert_shift
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 1, 3, 4, 5]
+      end
+    end
+    context '先ほどのケース+他の用紙1件で挿入したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
+        @item6.insert_shift
+        l = SheetPanel.find(:all, :conditions => ['sheet_id = ?', @sheet.id]).map {|s| s.t }
+        l.sort.should eq [0, 1, 3, 4, 5]
+      end
+      it '他の用紙に影響がない' do
+        ot = @itemc2.t
+        @item6.insert_shift
+        @itemc2.reload
+        @itemc2.t.should eq ot
+      end
+    end
+  end
+  describe '少ない方に移動に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+    end
+    context '依頼チェック' do
+      it 'Updateを依頼している' do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.stub(:update_all).with(any_args)
+        SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
+        ot = @item2.t
+        @item2.t = 0
+        @item2.lesser_shift ot
+      end
+    end
+    context 'テーブルに2件(t:0,1)で1を0に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 0
+      end
+      it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item2.lesser_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [1, 1]
+      end
+      it '既存のt0を1にシフトしている' do
+        @item2.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 1
+      end
+    end
+    context 'テーブルに3件(t:0,1,2)で2を1に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item3.t
+        @item3.t = 1
+      end
+      it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item3.lesser_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 2, 2]
+      end
+      it '既存のt1を2にシフトしている' do
+        @item3.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)で3を1に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it 'これから挿入するt(1)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item4.lesser_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 2, 3, 3, 4]
+      end
+      it '既存のt0には変化がない' do
+        @item4.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item4.lesser_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を2にシフトしている' do
+        @item4.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
+      end
+      it '既存のt2を3にシフトしている' do
+        @item4.lesser_shift @ot
+        @item3.reload
+        @item3.t.should eq 3
+      end
+    end
+    context '先ほどのケース+他の用紙1件で挿入したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it 'これから挿入するt(1)が欠番になっている' do
+        @item4.lesser_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 0, 2, 3, 3, 4]
+      end
+      it '既存のt0には変化がない' do
+        @item4.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item4.lesser_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を2にシフトしている' do
+        @item4.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
+      end
+      it '既存のt2を3にシフトしている' do
+        @item4.lesser_shift @ot
+        @item3.reload
+        @item3.t.should eq 3
+      end
+      it '他の用紙に影響がない' do
+        @item4.lesser_shift @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    #例外ケース。
+    #負のときは0として正常扱い
+    context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = -1
+      end
+      it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item2.lesser_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [1, 1]
+      end
+      it '既存のt0を1にシフトしている' do
+        @item2.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 1
+      end
+      it '既存のt1は0に補正されている' do
+        @item2.lesser_shift @ot
+        @item2.t.should eq 0
+      end
+    end
+  end
+  describe '大きい方に移動に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+    end
+    context '依頼チェック' do
+      it 'Updateを依頼している' do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.stub(:update_all).with(any_args)
+        SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
+        ot = @item.t
+        @item.t = 1
+        @item.higher_shift ot
+      end
+    end
+    context 'テーブルに2件(t:0,1)で0を1に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 1
+      end
+      it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item.higher_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 0]
+      end
+      it '既存のt1を0にシフトしている' do
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
+      end
+    end
+    context 'テーブルに3件(t:0,1,2)で0を1に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 1
+      end
+      it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item.higher_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 0, 2]
+      end
+      it '既存のt1を0にシフトしている' do
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)で1を3に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
+      end
+      it 'これから挿入するt(3)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item2.higher_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 1, 1, 2, 4]
+      end
+      it '既存のt0には変化がない' do
+        @item2.higher_shift @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item2.higher_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt2を1にシフトしている' do
+        @item2.higher_shift @ot
+        @item3.reload
+        @item3.t.should eq 1
+      end
+      it '既存のt3を2にシフトしている' do
+        @item2.higher_shift @ot
+        @item4.reload
+        @item4.t.should eq 2
+      end
+    end
+    context '先ほどのケース+他の用紙1件で挿入したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
+      end
+      it 'これから挿入するt(3)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item2.higher_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 0, 1, 1, 2, 4]
+      end
+      it '既存のt0には変化がない' do
+        @item2.higher_shift @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item2.higher_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt2を1にシフトしている' do
+        @item2.higher_shift @ot
+        @item3.reload
+        @item3.t.should eq 1
+      end
+      it '既存のt3を2にシフトしている' do
+        @item2.higher_shift @ot
+        @item4.reload
+        @item4.t.should eq 2
+      end
+      it '他の用紙に影響がない' do
+        @item2.higher_shift @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    #例外ケース。
+    #max超えたときはmaxとして正常扱い
+    context 'テーブルに2件(t:0,1)で0を2に移動したとき' do
+      before do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 2
+      end
+      it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
+        #移動させたい行はそのまま残る
+        @item.higher_shift @ot
+        l = SheetPanel.find(:all).map {|s| s.t }
+        l.sort.should eq [0, 0]
+      end
+      it '既存のt1を0にシフトしている' do
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
+      end
+      it '既存のt0は1に補正されている' do
+        @item.higher_shift @ot
+        @item.t.should eq 1
+      end
+    end
+  end
+  describe '入れ替えに於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context '新tが旧tより小さいとき' do
+      it '少ない方に移動を依頼している' do
+        SheetPanel.any_instance.stub(:lesser_shift).with(any_args)
+        SheetPanel.any_instance.should_receive(:lesser_shift).with(any_args).exactly(1)
+        ot = @item2.t
+        @item2.t = 0
+        @item2.update_shift ot
+      end
+    end
+    context '新tが旧tより大きいとき' do
+      it '大きい方に移動を依頼している' do
+        SheetPanel.any_instance.stub(:higher_shift).with(any_args)
+        SheetPanel.any_instance.should_receive(:higher_shift).with(any_args).exactly(1)
+        ot = @item.t
+        @item.t = 1
+        @item.update_shift ot
+      end
+    end
+  end
+  describe '順序入れ替えに於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+    end
+    context 'オブジェクトが新規でtが空のとき' do
+      it '末尾追加としてtを補充依頼している' do
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.stub(:new_t).with(any_args).and_return(0)
+        SheetPanel.should_receive(:new_t).with(any_args).exactly(1)
+        @item.t = nil
+        r = @item.rotate
+      end
+    end
+    context 'オブジェクトが新規でtが設定されているとき' do
+      it '挿入追加として挿入シフトを依頼している' do
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.any_instance.stub(:insert_shift).with(any_args)
+        SheetPanel.any_instance.should_receive(:insert_shift).with(any_args).exactly(1)
+        @item.t = 0
+        r = @item.rotate
+      end
+    end
+    context 'オブジェクトが新規でなくtが設定されているとき' do
+      it 'コマ移動として入れ替えを依頼している' do
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.any_instance.stub(:update_shift).with(any_args)
+        SheetPanel.any_instance.should_receive(:update_shift).with(1).exactly(1)
+        @item2.t = 0
+        r = @item.rotate 1
+      end
+    end
+    context 'オブジェクトが新規でなくtが空のとき' do
+      it '入れ替えもシフトもせず、tを空のままにしている' do
+        #結果、tに欠番が生じてシリアライズチェックでひっかかる
+      end
+    end
+  end
+  describe '保存に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it '編集許可チェックを依頼している' do
+        SheetPanel.any_instance.stub(:allow?).with(any_args).and_return(true)
+        SheetPanel.any_instance.should_receive(:allow?).with(any_args).exactly(1)
+        r = @item.store
+      end
+      it '順序入れ替えを依頼している' do
+        SheetPanel.any_instance.stub(:rotate).with(any_args).and_return(0)
+        SheetPanel.any_instance.should_receive(:rotate).with(any_args).exactly(1)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        r = @item.store 
+      end
+      it '保存を依頼している' do
+        SheetPanel.stub(:new_t).with(any_args).and_return(0)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.any_instance.should_receive(:save).with(any_args).exactly(1)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        r = @item.store
+      end
+      it 'tのシリアライズチェックを依頼している' do
+        SheetPanel.stub(:new_t).with(any_args).and_return(0)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        SheetPanel.should_receive(:validate_t).with(any_args).exactly(1)
+        r = @item.store
+      end
+    end
+    #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のt0には変化がない' do
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt1には変化がない' do
+        @item6.store
+        @item2.reload
+        @item2.t.should eq 1
+      end
+      it '既存のt2を3にシフトしている' do
+        @item6.store
+        @item3.reload
+        @item3.t.should eq 3
+      end
+      it '既存のt3を4にシフトしている' do
+        @item6.store
+        @item4.reload
+        @item4.t.should eq 4
+      end
+      it '既存のt5を5にシフトしている' do
+        @item6.store
+        @item5.reload
+        @item5.t.should eq 5
+      end
+      it '新規のt2が作成されている' do
+        @item6.store
+        @item6.reload
+        @item6.t.should eq 2
+      end
+      it '他の用紙に影響がない' do
+        @ot = @itemc2.t
+        @item6.store
+        @itemc2.reload
+        @itemc2.t.should eq @ot
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で3を1に移動したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it '既存のt0には変化がない' do
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item4.store @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を2にシフトしている' do
+        @item4.store @ot
+        @item2.reload
+        @item2.t.should eq 2
+      end
+      it '既存のt2を3にシフトしている' do
+        @item4.store @ot
+        @item3.reload
+        @item3.t.should eq 3
+      end
+      it '既存のt3を1にシフトしている' do
+        @item4.store @ot
+        @item4.reload
+        @item4.t.should eq 1
+      end
+      it '他の用紙に影響がない' do
+        @item4.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で1を3に移動したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
+      end
+      it '既存のt0には変化がない' do
+        @item2.store @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item2.store @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を3にシフトしている' do
+        @item2.store @ot
+        @item2.reload
+        @item2.t.should eq 3
+      end
+      it '既存のt2を1にシフトしている' do
+        @item2.store @ot
+        @item3.reload
+        @item3.t.should eq 1
+      end
+      it '既存のt3を2にシフトしている' do
+        @item2.store @ot
+        @item4.reload
+        @item4.t.should eq 2
+      end
+      it '他の用紙に影響がない' do
+        @item2.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    #ロールバックテスト。入れ替えが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したが保存に失敗したとき' do
+      before do
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(false)
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のtに変化がない' do
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+      it 'falseを返す' do
+        r = @item6.store
+        r.should be_false
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で3を1に移動したがシリアルチェックに失敗したとき' do
+      before do
+        SheetPanel.stub(:validate_t).with(any_args).and_return(false)
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it '既存のtに変化がない' do
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+      it 'falseを返す' do
+        r = @item4.store @ot
+        r.should be_false
+      end
+      it 'tにエラーメッセージが入っている' do
+        @item4.store @ot
+        @item4.errors[:t].should_not be_empty
+        @item4.valid?.should be_true
+      end
+    end
+    context '編集不可だったとき' do
+      before do
+        @item = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.any_instance.stub(:allow?).and_return(false)
+      end
+      it '403Forbidden例外を返す' do
+        lambda{
+          @item.store
+        }.should raise_error(ActiveRecord::Forbidden)
+      end
+    end
+  end
+  describe '切り詰め処理つき削除に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it '削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it 'Trueを返す' do
+        r = @item.destroy_and_shorten
+        r.should be_true 
+      end
+    end
+    context '削除に失敗したとき' do
+      before do
+        SheetPanel.any_instance.stub(:destroy).and_return(false)
+      end
+      it 'ロールバックされる' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should_not change(SheetPanel, :count )
+      end
+      it 'Falseを返す' do
+        r = @item.destroy_and_shorten
+        r.should be_false
+      end
+    end
+    #連携テスト。切り詰めが直接DBをいじる
+    context '2件で先頭を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '先頭は削除される' do
+        @item.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '2件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
+      end
+    end
+    context '3件で先頭を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '先頭は削除される' do
+        @item.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '2件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
+      end
+      it '3件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item3.reload
+        @item3.t.should eq 1
+      end
+    end
+    context '5件で3件目を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item3.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '1件目は変化がない' do
+        @item3.destroy_and_shorten
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '2件目は変化がない' do
+        @item3.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 1
+      end
+      it '3件目は削除される' do
+        @item3.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item3.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '4件目は前に詰められる' do
+        @item3.destroy_and_shorten
+        @item4.reload
+        @item4.t.should eq 2
+      end
+      it '5件目は前に詰められる' do
+        @item3.destroy_and_shorten
+        @item5.reload
+        @item5.t.should eq 3
+      end
+    end
+    #ロールバックテスト。切り詰めが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
+  end
 end
 
index 34354e4..6a974b6 100644 (file)
@@ -13,26 +13,14 @@ describe Sheet do
   
   describe '生成メソッドに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
-    end
-    
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
-    end
-    
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+      @item =  FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'copy_attributesに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
+      @item =  FactoryGirl.create :sheet_install_a_with_sheet_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
@@ -52,29 +40,493 @@ describe Panel do
   
   describe '生成メソッドに於いて' do
     before do
+      @item =  FactoryGirl.create :panel_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ComicStory]
+  end
+  
+end
+# 
+describe ScrollPanel do
+  include LeafMacros
+  before do
+    @admin =FactoryGirl.create :admin
+    @user_yas = FactoryGirl.create :user_yas_with_owner
+    @user_rom = FactoryGirl.create :user_rom
+    @author_yas =  @user_yas.author
+    
+    @model = ScrollPanel
+  end
+  
+  describe 'new_tに於いて' do
+    before do
+      @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
+    end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        expect(@model.new_t(@scroll.id)).to eq 0
       end
+      
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ComicStory]
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        expect(@model.new_t(@scroll.id)).to eq 1
+      end
+      
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
+        expect(@model.new_t(@scroll.id)).to eq 3
       end
+      
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'collect_tに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
+      @dummy =  FactoryGirl.create :scroll_great_with_scroll_panels, author: @author_yas
+      @scroll =  FactoryGirl.create :scroll_hello, author: @author_yas
     end
     
-    it 'ブーストメッセージをリーフに伝搬する' do
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        expect(@model.collect_t(@scroll.id)).to be_empty
+      end
+      
     end
+    
+    context 'オーソドックスなデータのとき' do
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        expect(@model.collect_t(@scroll.id)).to eq [0]
+      end
+      
+      it 'cut' do
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 1, t: 0, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 2, t: 1, scroll: @scroll, panel: @panel
+        @item =  FactoryGirl.create :scroll_panel_plain, z: 3, t: 2, scroll: @scroll, panel: @panel
+        expect(@model.collect_t(@scroll.id)).to eq [0, 1, 2]
+      end
+      
+    end
+    
   end
   
+  describe 'tチェックに於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it 't収集を依頼している' do
+        SheetPanel.should_receive(:collect_t).with(any_args).exactly(1)
+        SheetPanel.stub(:collect_t).with(any_args).and_return([])
+        SheetPanel.stub(:serial?).with(any_args).and_return(true)
+        r = SheetPanel.validate_t @item
+      end
+      it '収集したtをシリアライズチェック依頼している' do
+        SheetPanel.stub(:collect_t).with(any_args).and_return([])
+        SheetPanel.should_receive(:serial?).with(any_args).exactly(1)
+        SheetPanel.stub(:serial?).with(any_args).and_return(true)
+        r = SheetPanel.validate_t @item
+      end
+    end
+    #実データでチェック
+    #依頼チェックだけでは不安なので最低限のチェックを
+    context '新規のとき' do
+      it '一件だけで正常通過している' do
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        r = SheetPanel.validate_t @item
+        r.should be_true 
+      end
+    end
+    context '既存のとき' do
+      it '2件目を作っても正常通過している' do
+        @item = FactoryGirl.create :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        @item2 = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
+        r = SheetPanel.validate_t @item2
+        r.should be_true 
+      end
+    end
+  end
+  describe '保存に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it '編集許可チェックを依頼している' do
+        SheetPanel.any_instance.stub(:allow?).with(any_args).and_return(true)
+        SheetPanel.any_instance.should_receive(:allow?).with(any_args).exactly(1)
+        r = @item.store
+      end
+      it '順序入れ替えを依頼している' do
+        SheetPanel.any_instance.stub(:rotate).with(any_args).and_return(0)
+        SheetPanel.any_instance.should_receive(:rotate).with(any_args).exactly(1)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        r = @item.store 
+      end
+      it '保存を依頼している' do
+        SheetPanel.stub(:new_t).with(any_args).and_return(0)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.any_instance.should_receive(:save).with(any_args).exactly(1)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        r = @item.store
+      end
+      it 'tのシリアライズチェックを依頼している' do
+        SheetPanel.stub(:new_t).with(any_args).and_return(0)
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
+        SheetPanel.stub(:validate_t).with(any_args).and_return(true)
+        SheetPanel.should_receive(:validate_t).with(any_args).exactly(1)
+        r = @item.store
+      end
+    end
+    #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のt0には変化がない' do
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt1には変化がない' do
+        @item6.store
+        @item2.reload
+        @item2.t.should eq 1
+      end
+      it '既存のt2を3にシフトしている' do
+        @item6.store
+        @item3.reload
+        @item3.t.should eq 3
+      end
+      it '既存のt3を4にシフトしている' do
+        @item6.store
+        @item4.reload
+        @item4.t.should eq 4
+      end
+      it '既存のt5を5にシフトしている' do
+        @item6.store
+        @item5.reload
+        @item5.t.should eq 5
+      end
+      it '新規のt2が作成されている' do
+        @item6.store
+        @item6.reload
+        @item6.t.should eq 2
+      end
+      it '他の用紙に影響がない' do
+        @ot = @itemc2.t
+        @item6.store
+        @itemc2.reload
+        @itemc2.t.should eq @ot
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で3を1に移動したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it '既存のt0には変化がない' do
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item4.store @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を2にシフトしている' do
+        @item4.store @ot
+        @item2.reload
+        @item2.t.should eq 2
+      end
+      it '既存のt2を3にシフトしている' do
+        @item4.store @ot
+        @item3.reload
+        @item3.t.should eq 3
+      end
+      it '既存のt3を1にシフトしている' do
+        @item4.store @ot
+        @item4.reload
+        @item4.t.should eq 1
+      end
+      it '他の用紙に影響がない' do
+        @item4.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で1を3に移動したとき' do
+      before do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
+      end
+      it '既存のt0には変化がない' do
+        @item2.store @ot
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '既存のt4には変化がない' do
+        @item2.store @ot
+        @item5.reload
+        @item5.t.should eq 4
+      end
+      it '既存のt1を3にシフトしている' do
+        @item2.store @ot
+        @item2.reload
+        @item2.t.should eq 3
+      end
+      it '既存のt2を1にシフトしている' do
+        @item2.store @ot
+        @item3.reload
+        @item3.t.should eq 1
+      end
+      it '既存のt3を2にシフトしている' do
+        @item2.store @ot
+        @item4.reload
+        @item4.t.should eq 2
+      end
+      it '他の用紙に影響がない' do
+        @item2.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+    end
+    #ロールバックテスト。入れ替えが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したが保存に失敗したとき' do
+      before do
+        SheetPanel.any_instance.stub(:save).with(any_args).and_return(false)
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '既存のtに変化がない' do
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+      it 'falseを返す' do
+        r = @item6.store
+        r.should be_false
+      end
+    end
+    context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で3を1に移動したがシリアルチェックに失敗したとき' do
+      before do
+        SheetPanel.stub(:validate_t).with(any_args).and_return(false)
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
+      end
+      it '既存のtに変化がない' do
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
+      end
+      it 'falseを返す' do
+        r = @item4.store @ot
+        r.should be_false
+      end
+      it 'tにエラーメッセージが入っている' do
+        @item4.store @ot
+        @item4.errors[:t].should_not be_empty
+        @item4.valid?.should be_true
+      end
+    end
+    context '編集不可だったとき' do
+      before do
+        @item = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        SheetPanel.any_instance.stub(:allow?).and_return(false)
+      end
+      it '403Forbidden例外を返す' do
+        lambda{
+          @item.store
+        }.should raise_error(ActiveRecord::Forbidden)
+      end
+    end
+  end
+  describe '切り詰め処理つき削除に於いて' do
+    before do
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+    end
+    context 'つつがなく終わるとき' do
+      it '削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it 'Trueを返す' do
+        r = @item.destroy_and_shorten
+        r.should be_true 
+      end
+    end
+    context '削除に失敗したとき' do
+      before do
+        SheetPanel.any_instance.stub(:destroy).and_return(false)
+      end
+      it 'ロールバックされる' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should_not change(SheetPanel, :count )
+      end
+      it 'Falseを返す' do
+        r = @item.destroy_and_shorten
+        r.should be_false
+      end
+    end
+    #連携テスト。切り詰めが直接DBをいじる
+    context '2件で先頭を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '先頭は削除される' do
+        @item.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '2件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
+      end
+    end
+    context '3件で先頭を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '先頭は削除される' do
+        @item.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '2件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
+      end
+      it '3件目は前に詰められる' do
+        @item.destroy_and_shorten
+        @item3.reload
+        @item3.t.should eq 1
+      end
+    end
+    context '5件で3件目を削除したとき' do
+      before do
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      end
+      it '行が削除される' do
+        lambda{
+          @item3.destroy_and_shorten
+        }.should change(SheetPanel, :count ).by(-1)
+      end
+      it '1件目は変化がない' do
+        @item3.destroy_and_shorten
+        @item.reload
+        @item.t.should eq 0
+      end
+      it '2件目は変化がない' do
+        @item3.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 1
+      end
+      it '3件目は削除される' do
+        @item3.destroy_and_shorten
+        lambda{
+          SheetPanel.find @item3.id
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+      it '4件目は前に詰められる' do
+        @item3.destroy_and_shorten
+        @item4.reload
+        @item4.t.should eq 2
+      end
+      it '5件目は前に詰められる' do
+        @item3.destroy_and_shorten
+        @item5.reload
+        @item5.t.should eq 3
+      end
+    end
+    #ロールバックテスト。切り詰めが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
+  end
 end
+
index 013e817..82254f8 100644 (file)
@@ -5,37 +5,55 @@ require 'spec_helper'
 describe License do
   include SystemResourceMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
-    @author_yas =  @user_yas.author
+    @author_yas = @user_yas.author
+    
+    @model = License
+    @source_url_btn = FactoryGirl.create :system_picture_source_url_btn
+    @source_url_off_btn = FactoryGirl.create :system_picture_source_url_off_btn
+    @license_group = FactoryGirl.create :license_group_pc
+    @item = FactoryGirl.build :license_pc_by_with_system_picture, license_group: @license_group
+    @item.boosts 'post'
+    @item.save!
+    @item = FactoryGirl.build :license_pc_bync_with_system_picture, license_group: @license_group
+    @item.boosts 'post'
+    @item.save!
   end
   
-  describe '生成メソッドに於いて' do
+  describe 'editに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@admin]
+      allow_any_instance_of(@model).to receive(:own?).and_return(true)
+      expect(@model.edit(@item.id, @operators)).to eq @item
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@user_yas, @author_yas]
+      allow_any_instance_of(@model).to receive(:own?).and_return(false)
+      expect {@model.edit(@item.id, @operators)}.to raise_error(ActiveRecord::Forbidden)
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'own?に於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@admin]
+      allow_any_instance_of(Operator).to receive(:admin?).and_return(true)
+      expect(@item.own?(@operators)).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@user_yas, @author_yas]
+      allow_any_instance_of(Operator).to receive(:admin?).and_return(false)
+      expect(@item.own?(@operators)).to be false
     end
   end
   
@@ -44,36 +62,47 @@ end
 describe SystemPicture do
   include SystemResourceMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
-    @author_yas =  @user_yas.author
+    @author_yas = @user_yas.author
+    
+    @model = SystemPicture
+    @item = FactoryGirl.create :system_picture_license_pc_by
   end
   
-  describe '生成メソッドに於いて' do
+  describe 'editに於いて' do
     before do
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ComicStory]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@admin]
+      allow_any_instance_of(@model).to receive(:own?).and_return(true)
+      expect(@model.edit(@item.id, @operators)).to eq @item
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ComicStory]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@user_yas, @author_yas]
+      allow_any_instance_of(@model).to receive(:own?).and_return(false)
+      expect {@model.edit(@item.id, @operators)}.to raise_error(ActiveRecord::Forbidden)
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'own?に於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@admin]
+      allow_any_instance_of(Operator).to receive(:admin?).and_return(true)
+      expect(@item.own?(@operators)).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      @operators = Operator.new [@user_yas, @author_yas]
+      allow_any_instance_of(Operator).to receive(:admin?).and_return(false)
+      expect(@item.own?(@operators)).to be false
     end
   end
   
index 7c51e06..9ec76e4 100644 (file)
@@ -9,33 +9,74 @@ describe SpeechBalloonTemplate do
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @circle = FactoryGirl.create :speech_balloon_template_circle_with_system_picture
+    @plain = FactoryGirl.create :speech_balloon_template_plain_with_system_picture
+    @square = FactoryGirl.create :speech_balloon_template_square_with_system_picture
+    @test = FactoryGirl.create :speech_balloon_template_test_with_system_picture
   end
   
   describe '生成メソッドに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
+  end
+  
+  describe 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(SpeechBalloonTemplate.enable_list).to_not be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(SpeechBalloonTemplate).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list).to be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(@circle).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list.size).to eq 3
+    end
+    
+  end
+  
+  describe 'enable?に於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(SpeechBalloonTemplate).to receive(:template_manifest).and_return(nil)
+      expect(@circle.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.enable?).to be true
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
     end
     
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.template_module).to eq CircleSpeechBalloon
+      expect(@square.template_module).to eq SquareSpeechBalloon
+    end
   end
   
-  describe 'boostに於いて' do
+  describe 'template_path_nameに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.template_path_name).to eq 'circle_speech_balloon'
+      expect(@square.template_path_name).to eq 'square_speech_balloon'
     end
   end
   
@@ -44,37 +85,76 @@ end
 describe LicenseGroup do
   include TemplateMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @cc = FactoryGirl.create :license_group_cc
+    @pc = FactoryGirl.create :license_group_pc
+    @test = FactoryGirl.create :license_group_test
   end
   
   describe '生成メソッドに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
+  end
+  
+  describe 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(LicenseGroup.enable_list).to_not be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(LicenseGroup).to receive(:enable?).and_return(false)
+      expect(LicenseGroup.enable_list).to be_empty
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(LicenseGroup.enable_list.size).to eq 2
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'enable?に於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      allow(LicenseGroup).to receive(:template_manifest).and_return(nil)
+      expect(@cc.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.enable?).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.template_module).to eq PettanrCreativeCommonsV30Licenses
+      expect(@pc.template_module).to eq PettanrPettanCommonsV01Licenses
+    end
+  end
+  
+  describe 'template_path_nameに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.template_path_name).to eq 'pettanr_creative_commons_v30_licenses'
+      expect(@pc.template_path_name).to eq 'pettanr_pettan_commons_v01_licenses'
     end
   end
   
@@ -83,36 +163,75 @@ end
 describe WritingFormat do
   include TemplateMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @test = FactoryGirl.create :writing_format_test_with_system_picture
+    @simple = FactoryGirl.create :writing_format_simple_format_with_system_picture
   end
   
   describe '生成メソッドに於いて' do
     before do
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ComicStory]
-      end
+  end
+  
+  describe 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(WritingFormat.enable_list).to_not be_empty
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ComicStory]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(WritingFormat).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list).to be_empty
     end
     
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(@simple).to receive(:enable?).and_return(false)
+      expect(WritingFormat.enable_list.size).to eq 2
+    end
+    
+  end
+  
+  describe 'enable?に於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(WritingFormat).to receive(:template_manifest).and_return(nil)
+      expect(@simple.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.enable?).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(WritingFormat).to receive(:module_name).and_return('excluded')
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.template_module).to eq PettanrSimpleFormat
+    end
   end
   
-  describe 'boostに於いて' do
+  describe 'template_path_nameに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.template_path_name).to eq 'pettanr_simple_format'
     end
   end
   
index f2b8b79..90ea3ae 100644 (file)
@@ -119,21 +119,8 @@ module BinderMacros
 end\r
 \r
 module LeafMacros\r
-  # ぶら下がるそれぞれのリーフを取得\r
-  def define_leaf_items? item, leaf_models\r
-    expect(item.respond_to?(:leaf_items)).to be true\r
-    leaf_models.each do |model|\r
-      expect(item.leaf_items(model)).to_not be_empty\r
-      expect(item.leaf_items(model).first.class).to eq model\r
-    end\r
-  end\r
-  \r
-  def define_leafs_items? item, leaf_models\r
-    expect(item.respond_to?(:leafs_items)).to be true\r
-    expect(item.leafs_items).to_not be_empty\r
-    item.leafs_items.map {|i| i.class }.each do |model|\r
-      expect(leaf_models).to include model\r
-    end\r
+  def define_test item\r
+    expect {expect(item.new_t(0))}.not_to raise_error\r
   end\r
   \r
 end\r