OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / spec / models / license_spec.rb
index e0dafd4..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
@@ -223,6 +277,22 @@ describe License do
     end
   end
   
+  describe '管理名検索に於いて' do
+    before do
+      @sp = FactoryGirl.create :system_picture
+      @lg = FactoryGirl.create :license_group
+      @l = FactoryGirl.create :license, :name => 'peta2.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
+      @lg2 = FactoryGirl.create :license_group, :name => 'pubdm'
+      @l2 = FactoryGirl.create :license, :name => 'pettan2.2b', :url => @l.url + 'l2', :license_group_id => @lg.id, :system_picture_id => @sp.id
+    end
+    context 'つつがなく終わるとき' do
+      it 'リストを返す' do
+        l = License.list_by_name @l2.name
+        l.should eq [@l2]
+      end
+    end
+  end
+  
   describe '更新に於いて' do
     before do
       @lg = FactoryGirl.create :license_group