OSDN Git Service

t#31085:raise err when input invalid encoding string
[pettanr/pettanr.git] / spec / models / license_spec.rb
index 4c94fd1..0889793 100644 (file)
@@ -95,6 +95,60 @@ describe License do
     end
   end
   
+  describe '文字コード検証に於いて' do
+    before do
+      @sp = FactoryGirl.create :system_picture
+      @lg = FactoryGirl.create :license_group
+      @l = FactoryGirl.build :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+    end
+    
+    context 'nameを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @l.name = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @l.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'captionを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @l.caption = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @l.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'urlを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @l.url = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @l.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'settingsを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @l.settings = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @l.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+    context 'credit_picturesを検証するとき' do
+      it 'Shift JISなら失敗する' do
+        @l.credit_pictures = "\x83G\x83r\x83]\x83D"
+        lambda{
+          @l.valid_encode
+        }.should raise_error(Pettanr::BadRequest)
+      end
+    end
+    
+  end
+  
   describe 'デフォルト値補充に於いて' do
     it 'defined' do
       @sp = FactoryGirl.create :system_picture