1 # -*- encoding: utf-8 -*-
6 include ManifestsMacros
11 describe 'ペタナイズに於いて' do
12 it 'ライセンスグループの内訳。管理者がメンテナンスするアイテムなので、システムリソースにあたる' do
13 # テンプレート要件を満たしていないので、テンプレートではない。
14 # ライセンスグループに所属しているが、親はバインダーでもなく、ルートでもない。
15 # リーフやエレメントとして振る舞うこともできないので、
17 expect(@model.ancestors.include?(Peta::SystemResource)).to eq true
20 expect(@model.my_peta.parent_model_name).to be_blank
22 describe 'ブーストに於いて' do
24 @boosts = @model.my_peta.boost
25 @boosts_names = ['license_group', 'credit_picture']
27 it 'これらのブーストが定義されている' do
28 set_boosts? @boosts, @boosts_names
30 describe 'ライセンスフラグに於いて' do
32 @mani = @boosts['license_group']
34 it 'システム起動前に初期化可能なサポート機能が動作している' do
35 expect(@mani.level).to eq 'post'
36 expect(@mani.template_name).to eq 'license_group'
37 expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'
38 expect(@mani.settings_column_name).to eq 'license_group_settings'
39 expect(@mani.foreign_key).to eq 'license_group_id'
41 it 'システム起動後にしか初期化できないサポート機能が動作している' do
42 expect(@mani.item_name_for_extend_model).to eq 'license'
43 expect(@mani.setter_method_name).to eq 'license_extend='
44 expect(@mani.getter_method_name).to eq 'license_extend'
45 expect(@mani.extend_model_class_name).to eq 'License'
46 expect(@mani.extend_module_name).to eq 'LicenseModule'
49 describe 'クレジットの表示に必要な情報に於いて' do
51 @mani = @boosts['credit_picture']
53 it 'システム起動前に初期化可能なサポート機能が動作している' do
54 expect(@mani.level).to eq 'read'
55 expect(@mani.template_name).to eq 'license_group'
56 expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'
57 expect(@mani.settings_column_name).to eq 'credit_picture_settings'
58 expect(@mani.foreign_key).to eq 'license_group_id'
60 it 'システム起動後にしか初期化できないサポート機能が動作している' do
61 expect(@mani.item_name_for_extend_model).to eq 'credit_picture'
62 expect(@mani.setter_method_name).to eq 'credit_picture_extend='
63 expect(@mani.getter_method_name).to eq 'credit_picture_extend'
64 expect(@mani.extend_model_class_name).to eq 'CreditPicture'
65 expect(@mani.extend_module_name).to eq 'CreditPictureModule'
72 describe 'コントローラに於いて' do
74 @controller = @model.my_controller
76 it 'ライセンスのためのコントローラである' do
77 expect(@model.item_name).to eq 'license'
79 describe 'actionに於いて' do
81 @actions = @controller.actions
82 @actions_names = ['index', 'by_license_group', 'by_system_picture', 'show',
83 'count', 'count_by_license_group', 'count_by_system_picture',
84 'new', 'edit', 'create', 'update', 'destroy']
86 it 'これらのアクションが定義されている' do
87 set_actions? @actions, @actions_names
89 describe 'baseに於いて' do
91 describe 'indexに於いて' do
93 @action = @actions['index']
95 it 'listタイプのアクションである' do
96 expect(@action.type).to eq 'list'
98 it 'マニフェストから設定を取り出している' do
99 # ライセンスの公開リストを返すように定義している
100 set_list_action? @action, 'license', 'public'
103 describe 'by_license_groupに於いて' do
105 @action = @actions['by_license_group']
107 it 'listタイプのアクションである' do
108 expect(@action.type).to eq 'list'
110 it 'マニフェストから設定を取り出している' do
111 # ライセンスのライセンスグループ フィルタリストを返すように定義している
112 set_list_action? @action, 'license', 'by_license_group'
115 describe 'by_system_pictureに於いて' do
117 @action = @actions['by_system_picture']
119 it 'listタイプのアクションである' do
120 expect(@action.type).to eq 'list'
122 it 'マニフェストから設定を取り出している' do
123 #ライセンスのシステム画像フィルタリストを返すように定義している
124 set_list_action? @action, 'license', 'by_system_picture'
127 describe 'countに於いて' do
129 @action = @actions['count']
131 it 'countタイプのアクションである' do
132 expect(@action.type).to eq 'count'
134 it 'マニフェストから設定を取り出している' do
135 #ライセンスの公開リストのカウントを返すように定義している
136 set_list_action? @action, 'license', 'public'
139 describe 'showに於いて' do
141 @action = @actions['show']
143 it 'showタイプのアクションである' do
144 expect(@action.type).to eq 'show'
147 describe 'count_by_license_groupに於いて' do
149 @action = @actions['count_by_license_group']
151 it 'countタイプのアクションである' do
152 expect(@action.type).to eq 'count'
154 it 'マニフェストから設定を取り出している' do
155 # ライセンスのライセンスグループ フィルタリストのカウントを返すように定義している
156 set_list_action? @action, 'license', 'by_license_group'
159 describe 'count_by_system_pictureに於いて' do
161 @action = @actions['count_by_system_picture']
163 it 'countタイプのアクションである' do
164 expect(@action.type).to eq 'count'
166 it 'マニフェストから設定を取り出している' do
167 # ライセンスのシステム画像フィルタリストのカウントを返すように定義している
168 set_list_action? @action, 'license', 'by_system_picture'
171 describe 'newに於いて' do
173 @action = @actions['new']
175 it 'newタイプのアクションである' do
176 expect(@action.type).to eq 'new'
179 expect(@action.item_name).to eq 'license'
182 describe 'editに於いて' do
184 @action = @actions['edit']
186 it 'editタイプのアクションである' do
187 expect(@action.type).to eq 'edit'
190 expect(@action.item_name).to eq 'license'
193 describe 'createに於いて' do
195 @action = @actions['create']
197 it 'createタイプのアクションである' do
198 expect(@action.type).to eq 'create'
201 expect(@action.item_name).to eq 'license'
204 describe 'updateに於いて' do
206 @action = @actions['update']
208 it 'updateタイプのアクションである' do
209 expect(@action.type).to eq 'update'
212 expect(@action.item_name).to eq 'license'
215 describe 'destroyに於いて' do
217 @action = @actions['destroy']
219 it 'destroyタイプのアクションである' do
220 expect(@action.type).to eq 'destroy'
223 expect(@action.item_name).to eq 'license'
230 describe 'モデルに於いて' do
232 @my_manifest = @model.my_manifest
234 it 'サポート機能が動作している' do
235 expect(@my_manifest.model_name).to eq 'license'
236 expect(@my_manifest.classify).to eq @model
237 expect(@my_manifest.table_name).to eq 'licenses'
240 describe 'associationsに於いて' do
241 describe 'belongs_toに於いて' do
243 @belongs_to = @my_manifest.associations.belongs_to
244 @names = ['license_group', 'system_picture']
246 it 'これらのモデルに所属している' do
247 set_associations? @belongs_to, @names
249 describe 'license_groupに於いて' do
251 @mani = @belongs_to['license_group']
253 it 'マニフェストから設定を取り出している' do
254 # モデル名と外部キーが定義あるいはデフォルト値補充されている
255 expect(@mani.model_name).to eq 'license_group'
256 expect(@mani.id_column).to eq 'license_group_id'
258 it 'サポート機能が動作している' do
260 expect(@mani.model).to eq LicenseGroup
263 describe 'system_pictureに於いて' do
265 @mani = @belongs_to['system_picture']
267 it 'マニフェストから設定を取り出している' do
268 # モデル名と外部キーが定義あるいはデフォルト値補充されている
269 expect(@mani.model_name).to eq 'system_picture'
270 expect(@mani.id_column).to eq 'system_picture_id'
272 it 'サポート機能が動作している' do
274 expect(@mani.model).to eq SystemPicture
278 describe 'has_manyに於いて' do
280 @has_many = @model.my_manifest.associations.has_many
281 @names = ['resource_pictures']
283 it 'これらのモデルを所持している' do
284 set_associations? @has_many, @names
286 describe 'resource_picturesに於いて' do
288 @mani = @has_many['resource_pictures']
290 it 'マニフェストから設定を取り出している' do
291 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
292 expect(@mani.model_name).to eq 'resource_picture'
293 expect(@mani.foreign_key).to eq 'license_id'
294 expect(@mani.through).to be nil
296 it 'サポート機能が動作している' do
297 # モデルを再現できている, 中間モデルフラグ
298 expect(@mani.through?).to be false
299 expect(@mani.model).to eq ResourcePicture
305 describe 'attributesに於いて' do
307 @attributes = @model.my_manifest.attributes
309 it 'これらのカラムを定義している' do
310 set_attributes? @attributes,
311 ['id', 'license_group_id', 'license_group_module_name',
312 'name', 'caption', 'system_picture_id', 'url',
313 'license_group_settings', 'credit_picture_settings',
314 'created_at', 'updated_at']
316 describe 'license_group_idに於いて' do
318 @attribute = @attributes['license_group_id']
321 expect(@attribute.type).to eq 'number'
324 describe 'license_group_module_nameに於いて' do
326 @attribute = @attributes['license_group_module_name']
329 expect(@attribute.type).to eq 'text'
332 describe 'nameに於いて' do
334 @attribute = @attributes['name']
337 expect(@attribute.type).to eq 'text'
340 describe 'captionに於いて' do
342 @attribute = @attributes['caption']
345 expect(@attribute.type).to eq 'text'
348 describe 'system_picture_idに於いて' do
350 @attribute = @attributes['system_picture_id']
353 expect(@attribute.type).to eq 'number'
356 describe 'urlに於いて' do
358 @attribute = @attributes['url']
361 expect(@attribute.type).to eq 'text'
364 describe 'license_group_settingsに於いて' do
366 @attribute = @attributes['license_group_settings']
369 expect(@attribute.type).to eq 'text'
372 describe 'credit_picture_settingsに於いて' do
374 @attribute = @attributes['credit_picture_settings']
377 expect(@attribute.type).to eq 'text'