+ describe 'デフォルト値補充に於いて' do
+ it 'defined' do
+ @lg = FactoryGirl.build :license_group, :name => "1"
+ @lg.supply_default
+ end
+ end
+
+ describe '上書き補充に於いて' do
+ it 'defined' do
+ @lg = FactoryGirl.build :license_group, :name => "1"
+ @lg.overwrite
+ end
+ end
+
+ describe '閲覧許可に於いて' do
+ #ライセンスグループは作家作成する前から存在するので、閲覧制限の意味がない
+ end
+
+ describe '一覧取得に於いて' do
+ before do
+ @lg = FactoryGirl.create :license_group, :name => "1"
+ end
+ context 'つつがなく終わるとき' do\r
+ it '一覧取得オプションを利用している' do\r
+ LicenseGroup.stub(:list_opt).with(any_args).and_return({})\r
+ LicenseGroup.should_receive(:list_opt).with(any_args).exactly(1)\r
+ r = LicenseGroup.list
+ end\r
+ end\r
+ it 'リストを返す' do
+ l = LicenseGroup.list
+ l.should eq [@lg]
+ end
+ it '名前順で並んでいる' do
+ @lg2 = FactoryGirl.create :license_group, :name => "5", :url => 'http://test.ptn/10'
+ l = LicenseGroup.list
+ l.should eq [@lg, @lg2]
+ end
+ end
+ describe 'list関連テーブルプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.list_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.list_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.list_json_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.list_json_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.list_json_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+
+ describe '単体取得に於いて' do
+ before do
+ @lg = FactoryGirl.create :license_group
+ end
+ context 'つつがなく終わるとき' do\r
+ it '単体取得オプションを利用している' do\r
+ LicenseGroup.stub(:show_opt).with(any_args).and_return({})\r
+ LicenseGroup.should_receive(:show_opt).with(any_args).exactly(1)\r
+ r = LicenseGroup.show @lg.id
+ end\r
+ end\r
+ it '指定のコマを返す' do
+ l = LicenseGroup.show @lg.id
+ l.should eq @lg
+ end
+ context '存在しないライセンスグループを開こうとしたとき' do\r
+ it '404RecordNotFound例外を返す' do\r
+ lambda{\r
+ LicenseGroup.show 110\r
+ }.should raise_error(ActiveRecord::RecordNotFound)\r
+ end\r
+ end\r
+ end
+ describe '単体出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.show_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.show_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.show_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+ describe 'json単体出力オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = LicenseGroup.show_json_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = LicenseGroup.show_json_opt[:include]
+ r.should have(1).items
+ end
+ it 'ライセンスを含んでいる' do
+ r = LicenseGroup.show_json_opt[:include]
+ r.has_key?(:licenses).should be_true
+ end
+ end
+