OSDN Git Service

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