@l.license_group_id = ''
@l.should_not be_valid
end
- it '数値でなければ失敗する' do\r
- @l.license_group_id = 'a'\r
- @l.should_not be_valid\r
- end\r
- it '存在するライセンスグループでなければ失敗する' do\r
- @l.license_group_id = 0\r
- @l.should_not be_valid\r
- end\r
+ it '数値でなければ失敗する' do
+ @l.license_group_id = 'a'
+ @l.should_not be_valid
+ end
+ it '存在するライセンスグループでなければ失敗する' do
+ @l.license_group_id = 0
+ @l.should_not be_valid
+ end
end
context 'nameを検証するとき' do
it 'nullなら失敗する' do
@l.should_not be_valid
end
it 'url形式でないなら失敗する' do
- @l.url = 'a'*200\r
- @l.should_not be_valid\r
+ @l.url = 'a'*200
+ @l.should_not be_valid
end
end
context 'system_picture_idを検証するとき' do
@l.system_picture_id = ''
@l.should_not be_valid
end
- it '数値でなければ失敗する' do\r
- @l.system_picture_id = 'a'\r
- @l.should_not be_valid\r
- end\r
- it '存在するシステム画像でなければ失敗する' do\r
- @l.system_picture_id = 0\r
- @l.should_not be_valid\r
- end\r
+ it '数値でなければ失敗する' do
+ @l.system_picture_id = 'a'
+ @l.should_not be_valid
+ end
+ it '存在するシステム画像でなければ失敗する' do
+ @l.system_picture_id = 0
+ @l.should_not be_valid
+ end
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
@l = FactoryGirl.create :license, :name => 'peta2.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
@lg2 = FactoryGirl.create :license_group, :name => 'pubdm'
end
- context 'つつがなく終わるとき' do\r
- it '一覧取得オプションを利用している' do\r
- License.stub(:list_opt).with(any_args).and_return({})\r
- License.should_receive(:list_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ License.stub(:list_opt).with(any_args).and_return({})
+ License.should_receive(:list_opt).with(any_args).exactly(1)
r = License.list
- end\r
- end\r
+ end
+ end
it 'リストを返す' do
l = License.list
l.should eq [@l]
@lg = FactoryGirl.create :license_group
@l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
- context 'つつがなく終わるとき' do\r
- it '単体取得オプションを利用している' do\r
- License.stub(:show_opt).with(any_args).and_return({})\r
- License.should_receive(:show_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '単体取得オプションを利用している' do
+ License.stub(:show_opt).with(any_args).and_return({})
+ License.should_receive(:show_opt).with(any_args).exactly(1)
r = License.show @l.id
- end\r
- end\r
+ end
+ end
it '指定のライセンスを返す' do
l = License.show @l.id
l.should eq @l
end
- context '存在しないライセンスを開こうとしたとき' do\r
- it '404RecordNotFound例外を返す' do\r
- lambda{\r
- License.show 110\r
- }.should raise_error(ActiveRecord::RecordNotFound)\r
- end\r
- end\r
+ context '存在しないライセンスを開こうとしたとき' do
+ it '404RecordNotFound例外を返す' do
+ lambda{
+ License.show 110
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
end
describe '単体取得オプションに於いて' do
it 'includeキーを含んでいる' 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
r.is_a?(License).should be_true
r.name.should eq @ln
r.url.should eq @la["url"]
+ cp = JSON.parse r.credit_pictures
+ cp['a_picture_id'].should_not be_nil
+ cp['b_picture_id'].should_not be_nil
end
it 'ライセンスが作成されている' do
lambda {
end
end
+ describe 'エクスポートに於いて' do
+ before do
+ @sp = FactoryGirl.create :system_picture
+ @lg = FactoryGirl.create :license_group
+ @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+ @l2 = FactoryGirl.create :license, :name => 'l2[old ls]', :url => @l.url+'2', :license_group_id => @lg.id, :system_picture_id => @sp.id, :updated_at => Time.now - 3000
+ end
+ it '開始日時が省略された場合はすべてのライセンスを返す' do
+ r = License.export
+ r.should eq [@l, @l2]
+ end
+ it '開始日時以降に更新されたライセンスを返す' do
+ r = License.export @l.updated_at - 100
+ r.should eq [@l]
+ end
+ end
+
end