OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / license_spec.rb
index cc30eeb..71a3400 100644 (file)
@@ -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 'ã\82¹ã\82¯ã\83­ã\83¼ã\83«のためのコントローラである' do
-      expect(@model.item_name).to eq 'scroll'
+    it 'ã\83©ã\82¤ã\82»ã\83³ã\82¹のためのコントローラである' 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
-          # ã\82¹ã\82¯ã\83­ã\83¼ã\83«の公開リストを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          # ã\83©ã\82¤ã\82»ã\83³ã\82¹の公開リストを返すように定義している
+          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
-          # ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ä½\9c家フィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+          # ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81®ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97 フィルタリストを返すように定義している
+          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
-          #ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ã\82³ã\83\9eフィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          #ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81®ã\82·ã\82¹ã\83\86ã\83 ç\94»å\83\8fフィルタリストを返すように定義している
+          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
-          #ã\82¹ã\82¯ã\83­ã\83¼ã\83«の公開リストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          #ã\83©ã\82¤ã\82»ã\83³ã\82¹の公開リストのカウントを返すように定義している
+          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
-          # ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ä½\9c家フィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+          # ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81®ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\82°ã\83«ã\83¼ã\83\97 フィルタリストのカウントを返すように定義している
+          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
-          # ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ã\82³ã\83\9eフィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          # ã\83©ã\82¤ã\82»ã\83³ã\82¹ã\81®ã\82·ã\82¹ã\83\86ã\83 ç\94»å\83\8fフィルタリストのカウントを返すように定義している
+          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