1 # -*- encoding: utf-8 -*-
10 @sp = Factory :system_picture
11 @lg = Factory :license_group
12 @l = Factory.build :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
15 it 'オーソドックスなデータなら通る' do
19 context 'license_group_idを検証するとき' do
21 @l.license_group_id = @lg.id
\r
25 @l.license_group_id = ''
26 @l.should_not be_valid
29 @l.license_group_id = 'a'
\r
30 @l.should_not be_valid
\r
32 it '存在するライセンスグループでなければ失敗する' do
\r
33 @l.license_group_id = 0
\r
34 @l.should_not be_valid
\r
37 context 'nameを検証するとき' do
44 @l.should_not be_valid
48 @l.should_not be_valid
52 @l.should_not be_valid
55 context 'captionを検証するとき' do
62 @l.should_not be_valid
66 @l.should_not be_valid
69 context 'urlを検証するとき' do
71 @l.url = 'http://test.jp/aaaaa' + 'a' * 180
77 @l.should_not be_valid
80 @l.url = 'http://test.jp/aaaaa' + 'a' * 181
81 @l.should_not be_valid
85 @l.should_not be_valid
\r
88 context 'system_picture_idを検証するとき' do
90 @l.system_picture_id = @sp.id
\r
94 @l.system_picture_id = ''
95 @l.should_not be_valid
98 @l.system_picture_id = 'a'
\r
99 @l.should_not be_valid
\r
101 it '存在するシステム画像でなければ失敗する' do
\r
102 @l.system_picture_id = 0
\r
103 @l.should_not be_valid
\r
108 describe '単体取得に於いて' do
110 @sp = Factory :system_picture
111 @lg = Factory :license_group
112 @l = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
115 l = License.show @l.id
119 describe '関連テーブルプションに於いて' do
120 context 'オプションがないとき' do
121 it 'ライセンスグループを含んでいる' do
122 r = License.show_include_opt
123 r.should eq [:license_group]
126 context 'オプションで素材ライセンスを含ませたとき' do
127 it 'ライセンスグループと素材ライセンスを含んでいる' do
128 r = License.show_include_opt(:include => :resource_picture_license)
129 r.should eq [:license_group, :resource_picture_license]
133 describe 'json単体出力オプションに於いて' do
134 it 'includeキーを含んでいる' do
135 r = License.show_json_include_opt
136 r.has_key?(:include).should be_true
139 r = License.show_json_include_opt[:include]
140 r.should have(1).items
142 it 'ライセンスグループを含んでいる' do
143 r = License.show_json_include_opt[:include]
144 r.has_key?(:license_group).should be_true
147 describe '一覧取得に於いて' do
149 @sp = Factory :system_picture
150 @lg = Factory :license_group
151 @l = Factory :license, :name => 'peta2.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
152 @lg2 = Factory :license_group, :name => 'pubdm'
155 l = License.list @lg.id
158 it 'グループ順,名前順で並んでいる' do
159 @l2 = Factory :license, :name => 'peta3.0', :url => 'http://pe.ta/3.0', :license_group_id => @lg.id, :system_picture_id => @sp.id
160 @l3 = Factory :license, :name => 'pd1.0', :url => 'http://pb.dm/1.0', :license_group_id => @lg2.id, :system_picture_id => @sp.id
161 l = License.list @lg.id
162 l.should eq [@l, @l2]
165 describe 'list関連テーブルプションに於いて' do
166 it 'includeキーを含んでいる' do
168 r.has_key?(:include).should be_true
171 r = License.list_opt[:include]
172 r.should have(1).items
174 it 'ライセンスグループを含んでいる' do
175 r = License.list_opt[:include]
176 r.has_key?(:license_group).should be_true
179 describe 'json一覧出力オプションに於いて' do
180 it 'includeキーを含んでいる' do
181 r = License.list_json_opt
182 r.has_key?(:include).should be_true
185 r = License.list_json_opt[:include]
186 r.should have(1).items
188 it 'ライセンスグループを含んでいる' do
189 r = License.list_json_opt[:include]
190 r.has_key?(:license_group).should be_true