X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=spec%2Fmodels%2Flicense_spec.rb;h=08897937f57780441bda0e0dd3273d5bd71d90de;hb=1c1b60dd45979db866f8a66b423bb5e75602b74f;hp=e0dafd4e78f50c0320815f607031fee2781a3dec;hpb=ebc737a8fca36b965e53899182f4ab7ccbd74b0d;p=pettanr%2Fpettanr.git diff --git a/spec/models/license_spec.rb b/spec/models/license_spec.rb index e0dafd4e..08897937 100644 --- a/spec/models/license_spec.rb +++ b/spec/models/license_spec.rb @@ -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