OSDN Git Service

t#32313:add sheet copy
[pettanr/pettanr.git] / spec / models / license_group_spec.rb
index 181cb7c..482ecc6 100644 (file)
@@ -4,6 +4,7 @@ require 'spec_helper'
 
 describe LicenseGroup do
   before do
+    SpeechBalloonTemplate.delete_all
     #テストデータを用意してね
     @f = Rails.root + 'spec/json/license_group.json'
     @t = File.open(@f, 'r').read
@@ -83,6 +84,48 @@ describe LicenseGroup do
     end
   end
   
+  describe '文字コード検証に於いて' do
+    before do
+      @lg = FactoryGirl.build :license_group
+    end
+    
+    context 'nameを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @lg.name = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @lg.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'classnameを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @lg.classname = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @lg.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'captionを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @lg.caption = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @lg.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'urlを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @lg.url = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @lg.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+  end
+  
   describe 'デフォルト値補充に於いて' do
     it 'defined' do
       @lg = FactoryGirl.build :license_group, :name => "1"
@@ -105,13 +148,13 @@ describe LicenseGroup do
     before do
       @lg = FactoryGirl.create :license_group, :name => "1"
     end
-    context 'つつがなく終わるとき' do\r
-      it '一覧取得オプションを利用している' do\r
-        LicenseGroup.stub(:list_opt).with(any_args).and_return({})\r
-        LicenseGroup.should_receive(:list_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '一覧取得オプションを利用している' do
+        LicenseGroup.stub(:list_opt).with(any_args).and_return({})
+        LicenseGroup.should_receive(:list_opt).with(any_args).exactly(1)
         r = LicenseGroup.list
-      end\r
-    end\r
+      end
+    end
     it 'リストを返す' do
       l = LicenseGroup.list
       l.should eq [@lg]
@@ -142,15 +185,15 @@ describe LicenseGroup do
       @lg = FactoryGirl.create :license_group
       @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
       @user = FactoryGirl.create( :user_yas)
-      @author = @user.author
+      @author = FactoryGirl.create :author, :user_id => @user.id
       @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
-      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
-      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
-      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
-      @sbt = FactoryGirl.create :speech_balloon_template\r
-      @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @sbt = FactoryGirl.create :speech_balloon_template
+      @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
       @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
     end
     it 'ライセンスを含んでいる' do
       r = LicenseGroup.list.to_json LicenseGroup.list_json_opt
@@ -164,24 +207,24 @@ describe LicenseGroup do
     before do
       @lg = FactoryGirl.create :license_group
     end
-    context 'つつがなく終わるとき' do\r
-      it '単体取得オプションを利用している' do\r
-        LicenseGroup.stub(:show_opt).with(any_args).and_return({})\r
-        LicenseGroup.should_receive(:show_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '単体取得オプションを利用している' do
+        LicenseGroup.stub(:show_opt).with(any_args).and_return({})
+        LicenseGroup.should_receive(:show_opt).with(any_args).exactly(1)
         r = LicenseGroup.show @lg.id
-      end\r
-    end\r
+      end
+    end
     it '指定のコマを返す' do
       l = LicenseGroup.show @lg.id
       l.should eq @lg
     end
-    context '存在しないライセンスグループを開こうとしたとき' do\r
-      it '404RecordNotFound例外を返す' do\r
-        lambda{\r
-          LicenseGroup.show 110\r
-        }.should raise_error(ActiveRecord::RecordNotFound)\r
-      end\r
-    end\r
+    context '存在しないライセンスグループを開こうとしたとき' do
+      it '404RecordNotFound例外を返す' do
+        lambda{
+          LicenseGroup.show 110
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+    end
   end
   describe '単体取得オプションに於いて' do
     it 'includeキーを含んでいる' do
@@ -203,15 +246,15 @@ describe LicenseGroup do
       @lg = FactoryGirl.create :license_group
       @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
       @user = FactoryGirl.create( :user_yas)
-      @author = @user.author
+      @author = FactoryGirl.create :author, :user_id => @user.id
       @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
-      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
-      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
-      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
-      @sbt = FactoryGirl.create :speech_balloon_template\r
-      @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @sbt = FactoryGirl.create :speech_balloon_template
+      @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
       @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
     end
     it 'ライセンスを含んでいる' do
       r = LicenseGroup.show(@lg.id).to_json LicenseGroup.show_json_opt