OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / panel_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 require 'spec_helper'\r
3 #コマ\r
4 \r
5 describe Panel do\r
6   include ManifestsMacros\r
7   before do\r
8     @model = Panel\r
9   end\r
10   \r
11   describe 'ペタナイズに於いて' do\r
12     it 'ルートである' do\r
13       expect(@model.ancestors.include?(Peta::Root)).to eq true\r
14     end\r
15     it '親モデルは持たない' do\r
16       expect(@model.my_peta.parent_model_name).to be_blank\r
17     end\r
18     describe 'ブーストに於いて' do\r
19       it '特筆すべき注意事項はない' do\r
20         expect(@model.my_peta.boost.keys).to be_empty\r
21       end\r
22     end\r
23     \r
24   end\r
25   \r
26   describe 'コントローラに於いて' do\r
27     before do\r
28       @controller = @model.my_controller\r
29     end\r
30     it 'コマのためのコントローラである' do\r
31       expect(@model.item_name).to eq 'panel'\r
32     end\r
33     describe 'actionに於いて' do\r
34       before do\r
35         @actions = @controller.actions\r
36         @actions_names = ['index', 'by_author', 'by_scroll', 'by_sheet', 'by_speech_balloon_template', 'show', \r
37           'count', 'count_by_author', 'count_by_scroll', 'count_by_sheet', 'count_by_speech_balloon_template', \r
38           'new', 'edit', 'create', 'update', 'destroy']\r
39       end\r
40       it 'これらのアクションが定義されている' do\r
41         set_actions? @actions, @actions_names\r
42       end\r
43       describe 'baseに於いて' do\r
44       end\r
45       describe 'indexに於いて' do\r
46         before do\r
47           @action = @actions['index']\r
48         end\r
49         it 'listタイプのアクションである' do\r
50           expect(@action.type).to eq 'list'\r
51         end\r
52         it 'マニフェストから設定を取り出している' do\r
53           # コマの公開リストを返すように定義している\r
54           set_list_action? @action, 'panel', 'public'\r
55         end\r
56       end\r
57       describe 'by_authorに於いて' do\r
58         before do\r
59           @action = @actions['by_author']\r
60         end\r
61         it 'listタイプのアクションである' do\r
62           expect(@action.type).to eq 'list'\r
63         end\r
64         it 'マニフェストから設定を取り出している' do\r
65           # コマの作家フィルタリストを返すように定義している\r
66           set_list_action? @action, 'panel', 'by_author'\r
67         end\r
68       end\r
69       describe 'by_scrollに於いて' do\r
70         before do\r
71           @action = @actions['by_scroll']\r
72         end\r
73         it 'listタイプのアクションである' do\r
74           expect(@action.type).to eq 'list'\r
75         end\r
76         it 'マニフェストから設定を取り出している' do\r
77           #コマのコマフィルタリストを返すように定義している\r
78           set_list_action? @action, 'panel', 'by_scroll'\r
79         end\r
80       end\r
81       describe 'by_sheetに於いて' do\r
82         before do\r
83           @action = @actions['by_sheet']\r
84         end\r
85         it 'listタイプのアクションである' do\r
86           expect(@action.type).to eq 'list'\r
87         end\r
88         it 'マニフェストから設定を取り出している' do\r
89           #コマのコマフィルタリストを返すように定義している\r
90           set_list_action? @action, 'panel', 'by_sheet'\r
91         end\r
92       end\r
93       describe 'by_speech_balloon_templateに於いて' do\r
94         before do\r
95           @action = @actions['by_speech_balloon_template']\r
96         end\r
97         it 'listタイプのアクションである' do\r
98           expect(@action.type).to eq 'list'\r
99         end\r
100         it 'マニフェストから設定を取り出している' do\r
101           #コマのコマフィルタリストを返すように定義している\r
102           set_list_action? @action, 'panel', 'by_speech_balloon_template'\r
103         end\r
104       end\r
105       describe 'showに於いて' do\r
106         before do\r
107           @action = @actions['show']\r
108         end\r
109         it 'showタイプのアクションである' do\r
110           expect(@action.type).to eq 'show'\r
111         end\r
112       end\r
113       describe 'countに於いて' do\r
114         before do\r
115           @action = @actions['count']\r
116         end\r
117         it 'countタイプのアクションである' do\r
118           expect(@action.type).to eq 'count'\r
119         end\r
120         it 'マニフェストから設定を取り出している' do\r
121           #コマの公開リストのカウントを返すように定義している\r
122           set_list_action? @action, 'panel', 'public'\r
123         end\r
124       end\r
125       describe 'count_by_authorに於いて' do\r
126         before do\r
127           @action = @actions['count_by_author']\r
128         end\r
129         it 'countタイプのアクションである' do\r
130           expect(@action.type).to eq 'count'\r
131         end\r
132         it 'マニフェストから設定を取り出している' do\r
133           # コマの作家フィルタリストのカウントを返すように定義している\r
134           set_list_action? @action, 'panel', 'by_author'\r
135         end\r
136       end\r
137       describe 'count_by_scrollに於いて' do\r
138         before do\r
139           @action = @actions['count_by_scroll']\r
140         end\r
141         it 'countタイプのアクションである' do\r
142           expect(@action.type).to eq 'count'\r
143         end\r
144         it 'マニフェストから設定を取り出している' do\r
145           # コマのコマフィルタリストのカウントを返すように定義している\r
146           set_list_action? @action, 'panel', 'by_scroll'\r
147         end\r
148       end\r
149       describe 'count_by_sheetに於いて' do\r
150         before do\r
151           @action = @actions['count_by_sheet']\r
152         end\r
153         it 'countタイプのアクションである' do\r
154           expect(@action.type).to eq 'count'\r
155         end\r
156         it 'マニフェストから設定を取り出している' do\r
157           # コマのコマフィルタリストのカウントを返すように定義している\r
158           set_list_action? @action, 'panel', 'by_sheet'\r
159         end\r
160       end\r
161       describe 'count_by_speech_balloon_templateに於いて' do\r
162         before do\r
163           @action = @actions['count_by_speech_balloon_template']\r
164         end\r
165         it 'countタイプのアクションである' do\r
166           expect(@action.type).to eq 'count'\r
167         end\r
168         it 'マニフェストから設定を取り出している' do\r
169           # コマのコマフィルタリストのカウントを返すように定義している\r
170           set_list_action? @action, 'panel', 'by_speech_balloon_template'\r
171         end\r
172       end\r
173       describe 'newに於いて' do\r
174         before do\r
175           @action = @actions['new']\r
176         end\r
177         it 'newタイプのアクションである' do\r
178           expect(@action.type).to eq 'new'\r
179         end\r
180         it 'type' do\r
181           expect(@action.item_name).to eq 'panel'\r
182         end\r
183       end\r
184       describe 'editに於いて' do\r
185         before do\r
186           @action = @actions['edit']\r
187         end\r
188         it 'editタイプのアクションである' do\r
189           expect(@action.type).to eq 'edit'\r
190         end\r
191         it 'type' do\r
192           expect(@action.item_name).to eq 'panel'\r
193         end\r
194       end\r
195       describe 'createに於いて' do\r
196         before do\r
197           @action = @actions['create']\r
198         end\r
199         it 'createタイプのアクションである' do\r
200           expect(@action.type).to eq 'create'\r
201         end\r
202         it 'type' do\r
203           expect(@action.item_name).to eq 'panel'\r
204         end\r
205       end\r
206       describe 'updateに於いて' do\r
207         before do\r
208           @action = @actions['update']\r
209         end\r
210         it 'updateタイプのアクションである' do\r
211           expect(@action.type).to eq 'update'\r
212         end\r
213         it 'type' do\r
214           expect(@action.item_name).to eq 'panel'\r
215         end\r
216       end\r
217       describe 'destroyに於いて' do\r
218         before do\r
219           @action = @actions['destroy']\r
220         end\r
221         it 'destroyタイプのアクションである' do\r
222           expect(@action.type).to eq 'destroy'\r
223         end\r
224         it 'type' do\r
225           expect(@action.item_name).to eq 'panel'\r
226         end\r
227       end\r
228     end\r
229     \r
230   end\r
231   \r
232   describe 'モデルに於いて' do\r
233     before do\r
234       @my_manifest = @model.my_manifest\r
235     end\r
236     it 'サポート機能が動作している' do\r
237       expect(@my_manifest.model_name).to eq 'panel'\r
238       expect(@my_manifest.classify).to eq @model\r
239       expect(@my_manifest.table_name).to eq 'panels'\r
240     end\r
241     \r
242     describe 'associationsに於いて' do\r
243       describe 'belongs_toに於いて' do\r
244         before do\r
245           @belongs_to = @my_manifest.associations.belongs_to\r
246           @names = ['author']\r
247         end\r
248         it 'これらのモデルに所属している' do\r
249           set_associations? @belongs_to, @names\r
250         end\r
251         describe 'authorに於いて' do\r
252           before do\r
253             @mani = @belongs_to['author']\r
254           end\r
255           it 'マニフェストから設定を取り出している' do\r
256             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
257             expect(@mani.model_name).to eq 'author'\r
258             expect(@mani.id_column).to eq 'author_id'\r
259           end\r
260           it 'サポート機能が動作している' do\r
261             # モデルを再現できている\r
262             expect(@mani.model).to eq Author\r
263           end\r
264         end\r
265       end\r
266       describe 'has_manyに於いて' do\r
267         before do\r
268           @has_many = @model.my_manifest.associations.has_many\r
269           @names = ['scroll_panels', 'scrolls', 'sheet_panels', 'sheets', \r
270           'panel_pictures', 'speech_balloons', 'ground_pictures', 'ground_colors']\r
271         end\r
272         it 'これらのモデルを所持している' do\r
273           set_associations? @has_many, @names\r
274         end\r
275         describe 'scroll_panelsに於いて' do\r
276           before do\r
277             @mani = @has_many['scroll_panels']\r
278           end\r
279           it 'マニフェストから設定を取り出している' do\r
280             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
281             expect(@mani.model_name).to eq 'scroll_panel'\r
282             expect(@mani.foreign_key).to eq 'panel_id'\r
283             expect(@mani.through).to be nil\r
284           end\r
285           it 'サポート機能が動作している' do\r
286             # モデルを再現できている, 中間モデルフラグ\r
287             expect(@mani.through?).to be false\r
288             expect(@mani.model).to eq ScrollPanel\r
289           end\r
290         end\r
291         describe 'scrollsに於いて' do\r
292           before do\r
293             @mani = @has_many['scrolls']\r
294           end\r
295           it 'マニフェストから設定を取り出している' do\r
296             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
297             expect(@mani.model_name).to eq 'scroll'\r
298             expect(@mani.foreign_key).to eq 'panel_id'\r
299             expect(@mani.through).to eq 'scroll_panels'\r
300           end\r
301           it 'サポート機能が動作している' do\r
302             # モデルを再現できている, 中間モデルフラグ\r
303             expect(@mani.through?).to be true\r
304             expect(@mani.model).to eq Scroll\r
305           end\r
306         end\r
307         describe 'sheet_panelsに於いて' do\r
308           before do\r
309             @mani = @has_many['sheet_panels']\r
310           end\r
311           it 'マニフェストから設定を取り出している' do\r
312             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
313             expect(@mani.model_name).to eq 'sheet_panel'\r
314             expect(@mani.foreign_key).to eq 'panel_id'\r
315             expect(@mani.through).to be nil\r
316           end\r
317           it 'サポート機能が動作している' do\r
318             # モデルを再現できている, 中間モデルフラグ\r
319             expect(@mani.through?).to be false\r
320             expect(@mani.model).to eq SheetPanel\r
321           end\r
322         end\r
323         describe 'sheetsに於いて' do\r
324           before do\r
325             @mani = @has_many['sheets']\r
326           end\r
327           it 'マニフェストから設定を取り出している' do\r
328             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
329             expect(@mani.model_name).to eq 'sheet'\r
330             expect(@mani.foreign_key).to eq 'panel_id'\r
331             expect(@mani.through).to eq 'sheet_panels'\r
332           end\r
333           it 'サポート機能が動作している' do\r
334             # モデルを再現できている, 中間モデルフラグ\r
335             expect(@mani.through?).to be true\r
336             expect(@mani.model).to eq Sheet\r
337           end\r
338         end\r
339         describe 'panel_picturesに於いて' do\r
340           before do\r
341             @mani = @has_many['panel_pictures']\r
342           end\r
343           it 'マニフェストから設定を取り出している' do\r
344             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
345             expect(@mani.model_name).to eq 'panel_picture'\r
346             expect(@mani.foreign_key).to eq 'panel_id'\r
347             expect(@mani.through).to be nil\r
348           end\r
349           it 'サポート機能が動作している' do\r
350             # モデルを再現できている, 中間モデルフラグ\r
351             expect(@mani.through?).to be false\r
352             expect(@mani.model).to eq PanelPicture\r
353           end\r
354         end\r
355         describe 'speech_balloonsに於いて' do\r
356           before do\r
357             @mani = @has_many['speech_balloons']\r
358           end\r
359           it 'マニフェストから設定を取り出している' do\r
360             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
361             expect(@mani.model_name).to eq 'speech_balloon'\r
362             expect(@mani.foreign_key).to eq 'panel_id'\r
363             expect(@mani.through).to be nil\r
364           end\r
365           it 'サポート機能が動作している' do\r
366             # モデルを再現できている, 中間モデルフラグ\r
367             expect(@mani.through?).to be false\r
368             expect(@mani.model).to eq SpeechBalloon\r
369           end\r
370         end\r
371         describe 'ground_picturesに於いて' do\r
372           before do\r
373             @mani = @has_many['ground_pictures']\r
374           end\r
375           it 'マニフェストから設定を取り出している' do\r
376             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
377             expect(@mani.model_name).to eq 'ground_picture'\r
378             expect(@mani.foreign_key).to eq 'panel_id'\r
379             expect(@mani.through).to be nil\r
380           end\r
381           it 'サポート機能が動作している' do\r
382             # モデルを再現できている, 中間モデルフラグ\r
383             expect(@mani.through?).to be false\r
384             expect(@mani.model).to eq GroundPicture\r
385           end\r
386         end\r
387         describe 'ground_colorsに於いて' do\r
388           before do\r
389             @mani = @has_many['ground_colors']\r
390           end\r
391           it 'マニフェストから設定を取り出している' do\r
392             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
393             expect(@mani.model_name).to eq 'ground_color'\r
394             expect(@mani.foreign_key).to eq 'panel_id'\r
395             expect(@mani.through).to be nil\r
396           end\r
397           it 'サポート機能が動作している' do\r
398             # モデルを再現できている, 中間モデルフラグ\r
399             expect(@mani.through?).to be false\r
400             expect(@mani.model).to eq GroundColor\r
401           end\r
402         end\r
403       end\r
404     end\r
405     \r
406     describe 'attributesに於いて' do\r
407       before do\r
408         @attributes = @model.my_manifest.attributes\r
409       end\r
410       it 'これらのカラムを定義している' do\r
411         set_attributes? @attributes, \r
412           ['id', 'width', 'height', 'border', 'caption', 'publish', 'author_id', \r
413           'created_at', 'updated_at']\r
414       end\r
415       describe 'widthに於いて' do\r
416         before do\r
417           @attribute = @attributes['width']\r
418         end\r
419         it 'numberタイプである' do\r
420           expect(@attribute.type).to eq 'number'\r
421         end\r
422       end\r
423       describe 'heightに於いて' do\r
424         before do\r
425           @attribute = @attributes['height']\r
426         end\r
427         it 'numberタイプである' do\r
428           expect(@attribute.type).to eq 'number'\r
429         end\r
430       end\r
431       describe 'borderに於いて' do\r
432         before do\r
433           @attribute = @attributes['border']\r
434         end\r
435         it 'numberタイプである' do\r
436           expect(@attribute.type).to eq 'number'\r
437         end\r
438       end\r
439       describe 'captionに於いて' do\r
440         before do\r
441           @attribute = @attributes['caption']\r
442         end\r
443         it 'textタイプである' do\r
444           expect(@attribute.type).to eq 'text'\r
445         end\r
446       end\r
447       describe 'publishに於いて' do\r
448         before do\r
449           @attribute = @attributes['publish']\r
450         end\r
451         it 'numberタイプである' do\r
452           expect(@attribute.type).to eq 'number'\r
453         end\r
454         it '選択肢を定数から取得できるように定義している' do\r
455           expect(@attribute.source.type).to eq 'magic_number'\r
456           expect(@attribute.source.select_item_name).to eq 'panel_publish_items'\r
457         end\r
458       end\r
459       describe 'author_idに於いて' do\r
460         before do\r
461           @attribute = @attributes['author_id']\r
462         end\r
463         it 'numberタイプである' do\r
464           expect(@attribute.type).to eq 'number'\r
465         end\r
466       end\r
467     end\r
468     \r
469   end\r
470   \r
471 end\r