OSDN Git Service

v07
[pettanr/pettanr.git] / spec / manifests / license_spec.rb
1 # -*- encoding: utf-8 -*-
2 #ライセンス
3 require 'spec_helper'
4
5 describe License do
6   include ManifestsMacros
7   before do
8     @model = License
9   end
10   
11   describe 'ペタナイズに於いて' do
12     it 'ライセンスグループの内訳。管理者がメンテナンスするアイテムなので、システムリソースにあたる' do
13       # テンプレート要件を満たしていないので、テンプレートではない。
14       # ライセンスグループに所属しているが、親はバインダーでもなく、ルートでもない。
15       # リーフやエレメントとして振る舞うこともできないので、
16       # システムリソースとして扱うのが妥当か。 
17       expect(@model.ancestors.include?(Peta::SystemResource)).to eq true
18     end
19     it '親モデルは持たない' do
20       expect(@model.my_peta.parent_model_name).to be_blank
21     end
22     describe 'ブーストに於いて' do
23       before do
24         @boosts = @model.my_peta.boost
25         @boosts_names = ['license_group', 'credit_picture']
26       end
27       it 'これらのブーストが定義されている' do
28         set_boosts? @boosts, @boosts_names
29       end
30       describe 'ライセンスフラグに於いて' do
31         before do
32           @mani = @boosts['license_group']
33         end
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'
40         end
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'
47         end
48       end
49       describe 'クレジットの表示に必要な情報に於いて' do
50         before do
51           @mani = @boosts['credit_picture']
52         end
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'
59         end
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'
66         end
67       end
68     end
69     
70   end
71   
72   describe 'コントローラに於いて' do
73     before do
74       @controller = @model.my_controller
75     end
76     it 'ライセンスのためのコントローラである' do
77       expect(@model.item_name).to eq 'license'
78     end
79     describe 'actionに於いて' do
80       before 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']
85       end
86       it 'これらのアクションが定義されている' do
87         set_actions? @actions, @actions_names
88       end
89       describe 'baseに於いて' do
90       end
91       describe 'indexに於いて' do
92         before do
93           @action = @actions['index']
94         end
95         it 'listタイプのアクションである' do
96           expect(@action.type).to eq 'list'
97         end
98         it 'マニフェストから設定を取り出している' do
99           # ライセンスの公開リストを返すように定義している
100           set_list_action? @action, 'license', 'public'
101         end
102       end
103       describe 'by_license_groupに於いて' do
104         before do
105           @action = @actions['by_license_group']
106         end
107         it 'listタイプのアクションである' do
108           expect(@action.type).to eq 'list'
109         end
110         it 'マニフェストから設定を取り出している' do
111           # ライセンスのライセンスグループ フィルタリストを返すように定義している
112           set_list_action? @action, 'license', 'by_license_group'
113         end
114       end
115       describe 'by_system_pictureに於いて' do
116         before do
117           @action = @actions['by_system_picture']
118         end
119         it 'listタイプのアクションである' do
120           expect(@action.type).to eq 'list'
121         end
122         it 'マニフェストから設定を取り出している' do
123           #ライセンスのシステム画像フィルタリストを返すように定義している
124           set_list_action? @action, 'license', 'by_system_picture'
125         end
126       end
127       describe 'countに於いて' do
128         before do
129           @action = @actions['count']
130         end
131         it 'countタイプのアクションである' do
132           expect(@action.type).to eq 'count'
133         end
134         it 'マニフェストから設定を取り出している' do
135           #ライセンスの公開リストのカウントを返すように定義している
136           set_list_action? @action, 'license', 'public'
137         end
138       end
139       describe 'showに於いて' do
140         before do
141           @action = @actions['show']
142         end
143         it 'showタイプのアクションである' do
144           expect(@action.type).to eq 'show'
145         end
146       end
147       describe 'count_by_license_groupに於いて' do
148         before do
149           @action = @actions['count_by_license_group']
150         end
151         it 'countタイプのアクションである' do
152           expect(@action.type).to eq 'count'
153         end
154         it 'マニフェストから設定を取り出している' do
155           # ライセンスのライセンスグループ フィルタリストのカウントを返すように定義している
156           set_list_action? @action, 'license', 'by_license_group'
157         end
158       end
159       describe 'count_by_system_pictureに於いて' do
160         before do
161           @action = @actions['count_by_system_picture']
162         end
163         it 'countタイプのアクションである' do
164           expect(@action.type).to eq 'count'
165         end
166         it 'マニフェストから設定を取り出している' do
167           # ライセンスのシステム画像フィルタリストのカウントを返すように定義している
168           set_list_action? @action, 'license', 'by_system_picture'
169         end
170       end
171       describe 'newに於いて' do
172         before do
173           @action = @actions['new']
174         end
175         it 'newタイプのアクションである' do
176           expect(@action.type).to eq 'new'
177         end
178         it 'type' do
179           expect(@action.item_name).to eq 'license'
180         end
181       end
182       describe 'editに於いて' do
183         before do
184           @action = @actions['edit']
185         end
186         it 'editタイプのアクションである' do
187           expect(@action.type).to eq 'edit'
188         end
189         it 'type' do
190           expect(@action.item_name).to eq 'license'
191         end
192       end
193       describe 'createに於いて' do
194         before do
195           @action = @actions['create']
196         end
197         it 'createタイプのアクションである' do
198           expect(@action.type).to eq 'create'
199         end
200         it 'type' do
201           expect(@action.item_name).to eq 'license'
202         end
203       end
204       describe 'updateに於いて' do
205         before do
206           @action = @actions['update']
207         end
208         it 'updateタイプのアクションである' do
209           expect(@action.type).to eq 'update'
210         end
211         it 'type' do
212           expect(@action.item_name).to eq 'license'
213         end
214       end
215       describe 'destroyに於いて' do
216         before do
217           @action = @actions['destroy']
218         end
219         it 'destroyタイプのアクションである' do
220           expect(@action.type).to eq 'destroy'
221         end
222         it 'type' do
223           expect(@action.item_name).to eq 'license'
224         end
225       end
226     end
227     
228   end
229   
230   describe 'モデルに於いて' do
231     before do
232       @my_manifest = @model.my_manifest
233     end
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'
238     end
239     
240     describe 'associationsに於いて' do
241       describe 'belongs_toに於いて' do
242         before do
243           @belongs_to = @my_manifest.associations.belongs_to
244           @names = ['license_group', 'system_picture']
245         end
246         it 'これらのモデルに所属している' do
247           set_associations? @belongs_to, @names
248         end
249         describe 'license_groupに於いて' do
250           before do
251             @mani = @belongs_to['license_group']
252           end
253           it 'マニフェストから設定を取り出している' do
254             # モデル名と外部キーが定義あるいはデフォルト値補充されている
255             expect(@mani.model_name).to eq 'license_group'
256             expect(@mani.id_column).to eq 'license_group_id'
257           end
258           it 'サポート機能が動作している' do
259             # モデルを再現できている
260             expect(@mani.model).to eq LicenseGroup
261           end
262         end
263         describe 'system_pictureに於いて' do
264           before do
265             @mani = @belongs_to['system_picture']
266           end
267           it 'マニフェストから設定を取り出している' do
268             # モデル名と外部キーが定義あるいはデフォルト値補充されている
269             expect(@mani.model_name).to eq 'system_picture'
270             expect(@mani.id_column).to eq 'system_picture_id'
271           end
272           it 'サポート機能が動作している' do
273             # モデルを再現できている
274             expect(@mani.model).to eq SystemPicture
275           end
276         end
277       end
278       describe 'has_manyに於いて' do
279         before do
280           @has_many = @model.my_manifest.associations.has_many
281           @names = ['resource_pictures']
282         end
283         it 'これらのモデルを所持している' do
284           set_associations? @has_many, @names
285         end
286         describe 'resource_picturesに於いて' do
287           before do
288             @mani = @has_many['resource_pictures']
289           end
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
295           end
296           it 'サポート機能が動作している' do
297             # モデルを再現できている, 中間モデルフラグ
298             expect(@mani.through?).to be false
299             expect(@mani.model).to eq ResourcePicture
300           end
301         end
302       end
303     end
304     
305     describe 'attributesに於いて' do
306       before do
307         @attributes = @model.my_manifest.attributes
308       end
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']
315       end
316       describe 'license_group_idに於いて' do
317         before do
318           @attribute = @attributes['license_group_id']
319         end
320         it 'numberタイプである' do
321           expect(@attribute.type).to eq 'number'
322         end
323       end
324       describe 'license_group_module_nameに於いて' do
325         before do
326           @attribute = @attributes['license_group_module_name']
327         end
328         it 'textタイプである' do
329           expect(@attribute.type).to eq 'text'
330         end
331       end
332       describe 'nameに於いて' do
333         before do
334           @attribute = @attributes['name']
335         end
336         it 'textタイプである' do
337           expect(@attribute.type).to eq 'text'
338         end
339       end
340       describe 'captionに於いて' do
341         before do
342           @attribute = @attributes['caption']
343         end
344         it 'textタイプである' do
345           expect(@attribute.type).to eq 'text'
346         end
347       end
348       describe 'system_picture_idに於いて' do
349         before do
350           @attribute = @attributes['system_picture_id']
351         end
352         it 'numberタイプである' do
353           expect(@attribute.type).to eq 'number'
354         end
355       end
356       describe 'urlに於いて' do
357         before do
358           @attribute = @attributes['url']
359         end
360         it 'textタイプである' do
361           expect(@attribute.type).to eq 'text'
362         end
363       end
364       describe 'license_group_settingsに於いて' do
365         before do
366           @attribute = @attributes['license_group_settings']
367         end
368         it 'textタイプである' do
369           expect(@attribute.type).to eq 'text'
370         end
371       end
372       describe 'credit_picture_settingsに於いて' do
373         before do
374           @attribute = @attributes['credit_picture_settings']
375         end
376         it 'textタイプである' do
377           expect(@attribute.type).to eq 'text'
378         end
379       end
380     end
381     
382   end
383   
384 end