--- /dev/null
+# -*- encoding: utf-8 -*-\r
+require 'spec_helper'\r
+#コマ\r
+\r
+describe Panel do\r
+ include ManifestsMacros\r
+ before do\r
+ @model = Panel\r
+ end\r
+ \r
+ describe 'ペタナイズに於いて' do\r
+ it 'ルートである' do\r
+ expect(@model.ancestors.include?(Peta::Root)).to eq true\r
+ end\r
+ it '親モデルは持たない' do\r
+ expect(@model.my_peta.parent_model_name).to be_blank\r
+ end\r
+ describe 'ブーストに於いて' do\r
+ it '特筆すべき注意事項はない' do\r
+ expect(@model.my_peta.boost.keys).to be_empty\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+ describe 'コントローラに於いて' do\r
+ before do\r
+ @controller = @model.my_controller\r
+ end\r
+ it 'コマのためのコントローラである' do\r
+ expect(@model.item_name).to eq 'panel'\r
+ end\r
+ describe 'actionに於いて' do\r
+ before do\r
+ @actions = @controller.actions\r
+ @actions_names = ['index', 'by_author', 'by_scroll', 'by_sheet', 'by_speech_balloon_template', 'show', \r
+ 'count', 'count_by_author', 'count_by_scroll', 'count_by_sheet', 'count_by_speech_balloon_template', \r
+ 'new', 'edit', 'create', 'update', 'destroy']\r
+ end\r
+ it 'これらのアクションが定義されている' do\r
+ set_actions? @actions, @actions_names\r
+ end\r
+ describe 'baseに於いて' do\r
+ end\r
+ describe 'indexに於いて' do\r
+ before do\r
+ @action = @actions['index']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマの公開リストを返すように定義している\r
+ set_list_action? @action, 'panel', 'public'\r
+ end\r
+ end\r
+ describe 'by_authorに於いて' do\r
+ before do\r
+ @action = @actions['by_author']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマの作家フィルタリストを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_author'\r
+ end\r
+ end\r
+ describe 'by_scrollに於いて' do\r
+ before do\r
+ @action = @actions['by_scroll']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #コマのコマフィルタリストを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_scroll'\r
+ end\r
+ end\r
+ describe 'by_sheetに於いて' do\r
+ before do\r
+ @action = @actions['by_sheet']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #コマのコマフィルタリストを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_sheet'\r
+ end\r
+ end\r
+ describe 'by_speech_balloon_templateに於いて' do\r
+ before do\r
+ @action = @actions['by_speech_balloon_template']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #コマのコマフィルタリストを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_speech_balloon_template'\r
+ end\r
+ end\r
+ describe 'showに於いて' do\r
+ before do\r
+ @action = @actions['show']\r
+ end\r
+ it 'showタイプのアクションである' do\r
+ expect(@action.type).to eq 'show'\r
+ end\r
+ end\r
+ describe 'countに於いて' do\r
+ before do\r
+ @action = @actions['count']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #コマの公開リストのカウントを返すように定義している\r
+ set_list_action? @action, 'panel', 'public'\r
+ end\r
+ end\r
+ describe 'count_by_authorに於いて' do\r
+ before do\r
+ @action = @actions['count_by_author']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマの作家フィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_author'\r
+ end\r
+ end\r
+ describe 'count_by_scrollに於いて' do\r
+ before do\r
+ @action = @actions['count_by_scroll']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマのコマフィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_scroll'\r
+ end\r
+ end\r
+ describe 'count_by_sheetに於いて' do\r
+ before do\r
+ @action = @actions['count_by_sheet']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマのコマフィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_sheet'\r
+ end\r
+ end\r
+ describe 'count_by_speech_balloon_templateに於いて' do\r
+ before do\r
+ @action = @actions['count_by_speech_balloon_template']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # コマのコマフィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'panel', 'by_speech_balloon_template'\r
+ end\r
+ end\r
+ describe 'newに於いて' do\r
+ before do\r
+ @action = @actions['new']\r
+ end\r
+ it 'newタイプのアクションである' do\r
+ expect(@action.type).to eq 'new'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'panel'\r
+ end\r
+ end\r
+ describe 'editに於いて' do\r
+ before do\r
+ @action = @actions['edit']\r
+ end\r
+ it 'editタイプのアクションである' do\r
+ expect(@action.type).to eq 'edit'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'panel'\r
+ end\r
+ end\r
+ describe 'createに於いて' do\r
+ before do\r
+ @action = @actions['create']\r
+ end\r
+ it 'createタイプのアクションである' do\r
+ expect(@action.type).to eq 'create'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'panel'\r
+ end\r
+ end\r
+ describe 'updateに於いて' do\r
+ before do\r
+ @action = @actions['update']\r
+ end\r
+ it 'updateタイプのアクションである' do\r
+ expect(@action.type).to eq 'update'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'panel'\r
+ end\r
+ end\r
+ describe 'destroyに於いて' do\r
+ before do\r
+ @action = @actions['destroy']\r
+ end\r
+ it 'destroyタイプのアクションである' do\r
+ expect(@action.type).to eq 'destroy'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'panel'\r
+ end\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+ describe 'モデルに於いて' do\r
+ before do\r
+ @my_manifest = @model.my_manifest\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ expect(@my_manifest.model_name).to eq 'panel'\r
+ expect(@my_manifest.classify).to eq @model\r
+ expect(@my_manifest.table_name).to eq 'panels'\r
+ end\r
+ \r
+ describe 'associationsに於いて' do\r
+ describe 'belongs_toに於いて' do\r
+ before do\r
+ @belongs_to = @my_manifest.associations.belongs_to\r
+ @names = ['author']\r
+ end\r
+ it 'これらのモデルに所属している' do\r
+ set_associations? @belongs_to, @names\r
+ end\r
+ describe 'authorに於いて' do\r
+ before do\r
+ @mani = @belongs_to['author']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'author'\r
+ expect(@mani.id_column).to eq 'author_id'\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている\r
+ expect(@mani.model).to eq Author\r
+ end\r
+ end\r
+ end\r
+ describe 'has_manyに於いて' do\r
+ before do\r
+ @has_many = @model.my_manifest.associations.has_many\r
+ @names = ['scroll_panels', 'scrolls', 'sheet_panels', 'sheets', \r
+ 'panel_pictures', 'speech_balloons', 'ground_pictures', 'ground_colors']\r
+ end\r
+ it 'これらのモデルを所持している' do\r
+ set_associations? @has_many, @names\r
+ end\r
+ describe 'scroll_panelsに於いて' do\r
+ before do\r
+ @mani = @has_many['scroll_panels']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'scroll_panel'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq ScrollPanel\r
+ end\r
+ end\r
+ describe 'scrollsに於いて' do\r
+ before do\r
+ @mani = @has_many['scrolls']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'scroll'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to eq 'scroll_panels'\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be true\r
+ expect(@mani.model).to eq Scroll\r
+ end\r
+ end\r
+ describe 'sheet_panelsに於いて' do\r
+ before do\r
+ @mani = @has_many['sheet_panels']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'sheet_panel'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq SheetPanel\r
+ end\r
+ end\r
+ describe 'sheetsに於いて' do\r
+ before do\r
+ @mani = @has_many['sheets']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'sheet'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to eq 'sheet_panels'\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be true\r
+ expect(@mani.model).to eq Sheet\r
+ end\r
+ end\r
+ describe 'panel_picturesに於いて' do\r
+ before do\r
+ @mani = @has_many['panel_pictures']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'panel_picture'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq PanelPicture\r
+ end\r
+ end\r
+ describe 'speech_balloonsに於いて' do\r
+ before do\r
+ @mani = @has_many['speech_balloons']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'speech_balloon'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq SpeechBalloon\r
+ end\r
+ end\r
+ describe 'ground_picturesに於いて' do\r
+ before do\r
+ @mani = @has_many['ground_pictures']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'ground_picture'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq GroundPicture\r
+ end\r
+ end\r
+ describe 'ground_colorsに於いて' do\r
+ before do\r
+ @mani = @has_many['ground_colors']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'ground_color'\r
+ expect(@mani.foreign_key).to eq 'panel_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq GroundColor\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe 'attributesに於いて' do\r
+ before do\r
+ @attributes = @model.my_manifest.attributes\r
+ end\r
+ it 'これらのカラムを定義している' do\r
+ set_attributes? @attributes, \r
+ ['id', 'width', 'height', 'border', 'caption', 'publish', 'author_id', \r
+ 'created_at', 'updated_at']\r
+ end\r
+ describe 'widthに於いて' do\r
+ before do\r
+ @attribute = @attributes['width']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ end\r
+ describe 'heightに於いて' do\r
+ before do\r
+ @attribute = @attributes['height']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ end\r
+ describe 'borderに於いて' do\r
+ before do\r
+ @attribute = @attributes['border']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ end\r
+ describe 'captionに於いて' do\r
+ before do\r
+ @attribute = @attributes['caption']\r
+ end\r
+ it 'textタイプである' do\r
+ expect(@attribute.type).to eq 'text'\r
+ end\r
+ end\r
+ describe 'publishに於いて' do\r
+ before do\r
+ @attribute = @attributes['publish']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ it '選択肢を定数から取得できるように定義している' do\r
+ expect(@attribute.source.type).to eq 'magic_number'\r
+ expect(@attribute.source.select_item_name).to eq 'panel_publish_items'\r
+ end\r
+ end\r
+ describe 'author_idに於いて' do\r
+ before do\r
+ @attribute = @attributes['author_id']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+end\r