1 # -*- encoding: utf-8 -*-
\r
2 require 'spec_helper'
\r
6 include ManifestsMacros
\r
11 describe 'ペタナイズに於いて' do
\r
13 expect(@model.ancestors.include?(Peta::Root)).to eq true
\r
16 expect(@model.my_peta.parent_model_name).to be_blank
\r
18 describe 'ブーストに於いて' do
\r
19 it '特筆すべき注意事項はない' do
\r
20 expect(@model.my_peta.boost.keys).to be_empty
\r
26 describe 'コントローラに於いて' do
\r
28 @controller = @model.my_controller
\r
30 it 'コマのためのコントローラである' do
\r
31 expect(@model.item_name).to eq 'panel'
\r
33 describe 'actionに於いて' 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
40 it 'これらのアクションが定義されている' do
\r
41 set_actions? @actions, @actions_names
\r
43 describe 'baseに於いて' do
\r
45 describe 'indexに於いて' do
\r
47 @action = @actions['index']
\r
49 it 'listタイプのアクションである' do
\r
50 expect(@action.type).to eq 'list'
\r
52 it 'マニフェストから設定を取り出している' do
\r
53 # コマの公開リストを返すように定義している
\r
54 set_list_action? @action, 'panel', 'public'
\r
57 describe 'by_authorに於いて' do
\r
59 @action = @actions['by_author']
\r
61 it 'listタイプのアクションである' do
\r
62 expect(@action.type).to eq 'list'
\r
64 it 'マニフェストから設定を取り出している' do
\r
65 # コマの作家フィルタリストを返すように定義している
\r
66 set_list_action? @action, 'panel', 'by_author'
\r
69 describe 'by_scrollに於いて' do
\r
71 @action = @actions['by_scroll']
\r
73 it 'listタイプのアクションである' do
\r
74 expect(@action.type).to eq 'list'
\r
76 it 'マニフェストから設定を取り出している' do
\r
77 #コマのコマフィルタリストを返すように定義している
\r
78 set_list_action? @action, 'panel', 'by_scroll'
\r
81 describe 'by_sheetに於いて' do
\r
83 @action = @actions['by_sheet']
\r
85 it 'listタイプのアクションである' do
\r
86 expect(@action.type).to eq 'list'
\r
88 it 'マニフェストから設定を取り出している' do
\r
89 #コマのコマフィルタリストを返すように定義している
\r
90 set_list_action? @action, 'panel', 'by_sheet'
\r
93 describe 'by_speech_balloon_templateに於いて' do
\r
95 @action = @actions['by_speech_balloon_template']
\r
97 it 'listタイプのアクションである' do
\r
98 expect(@action.type).to eq 'list'
\r
100 it 'マニフェストから設定を取り出している' do
\r
101 #コマのコマフィルタリストを返すように定義している
\r
102 set_list_action? @action, 'panel', 'by_speech_balloon_template'
\r
105 describe 'showに於いて' do
\r
107 @action = @actions['show']
\r
109 it 'showタイプのアクションである' do
\r
110 expect(@action.type).to eq 'show'
\r
113 describe 'countに於いて' do
\r
115 @action = @actions['count']
\r
117 it 'countタイプのアクションである' do
\r
118 expect(@action.type).to eq 'count'
\r
120 it 'マニフェストから設定を取り出している' do
\r
121 #コマの公開リストのカウントを返すように定義している
\r
122 set_list_action? @action, 'panel', 'public'
\r
125 describe 'count_by_authorに於いて' do
\r
127 @action = @actions['count_by_author']
\r
129 it 'countタイプのアクションである' do
\r
130 expect(@action.type).to eq 'count'
\r
132 it 'マニフェストから設定を取り出している' do
\r
133 # コマの作家フィルタリストのカウントを返すように定義している
\r
134 set_list_action? @action, 'panel', 'by_author'
\r
137 describe 'count_by_scrollに於いて' do
\r
139 @action = @actions['count_by_scroll']
\r
141 it 'countタイプのアクションである' do
\r
142 expect(@action.type).to eq 'count'
\r
144 it 'マニフェストから設定を取り出している' do
\r
145 # コマのコマフィルタリストのカウントを返すように定義している
\r
146 set_list_action? @action, 'panel', 'by_scroll'
\r
149 describe 'count_by_sheetに於いて' do
\r
151 @action = @actions['count_by_sheet']
\r
153 it 'countタイプのアクションである' do
\r
154 expect(@action.type).to eq 'count'
\r
156 it 'マニフェストから設定を取り出している' do
\r
157 # コマのコマフィルタリストのカウントを返すように定義している
\r
158 set_list_action? @action, 'panel', 'by_sheet'
\r
161 describe 'count_by_speech_balloon_templateに於いて' do
\r
163 @action = @actions['count_by_speech_balloon_template']
\r
165 it 'countタイプのアクションである' do
\r
166 expect(@action.type).to eq 'count'
\r
168 it 'マニフェストから設定を取り出している' do
\r
169 # コマのコマフィルタリストのカウントを返すように定義している
\r
170 set_list_action? @action, 'panel', 'by_speech_balloon_template'
\r
173 describe 'newに於いて' do
\r
175 @action = @actions['new']
\r
177 it 'newタイプのアクションである' do
\r
178 expect(@action.type).to eq 'new'
\r
181 expect(@action.item_name).to eq 'panel'
\r
184 describe 'editに於いて' do
\r
186 @action = @actions['edit']
\r
188 it 'editタイプのアクションである' do
\r
189 expect(@action.type).to eq 'edit'
\r
192 expect(@action.item_name).to eq 'panel'
\r
195 describe 'createに於いて' do
\r
197 @action = @actions['create']
\r
199 it 'createタイプのアクションである' do
\r
200 expect(@action.type).to eq 'create'
\r
203 expect(@action.item_name).to eq 'panel'
\r
206 describe 'updateに於いて' do
\r
208 @action = @actions['update']
\r
210 it 'updateタイプのアクションである' do
\r
211 expect(@action.type).to eq 'update'
\r
214 expect(@action.item_name).to eq 'panel'
\r
217 describe 'destroyに於いて' do
\r
219 @action = @actions['destroy']
\r
221 it 'destroyタイプのアクションである' do
\r
222 expect(@action.type).to eq 'destroy'
\r
225 expect(@action.item_name).to eq 'panel'
\r
232 describe 'モデルに於いて' do
\r
234 @my_manifest = @model.my_manifest
\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
242 describe 'associationsに於いて' do
\r
243 describe 'belongs_toに於いて' do
\r
245 @belongs_to = @my_manifest.associations.belongs_to
\r
246 @names = ['author']
\r
248 it 'これらのモデルに所属している' do
\r
249 set_associations? @belongs_to, @names
\r
251 describe 'authorに於いて' do
\r
253 @mani = @belongs_to['author']
\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
260 it 'サポート機能が動作している' do
\r
262 expect(@mani.model).to eq Author
\r
266 describe 'has_manyに於いて' 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
272 it 'これらのモデルを所持している' do
\r
273 set_associations? @has_many, @names
\r
275 describe 'scroll_panelsに於いて' do
\r
277 @mani = @has_many['scroll_panels']
\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
285 it 'サポート機能が動作している' do
\r
286 # モデルを再現できている, 中間モデルフラグ
\r
287 expect(@mani.through?).to be false
\r
288 expect(@mani.model).to eq ScrollPanel
\r
291 describe 'scrollsに於いて' do
\r
293 @mani = @has_many['scrolls']
\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
301 it 'サポート機能が動作している' do
\r
302 # モデルを再現できている, 中間モデルフラグ
\r
303 expect(@mani.through?).to be true
\r
304 expect(@mani.model).to eq Scroll
\r
307 describe 'sheet_panelsに於いて' do
\r
309 @mani = @has_many['sheet_panels']
\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
317 it 'サポート機能が動作している' do
\r
318 # モデルを再現できている, 中間モデルフラグ
\r
319 expect(@mani.through?).to be false
\r
320 expect(@mani.model).to eq SheetPanel
\r
323 describe 'sheetsに於いて' do
\r
325 @mani = @has_many['sheets']
\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
333 it 'サポート機能が動作している' do
\r
334 # モデルを再現できている, 中間モデルフラグ
\r
335 expect(@mani.through?).to be true
\r
336 expect(@mani.model).to eq Sheet
\r
339 describe 'panel_picturesに於いて' do
\r
341 @mani = @has_many['panel_pictures']
\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
349 it 'サポート機能が動作している' do
\r
350 # モデルを再現できている, 中間モデルフラグ
\r
351 expect(@mani.through?).to be false
\r
352 expect(@mani.model).to eq PanelPicture
\r
355 describe 'speech_balloonsに於いて' do
\r
357 @mani = @has_many['speech_balloons']
\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
365 it 'サポート機能が動作している' do
\r
366 # モデルを再現できている, 中間モデルフラグ
\r
367 expect(@mani.through?).to be false
\r
368 expect(@mani.model).to eq SpeechBalloon
\r
371 describe 'ground_picturesに於いて' do
\r
373 @mani = @has_many['ground_pictures']
\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
381 it 'サポート機能が動作している' do
\r
382 # モデルを再現できている, 中間モデルフラグ
\r
383 expect(@mani.through?).to be false
\r
384 expect(@mani.model).to eq GroundPicture
\r
387 describe 'ground_colorsに於いて' do
\r
389 @mani = @has_many['ground_colors']
\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
397 it 'サポート機能が動作している' do
\r
398 # モデルを再現できている, 中間モデルフラグ
\r
399 expect(@mani.through?).to be false
\r
400 expect(@mani.model).to eq GroundColor
\r
406 describe 'attributesに於いて' do
\r
408 @attributes = @model.my_manifest.attributes
\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
415 describe 'widthに於いて' do
\r
417 @attribute = @attributes['width']
\r
419 it 'numberタイプである' do
\r
420 expect(@attribute.type).to eq 'number'
\r
423 describe 'heightに於いて' do
\r
425 @attribute = @attributes['height']
\r
427 it 'numberタイプである' do
\r
428 expect(@attribute.type).to eq 'number'
\r
431 describe 'borderに於いて' do
\r
433 @attribute = @attributes['border']
\r
435 it 'numberタイプである' do
\r
436 expect(@attribute.type).to eq 'number'
\r
439 describe 'captionに於いて' do
\r
441 @attribute = @attributes['caption']
\r
444 expect(@attribute.type).to eq 'text'
\r
447 describe 'publishに於いて' do
\r
449 @attribute = @attributes['publish']
\r
451 it 'numberタイプである' do
\r
452 expect(@attribute.type).to eq 'number'
\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
459 describe 'author_idに於いて' do
\r
461 @attribute = @attributes['author_id']
\r
463 it 'numberタイプである' do
\r
464 expect(@attribute.type).to eq 'number'
\r