+++ /dev/null
-# -*- encoding: utf-8 -*-
-#ライセンス選択
-require 'spec_helper'
-
-describe StandardLicense do
- before do
- FactoryGirl.create :admin
- @user = FactoryGirl.create( :user_yas)
- @author = @user.author
- @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
- @other_user = FactoryGirl.create( :user_yas)
- @other_author = @other_user.author
- @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
- @sp = FactoryGirl.create :system_picture
- @lg = FactoryGirl.create :license_group
- @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
- end
-
- describe '検証に於いて' do
- before do
- end
-
- it 'オーソドックスなデータなら通る' do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- @sl.should be_valid
- end
-
- context 'license_idを検証するとき' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'テストデータの確認' do
- @sl.license_id = @license.id
- @sl.should be_valid
- end
- it 'nullなら失敗する' do
- @sl.license_id = nil
- @sl.should_not be_valid
- end
- it '数値でなければ失敗する' do
- @sl.license_id = 'a'
- @sl.should_not be_valid
- end
- it '存在するライセンスグループでなければ失敗する' do
- @sl.license_id = 0
- @sl.should_not be_valid
- end
- end
- context 'artist_nameを検証するとき' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'テストデータの確認' do
- @sl.artist_name = 'a'
- @sl.should be_valid
- end
- it 'nullなら失敗する' do
- @sl.artist_name = nil
- @sl.should_not be_valid
- end
- end
- end
- describe '補充に於いて' do
- it '原画idを補充している' do
- @sl = StandardLicense.new
- @sl.artist_name = nil
- @sl.supply_default @artist
- @sl.artist_name.should eq @artist.name
- end
- end
- describe 'クレジットデータに於いて' do
- before do
- @sl = FactoryGirl.build :standard_license, :license_id => @license.id
- end
- it 'jsonテキストを返す' do
- r = @sl.credit
- lambda{
- JSON.parse @sl.credit
- }.should_not raise_error
- end
- it 'system_picture_idを含んでいて値はライセンスに割り当てたシステム画像になっている' do
- r = JSON.parse @sl.credit
- r.has_key?('system_picture_id').should be_true
- r['system_picture_id'].should eq @sl.license.system_picture_id
- end
- end
-end