X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=spec%2Fmanifests%2Flicense_spec.rb;h=71a34004b72759b75b37084d1e1ad3ac8e6f5117;hb=18a9968f3ae8f024ba24f917969ac541ef403a5e;hp=cc30eeb2ea3332a5d9c4eacf45ee467febca4bc9;hpb=65cd4fb912cd3ecd5772dc8581429c44550c941a;p=pettanr%2Fpettanr.git diff --git a/spec/manifests/license_spec.rb b/spec/manifests/license_spec.rb index cc30eeb2..71a34004 100644 --- a/spec/manifests/license_spec.rb +++ b/spec/manifests/license_spec.rb @@ -9,15 +9,61 @@ describe License do end describe 'ペタナイズに於いて' do - it 'スクコマを閉じるためのバインダーである' do - expect(@model.ancestors.include?(Peta::Binder)).to eq true + it 'ライセンスグループの内訳。管理者がメンテナンスするアイテムなので、システムリソースにあたる' do + # テンプレート要件を満たしていないので、テンプレートではない。 + # ライセンスグループに所属しているが、親はバインダーでもなく、ルートでもない。 + # リーフやエレメントとして振る舞うこともできないので、 + # システムリソースとして扱うのが妥当か。 + expect(@model.ancestors.include?(Peta::SystemResource)).to eq true end it '親モデルは持たない' do expect(@model.my_peta.parent_model_name).to be_blank end describe 'ブーストに於いて' do - it '特筆すべき注意事項はない' do - expect(@model.my_peta.boost.keys).to be_empty + before do + @boosts = @model.my_peta.boost + @boosts_names = ['license_group', 'credit_picture'] + end + it 'これらのブーストが定義されている' do + set_boosts? @boosts, @boosts_names + end + describe 'ライセンスフラグに於いて' do + before do + @mani = @boosts['license_group'] + end + it 'システム起動前に初期化可能なサポート機能が動作している' do + expect(@mani.level).to eq 'post' + expect(@mani.template_name).to eq 'license_group' + expect(@mani.column_name_for_template_module).to eq 'license_group_module_name' + expect(@mani.settings_column_name).to eq 'license_group_settings' + expect(@mani.foreign_key).to eq 'license_group_id' + end + it 'システム起動後にしか初期化できないサポート機能が動作している' do + expect(@mani.item_name_for_extend_model).to eq 'license' + expect(@mani.setter_method_name).to eq 'license_extend=' + expect(@mani.getter_method_name).to eq 'license_extend' + expect(@mani.extend_model_class_name).to eq 'License' + expect(@mani.extend_module_name).to eq 'LicenseModule' + end + end + describe 'クレジットの表示に必要な情報に於いて' do + before do + @mani = @boosts['credit_picture'] + end + it 'システム起動前に初期化可能なサポート機能が動作している' do + expect(@mani.level).to eq 'read' + expect(@mani.template_name).to eq 'license_group' + expect(@mani.column_name_for_template_module).to eq 'license_group_module_name' + expect(@mani.settings_column_name).to eq 'credit_picture_settings' + expect(@mani.foreign_key).to eq 'license_group_id' + end + it 'システム起動後にしか初期化できないサポート機能が動作している' do + expect(@mani.item_name_for_extend_model).to eq 'credit_picture' + expect(@mani.setter_method_name).to eq 'credit_picture_extend=' + expect(@mani.getter_method_name).to eq 'credit_picture_extend' + expect(@mani.extend_model_class_name).to eq 'CreditPicture' + expect(@mani.extend_module_name).to eq 'CreditPictureModule' + end end end @@ -27,14 +73,14 @@ describe License do before do @controller = @model.my_controller end - it 'スクロールのためのコントローラである' do - expect(@model.item_name).to eq 'scroll' + it 'ライセンスのためのコントローラである' do + expect(@model.item_name).to eq 'license' end describe 'actionに於いて' do before do @actions = @controller.actions - @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', - 'count', 'count_by_author', 'count_by_panel', + @actions_names = ['index', 'by_license_group', 'by_system_picture', 'show', + 'count', 'count_by_license_group', 'count_by_system_picture', 'new', 'edit', 'create', 'update', 'destroy'] end it 'これらのアクションが定義されている' do @@ -50,32 +96,32 @@ describe License do expect(@action.type).to eq 'list' end it 'マニフェストから設定を取り出している' do - # スクロールの公開リストを返すように定義している - set_list_action? @action, 'scroll', 'public' + # ライセンスの公開リストを返すように定義している + set_list_action? @action, 'license', 'public' end end - describe 'by_authorに於いて' do + describe 'by_license_groupに於いて' do before do - @action = @actions['by_author'] + @action = @actions['by_license_group'] end it 'listタイプのアクションである' do expect(@action.type).to eq 'list' end it 'マニフェストから設定を取り出している' do - # スクロールの作家フィルタリストを返すように定義している - set_list_action? @action, 'scroll', 'by_author' + # ライセンスのライセンスグループ フィルタリストを返すように定義している + set_list_action? @action, 'license', 'by_license_group' end end - describe 'by_panelに於いて' do + describe 'by_system_pictureに於いて' do before do - @action = @actions['by_panel'] + @action = @actions['by_system_picture'] end it 'listタイプのアクションである' do expect(@action.type).to eq 'list' end it 'マニフェストから設定を取り出している' do - #スクロールのコマフィルタリストを返すように定義している - set_list_action? @action, 'scroll', 'by_panel' + #ライセンスのシステム画像フィルタリストを返すように定義している + set_list_action? @action, 'license', 'by_system_picture' end end describe 'countに於いて' do @@ -86,32 +132,40 @@ describe License do expect(@action.type).to eq 'count' end it 'マニフェストから設定を取り出している' do - #スクロールの公開リストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'public' + #ライセンスの公開リストのカウントを返すように定義している + set_list_action? @action, 'license', 'public' end end - describe 'count_by_authorに於いて' do + describe 'showに於いて' do before do - @action = @actions['count_by_author'] + @action = @actions['show'] + end + it 'showタイプのアクションである' do + expect(@action.type).to eq 'show' + end + end + describe 'count_by_license_groupに於いて' do + before do + @action = @actions['count_by_license_group'] end it 'countタイプのアクションである' do expect(@action.type).to eq 'count' end it 'マニフェストから設定を取り出している' do - # スクロールの作家フィルタリストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'by_author' + # ライセンスのライセンスグループ フィルタリストのカウントを返すように定義している + set_list_action? @action, 'license', 'by_license_group' end end - describe 'count_by_panelに於いて' do + describe 'count_by_system_pictureに於いて' do before do - @action = @actions['count_by_panel'] + @action = @actions['count_by_system_picture'] end it 'countタイプのアクションである' do expect(@action.type).to eq 'count' end it 'マニフェストから設定を取り出している' do - # スクロールのコマフィルタリストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'by_panel' + # ライセンスのシステム画像フィルタリストのカウントを返すように定義している + set_list_action? @action, 'license', 'by_system_picture' end end describe 'newに於いて' do @@ -122,7 +176,7 @@ describe License do expect(@action.type).to eq 'new' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'license' end end describe 'editに於いて' do @@ -133,7 +187,7 @@ describe License do expect(@action.type).to eq 'edit' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'license' end end describe 'createに於いて' do @@ -144,7 +198,7 @@ describe License do expect(@action.type).to eq 'create' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'license' end end describe 'updateに於いて' do @@ -155,7 +209,7 @@ describe License do expect(@action.type).to eq 'update' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'license' end end describe 'destroyに於いて' do @@ -166,7 +220,7 @@ describe License do expect(@action.type).to eq 'destroy' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'license' end end end @@ -178,73 +232,71 @@ describe License do @my_manifest = @model.my_manifest end it 'サポート機能が動作している' do - expect(@my_manifest.model_name).to eq 'scroll' + expect(@my_manifest.model_name).to eq 'license' expect(@my_manifest.classify).to eq @model - expect(@my_manifest.table_name).to eq 'scrolls' + expect(@my_manifest.table_name).to eq 'licenses' end describe 'associationsに於いて' do describe 'belongs_toに於いて' do before do @belongs_to = @my_manifest.associations.belongs_to - @names = ['author'] + @names = ['license_group', 'system_picture'] end it 'これらのモデルに所属している' do set_associations? @belongs_to, @names end - describe 'authorに於いて' do + describe 'license_groupに於いて' do before do - @mani = @belongs_to['author'] + @mani = @belongs_to['license_group'] end it 'マニフェストから設定を取り出している' do # モデル名と外部キーが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'author' - expect(@mani.id_column).to eq 'author_id' + expect(@mani.model_name).to eq 'license_group' + expect(@mani.id_column).to eq 'license_group_id' end it 'サポート機能が動作している' do # モデルを再現できている - expect(@mani.model).to eq Author + expect(@mani.model).to eq LicenseGroup + end + end + describe 'system_pictureに於いて' do + before do + @mani = @belongs_to['system_picture'] + end + it 'マニフェストから設定を取り出している' do + # モデル名と外部キーが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'system_picture' + expect(@mani.id_column).to eq 'system_picture_id' + end + it 'サポート機能が動作している' do + # モデルを再現できている + expect(@mani.model).to eq SystemPicture end end end describe 'has_manyに於いて' do before do @has_many = @model.my_manifest.associations.has_many - @names = ['scroll_panels', 'panels'] + @names = ['resource_pictures'] end it 'これらのモデルを所持している' do set_associations? @has_many, @names end - describe 'scroll_panelsに於いて' do + describe 'resource_picturesに於いて' do before do - @mani = @has_many['scroll_panels'] + @mani = @has_many['resource_pictures'] end it 'マニフェストから設定を取り出している' do # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'scroll_panel' - expect(@mani.foreign_key).to eq 'scroll_id' + expect(@mani.model_name).to eq 'resource_picture' + expect(@mani.foreign_key).to eq 'license_id' expect(@mani.through).to be nil end it 'サポート機能が動作している' do # モデルを再現できている, 中間モデルフラグ expect(@mani.through?).to be false - expect(@mani.model).to eq ScrollPanel - end - end - describe 'panelsに於いて' do - before do - @mani = @has_many['panels'] - end - it 'マニフェストから設定を取り出している' do - # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'panel' - expect(@mani.foreign_key).to eq 'scroll_id' - expect(@mani.through).to eq 'scroll_panels' - end - it 'サポート機能が動作している' do - # モデルを再現できている, 中間モデルフラグ - expect(@mani.through?).to be true - expect(@mani.model).to eq Panel + expect(@mani.model).to eq ResourcePicture end end end @@ -256,43 +308,73 @@ describe License do end it 'これらのカラムを定義している' do set_attributes? @attributes, - ['id', 'title', 'description', 'visible', 'author_id', + ['id', 'license_group_id', 'license_group_module_name', + 'name', 'caption', 'system_picture_id', 'url', + 'license_group_settings', 'credit_picture_settings', 'created_at', 'updated_at'] end - describe 'titleに於いて' do + describe 'license_group_idに於いて' do + before do + @attribute = @attributes['license_group_id'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + describe 'license_group_module_nameに於いて' do before do - @attribute = @attributes['title'] + @attribute = @attributes['license_group_module_name'] end it 'textタイプである' do expect(@attribute.type).to eq 'text' end end - describe 'descriptionに於いて' do + describe 'nameに於いて' do before do - @attribute = @attributes['description'] + @attribute = @attributes['name'] end it 'textタイプである' do expect(@attribute.type).to eq 'text' end end - describe 'visibleに於いて' do + describe 'captionに於いて' do before do - @attribute = @attributes['visible'] + @attribute = @attributes['caption'] + end + it 'textタイプである' do + expect(@attribute.type).to eq 'text' + end + end + describe 'system_picture_idに於いて' do + before do + @attribute = @attributes['system_picture_id'] end it 'numberタイプである' do expect(@attribute.type).to eq 'number' end - it '選択肢を定数から取得できるように定義している' do - expect(@attribute.source.type).to eq 'magic_number' - expect(@attribute.source.select_item_name).to eq 'scroll_visible_items' + end + describe 'urlに於いて' do + before do + @attribute = @attributes['url'] + end + it 'textタイプである' do + expect(@attribute.type).to eq 'text' end end - describe 'author_idに於いて' do + describe 'license_group_settingsに於いて' do before do - @attribute = @attributes['author_id'] + @attribute = @attributes['license_group_settings'] end - it 'numberタイプである' do - expect(@attribute.type).to eq 'number' + it 'textタイプである' do + expect(@attribute.type).to eq 'text' + end + end + describe 'credit_picture_settingsに於いて' do + before do + @attribute = @attributes['credit_picture_settings'] + end + it 'textタイプである' do + expect(@attribute.type).to eq 'text' end end end