OSDN Git Service

add test
[pettanr/pettanr.git] / spec / local_manifests / system_picture_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #システム画像
4 describe SystemPicture do
5   include LocalManifestsMacros
6   before do
7     @model = SystemPicture
8   end
9   
10   describe 'ファイラーに於いて' do
11     before do
12       @my_local_manifest = LocalManifest.manifest.filers[@model.item_name]
13     end
14     it 'サポート機能が動作している' do
15       expect(@my_local_manifest.item_class).to eq @model
16       expect(@my_local_manifest.item_name).to eq @model.item_name
17       expect(@my_local_manifest.filer_name).to eq @model.item_name
18     end
19     describe 'symbolに於いて' do
20       before do
21         @symbol = @my_local_manifest.symbol
22       end
23       it 'defaultタイプのsymbolである' do
24         expect(@symbol.type).to eq 'default'
25       end
26       it 'サポート機能が動作している' do
27         expect(@symbol.visible?).to be true
28       end
29       describe 'faceに於いて' do
30         before do
31           @face = @symbol.face
32         end
33         it 'imageタイプのfaceである' do
34           expect(@face.type).to eq 'image'
35         end
36         it 'マニフェストから設定を取り出している' do
37           expect(@face.url).to eq '/images/scroll.gif'
38         end
39       end
40       describe 'linkに於いて' do
41         before do
42           @link = @symbol.link
43         end
44         it 'actionタイプのlinkである' do
45           expect(@link.type).to eq 'action'
46         end
47         it 'マニフェストから設定を取り出している' do
48           expect(@link.action_name).to eq 'show'
49         end
50         it 'サポート機能が動作している' do
51           expect(@link.action_path).to eq '/scrolls/'
52         end
53       end
54     end
55     describe 'captionに於いて' do
56       before do
57         @caption = @my_local_manifest.caption
58       end
59       it 'defaultタイプのsymbolである' do
60         expect(@caption.type).to eq 'default'
61       end
62       it 'サポート機能が動作している' do
63         expect(@caption.visible?).to be true
64       end
65       describe 'faceに於いて' do
66         before do
67           @face = @caption.face
68         end
69         it 'columnタイプのfaceである' do
70           expect(@face.type).to eq 'column'
71         end
72         it 'マニフェストから設定を取り出している' do
73           expect(@face.column_name).to eq 'title'
74         end
75       end
76       describe 'linkに於いて' do
77         before do
78           @link = @caption.link
79         end
80         it 'actionタイプのlinkである' do
81           expect(@link.type).to eq 'action'
82         end
83         it 'マニフェストから設定を取り出している' do
84           expect(@link.action_name).to eq 'play'
85         end
86         it 'サポート機能が動作している' do
87           expect(@link.action_path).to eq '/scrolls/play/'
88         end
89       end
90     end
91     describe 'summaryに於いて' do
92       before do
93         @summary = @my_local_manifest.summary
94       end
95       it 'templateタイプのsymbolである' do
96         expect(@summary.type).to eq 'template'
97       end
98       it 'マニフェストから設定を取り出している' do
99         expect(@summary.template_name).to eq 'summary'
100       end
101     end
102     describe 'iconに於いて' do
103       before do
104         @icon = @my_local_manifest.icon
105       end
106       it 'defaultタイプのsymbolである' do
107         expect(@icon.type).to eq 'default'
108       end
109       it 'サポート機能が動作している' do
110         expect(@icon.visible?).to be true
111       end
112     end
113     describe 'dateに於いて' do
114       before do
115         @date = @my_local_manifest.date
116       end
117       it 'defaultタイプのsymbolである' do
118         expect(@date.type).to eq 'default'
119       end
120       it 'サポート機能が動作している' do
121         expect(@date.visible?).to be true
122       end
123     end
124     describe 'editに於いて' do
125       before do
126         @edit = @my_local_manifest.edit
127       end
128       it 'defaultタイプのsymbolである' do
129         expect(@edit.type).to eq 'default'
130       end
131       it 'サポート機能が動作している' do
132         expect(@edit.visible?).to be true
133       end
134     end
135   end
136   
137   describe 'プロファイラーに於いて' do
138     before do
139       @my_local_manifest = LocalManifest.manifest.profilers[@model.item_name]
140     end
141     it 'マニフェストから設定を取り出している' do
142       expect(@my_local_manifest.item_name).to eq @model.item_name
143     end
144     describe 'columnsに於いて' do
145       before do
146         @columns = @my_local_manifest.columns
147         @names = ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at']
148       end
149       it 'これらのカラムが定義されている' do
150         set_columns? @columns, @names
151       end
152       describe 'titleに於いて' do
153         before do
154           @column = @columns['title']
155         end
156         it 'defaultタイプのcolumnである' do
157           expect(@column.type).to eq 'default'
158         end
159         it 'マニフェストから設定を取り出している' do
160           expect(@column.item_name).to eq 'scroll'
161         end
162       end
163       describe 'descriptionに於いて' do
164         before do
165           @column = @columns['description']
166         end
167         it 'defaultタイプのcolumnである' do
168           expect(@column.type).to eq 'default'
169         end
170         it 'マニフェストから設定を取り出している' do
171           expect(@column.item_name).to eq 'scroll'
172         end
173       end
174       describe 'visibleに於いて' do
175         before do
176           @column = @columns['visible']
177         end
178         it 'sourceタイプのcolumnである' do
179           expect(@column.type).to eq 'source'
180         end
181         it 'マニフェストから設定を取り出している' do
182           expect(@column.item_name).to eq 'scroll'
183         end
184       end
185       describe 'author_idに於いて' do
186         before do
187           @column = @columns['author_id']
188         end
189         it 'defaultタイプのcolumnである' do
190           expect(@column.type).to eq 'default'
191         end
192         it 'マニフェストから設定を取り出している' do
193           expect(@column.item_name).to eq 'scroll'
194         end
195       end
196     end
197     describe 'column_namesに於いて' do
198       before do
199         @column_names = @my_local_manifest.column_names
200       end
201       it '数量が守られている' do
202         expect(@column_names.size).to eq 4 + 3
203       end
204       it '順序が守られている' do
205         expect(@column_names).to eq ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at']
206       end
207     end
208     describe 'extend_settingsに於いて' do
209       before do
210         @extend_settings = @my_local_manifest.extend_settings
211       end
212       it '拡張カラムは無い' do
213         expect(@extend_settings).to be_empty
214       end
215     end
216     describe 'listsに於いて' do
217       before do
218         @lists = @my_local_manifest.lists
219       end
220       it '無い' do
221         expect(@lists).to be_empty
222       end
223     end
224     describe 'associationsに於いて' do
225       before do
226         @associations = @my_local_manifest.associations
227       end
228       describe 'belongs_toに於いて' do
229         before do
230           @belongs_to = @associations.belongs_to
231         end
232         it 'これらの所属モデルを取り扱う' do
233           expect(@belongs_to.map {|a| a.name}).to eq ['author']
234         end
235         describe 'authorに於いて' do
236           before do
237             @mani = @belongs_to[0]
238           end
239           it 'マニフェストから設定を取り出している' do
240             expect(@mani.name).to eq 'author'
241             expect(@mani.model_name).to eq 'author'
242           end
243           it 'サポート機能が動作している' do
244             expect(@mani.model).to eq Author
245           end
246         end
247       end
248       describe 'has_manyに於いて' do
249         before do
250           @has_many = @associations.has_many
251         end
252         it 'これらの所持モデルを取り扱う' do
253           expect(@has_many.map {|a| a.table_name}).to eq ['scroll_panels', 'panels']
254         end
255         describe 'scroll_panelsに於いて' do
256           before do
257             @mani = @has_many[0]
258           end
259           it 'マニフェストから設定を取り出している' do
260             expect(@mani.name).to eq 'scroll_panels.by_scroll'
261             expect(@mani.model_name).to eq 'scroll_panel'
262             expect(@mani.list_name).to eq 'by_scroll'
263           end
264           it 'サポート機能が動作している' do
265             expect(@mani.model).to eq ScrollPanel
266           end
267         end
268         describe 'panels.by_scrollに於いて' do
269           before do
270             @mani = @has_many[1]
271           end
272           it 'マニフェストから設定を取り出している' do
273             expect(@mani.name).to eq 'panels.by_scroll'
274             expect(@mani.model_name).to eq 'panel'
275             expect(@mani.list_name).to eq 'by_scroll'
276           end
277           it 'サポート機能が動作している' do
278             expect(@mani.model).to eq Panel
279           end
280         end
281       end
282     end
283   end
284   
285   describe 'リストグループに於いて' do
286     before do
287       @my_local_manifest = LocalManifest.manifest.list_groups[@model.item_name]
288     end
289     it 'マニフェストから設定を取り出している' do
290       expect(@my_local_manifest.item_name).to eq @model.item_name
291     end
292     describe 'listsに於いて' do
293       before do
294         @lists = @my_local_manifest.lists
295       end
296       it 'これらのリストを定義している' do
297         set_lists? @lists, ['public', 'private', 'by_author', 'by_panel']
298       end
299       describe 'publicに於いて' do
300         before do
301           @mani = @lists['public']
302         end
303         it 'マニフェストから設定を取り出している' do
304           expect(@mani.type).to eq 'public'
305         end
306         it 'マニフェストから設定を取り出している' do
307           expect(@mani.model).to eq Scroll
308         end
309         it 'サポート機能が動作している' do
310           expect(@mani.has_id?).to be nil
311           expect(@mani.pre_id?).to be true
312           expect(@mani.item_name).to eq @model.item_name
313         end
314         describe 'whereに於いて' do
315           before do
316             @where = @mani.where
317           end
318           it 'autoタイプである' do
319             expect(@where.type).to eq 'auto'
320           end
321           it 'サポート機能が動作している' do
322             expect(@where.item_name).to eq @model.item_name
323             expect(@where.list_name).to eq 'public'
324             expect(@where.model).to eq Scroll
325           end
326           it 'method_name' do
327             expect(@where.method_name).to eq 'public_list_where'
328           end
329         end
330         describe 'includesに於いて' do
331           before do
332             @includes = @mani.includes
333           end
334           it 'autoタイプである' do
335             expect(@includes.type).to eq 'auto'
336           end
337           it 'サポート機能が動作している' do
338             expect(@includes.item_name).to eq @model.item_name
339             expect(@includes.list_name).to eq 'public'
340             expect(@includes.model).to eq Scroll
341           end
342           it 'includes' do
343             expect(@includes.includes).to be_empty
344           end
345         end
346         describe 'orderに於いて' do
347           before do
348             @order = @mani.order
349           end
350           it 'autoタイプである' do
351             expect(@order.type).to eq 'auto'
352           end
353           it 'サポート機能が動作している' do
354             expect(@order.item_name).to eq @model.item_name
355             expect(@order.list_name).to eq 'public'
356             expect(@order.model).to eq Scroll
357           end
358           it 'order' do
359             expect(@order.order).to eq 'list_order'
360           end
361         end
362       end
363     end
364   end
365   
366   describe '入力フォームに於いて' do
367     before do
368       @my_local_manifest = LocalManifest.manifest.forms[@model.item_name]
369     end
370     it 'マニフェストから設定を取り出している' do
371       expect(@my_local_manifest.name).to eq @model.item_name
372     end
373     describe 'fieldsに於いて' do
374       before do
375         @fields = @my_local_manifest.fields
376       end
377       # 細かいチェックは後でやるので、大雑把に数量だけチェックしておく。
378       it '数量が守られている' do
379         expect(@fields.size).to eq 5
380       end
381     end
382     describe 'field_namesに於いて' do
383       before do
384         @field_names = @my_local_manifest.field_names
385       end
386       it '数量が守られている' do
387         expect(@field_names.size).to eq 5
388       end
389       it '順序が守られている' do
390         expect(@field_names).to eq ['title', 'description', 'visible', 'id', 'author_id']
391       end
392     end
393     # 処理順に並べられたフィールドのこと
394     # 本来fieldsでテストするべき内容だが、並び替えもテストしたいのでこちらで行う。
395     describe 'ordered_fieldsに於いて' do
396       before do
397         @ordered_fields = @my_local_manifest.ordered_fields
398         @names = ['title', 'description', 'visible', 'id', 'author_id']
399       end
400       it 'これらのフィールドを取り扱う' do
401         expect(@ordered_fields.map {|f| f.name }).to eq @names
402       end
403       describe 'titleに於いて' do
404         before do
405           @field = @ordered_fields[0]
406         end
407         it 'マニフェストから設定を取り出している' do
408           expect(@field.name).to eq 'title'
409           expect(@field.row_break).to be true
410         end
411         it 'サポート機能が動作している' do
412           expect(@field.part?).to be false
413           expect(@field.form_name).to eq @model.item_name
414           expect(@field.column_name).to eq 'title'
415           expect(@field.model_name).to eq @model.item_name
416         end
417         describe 'labelに於いて' do
418           before do
419             @label = @field.label
420           end
421           it 'defaultタイプである' do
422             expect(@label.type).to eq 'default'
423           end
424           it 'マニフェストから設定を取り出している' do
425             expect(@label.row_break).to be true
426           end
427           it 'サポート機能が動作している' do
428             expect(@label.form_name).to eq @model.item_name
429             expect(@label.field_name).to eq 'title'
430             expect(@label.model_name).to eq @model.item_name
431             expect(@label.column_name).to eq 'title'
432           end
433         end
434         describe 'tagに於いて' do
435           before do
436             @tag = @field.tag
437           end
438           it 'textタイプである' do
439             expect(@tag.type).to eq 'text'
440           end
441           it 'マニフェストから設定を取り出している' do
442             expect(@tag.options).to_not be_empty
443             expect(@tag.options['size']).to eq 20
444           end
445           it 'サポート機能が動作している' do
446             expect(@tag.form_name).to eq @model.item_name
447             expect(@tag.field_name).to eq 'title'
448           end
449         end
450       end
451       describe 'descriptionに於いて' do
452         before do
453           @field = @ordered_fields[1]
454         end
455         it 'マニフェストから設定を取り出している' do
456           expect(@field.name).to eq 'description'
457           expect(@field.row_break).to be true
458         end
459         it 'サポート機能が動作している' do
460           expect(@field.part?).to be false
461           expect(@field.form_name).to eq @model.item_name
462           expect(@field.column_name).to eq 'description'
463           expect(@field.model_name).to eq @model.item_name
464         end
465       end
466       describe 'visibleに於いて' do
467         before do
468           @field = @ordered_fields[2]
469         end
470         it 'マニフェストから設定を取り出している' do
471           expect(@field.name).to eq 'visible'
472           expect(@field.row_break).to be true
473         end
474         it 'サポート機能が動作している' do
475           expect(@field.part?).to be false
476           expect(@field.form_name).to eq @model.item_name
477           expect(@field.column_name).to eq 'visible'
478           expect(@field.model_name).to eq @model.item_name
479         end
480       end
481       describe 'idに於いて' do
482         before do
483           @field = @ordered_fields[3]
484         end
485         it 'マニフェストから設定を取り出している' do
486           expect(@field.name).to eq 'id'
487           expect(@field.row_break).to be true
488         end
489         it 'サポート機能が動作している' do
490           expect(@field.part?).to be false
491           expect(@field.form_name).to eq @model.item_name
492           expect(@field.column_name).to eq 'id'
493           expect(@field.model_name).to eq @model.item_name
494         end
495       end
496       describe 'author_idに於いて' do
497         before do
498           @field = @ordered_fields[4]
499         end
500         it 'マニフェストから設定を取り出している' do
501           expect(@field.name).to eq 'author_id'
502           expect(@field.row_break).to be true
503         end
504         it 'サポート機能が動作している' do
505           expect(@field.part?).to be false
506           expect(@field.form_name).to eq @model.item_name
507           expect(@field.column_name).to eq 'author_id'
508           expect(@field.model_name).to eq @model.item_name
509         end
510       end
511     end
512   end
513   
514   describe 'bucketに於いて' do
515     before do
516       @my_local_manifest = LocalManifest.manifest.buckets[@model.item_name]
517     end
518     it 'マニフェストから設定を取り出している' do
519       expect(@my_local_manifest.members).to be_empty
520       expect(@my_local_manifest.form_field_names).to be_empty
521     end
522     it 'サポート機能が動作している' do
523       expect(@my_local_manifest.has_member?).to be false
524       expect(@my_local_manifest.item_name).to eq @model.item_name
525     end
526   end
527   
528 end