OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / resource_picture_spec.rb
index 309fdd8..9081483 100644 (file)
@@ -9,15 +9,76 @@ describe ResourcePicture do
   end\r
   \r
   describe 'ペタナイズに於いて' do\r
-    it 'スクコマを閉じるためのバインダーである' do\r
-      expect(@model.ancestors.include?(Peta::Binder)).to eq true\r
+    it '絵師が投稿するコンテンツである' do\r
+      expect(@model.ancestors.include?(Peta::Content)).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
+      before do\r
+        @boosts = @model.my_peta.boost\r
+        @boosts_names = ['license_group', 'license', 'credit_picture']\r
+      end\r
+      it 'これらのブーストが定義されている' do\r
+        set_boosts? @boosts, @boosts_names\r
+      end\r
+      describe 'ライセンスグループに於いて' do\r
+        before do\r
+          @mani = @boosts['license_group']\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.level).to eq 'post'\r
+          expect(@mani.template_name).to eq 'license_group'\r
+          expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
+          expect(@mani.settings_column_name).to eq 'license_group_settings'\r
+          expect(@mani.foreign_key).to eq 'license_group_id'\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.item_name_for_extend_model).to eq 'license'\r
+          expect(@mani.setter_method_name).to eq 'license_extend='\r
+          expect(@mani.getter_method_name).to eq 'license_extend'\r
+          expect(@mani.extend_model_class_name).to eq 'License'\r
+          expect(@mani.extend_module_name).to eq 'LicenseModule'\r
+        end\r
+      end\r
+      describe 'ライセンスに於いて' do\r
+        before do\r
+          @mani = @boosts['license']\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.level).to eq 'read'\r
+          expect(@mani.template_name).to eq 'license_group'\r
+          expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
+          expect(@mani.settings_column_name).to eq 'license_settings'\r
+          expect(@mani.foreign_key).to eq 'license_group_id'\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.item_name_for_extend_model).to eq 'attribute'\r
+          expect(@mani.setter_method_name).to eq 'attribute_extend='\r
+          expect(@mani.getter_method_name).to eq 'attribute_extend'\r
+          expect(@mani.extend_model_class_name).to eq 'Attribute'\r
+          expect(@mani.extend_module_name).to eq 'AttributeModule'\r
+        end\r
+      end\r
+      describe 'クレジットに於いて' do\r
+        before do\r
+          @mani = @boosts['credit_picture']\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.level).to eq 'read'\r
+          expect(@mani.template_name).to eq 'license_group'\r
+          expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
+          expect(@mani.settings_column_name).to eq 'credit_picture_settings'\r
+          expect(@mani.foreign_key).to eq 'license_group_id'\r
+        end\r
+        it 'フキダシテンプレート' do\r
+          expect(@mani.item_name_for_extend_model).to eq 'credit_picture'\r
+          expect(@mani.setter_method_name).to eq 'credit_picture_extend='\r
+          expect(@mani.getter_method_name).to eq 'credit_picture_extend'\r
+          expect(@mani.extend_model_class_name).to eq 'CreditPicture'\r
+          expect(@mani.extend_module_name).to eq 'CreditPictureModule'\r
+        end\r
       end\r
     end\r
     \r
@@ -27,15 +88,14 @@ describe ResourcePicture do
     before do\r
       @controller = @model.my_controller\r
     end\r
-    it 'スクロールのためのコントローラである' do\r
-      expect(@model.item_name).to eq 'scroll'\r
+    it '実素材のためのコントローラである' do\r
+      expect(@model.item_name).to eq 'resource_picture'\r
     end\r
     describe 'actionに於いて' do\r
       before do\r
         @actions = @controller.actions\r
-        @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', \r
-          'count', 'count_by_author', 'count_by_panel', \r
-          'new', 'edit', 'create', 'update', 'destroy']\r
+        @actions_names = ['index', 'by_license_group', 'by_license', 'by_artist', 'show', \r
+          'count', 'count_by_license_group', 'count_by_license', 'count_by_artist']\r
       end\r
       it 'これらのアクションが定義されている' do\r
         set_actions? @actions, @actions_names\r
@@ -50,123 +110,100 @@ describe ResourcePicture do
           expect(@action.type).to eq 'list'\r
         end\r
         it 'マニフェストから設定を取り出している' do\r
-          # スクロールの公開リストを返すように定義している\r
-          set_list_action? @action, 'scroll', 'public'\r
+          # 素材の公開リストを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'public'\r
         end\r
       end\r
-      describe 'by_authorに於いて' do\r
+      describe 'by_license_groupに於いて' do\r
         before do\r
-          @action = @actions['by_author']\r
+          @action = @actions['by_license_group']\r
         end\r
         it 'listタイプのアクションである' do\r
           expect(@action.type).to eq 'list'\r
         end\r
         it 'マニフェストから設定を取り出している' do\r
-          # スクロールの作家フィルタリストを返すように定義している\r
-          set_list_action? @action, 'scroll', 'by_author'\r
+          # 素材のライセンスグループフィルタリストを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_license_group'\r
         end\r
       end\r
-      describe 'by_panelに於いて' do\r
+      describe 'by_licenseに於いて' do\r
         before do\r
-          @action = @actions['by_panel']\r
+          @action = @actions['by_license']\r
         end\r
         it 'listタイプのアクションである' do\r
           expect(@action.type).to eq 'list'\r
         end\r
         it 'マニフェストから設定を取り出している' do\r
-          #スクロールのコマフィルタリストを返すように定義している\r
-          set_list_action? @action, 'scroll', 'by_panel'\r
+          # 実素材のライセンスフィルタリストを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_license'\r
         end\r
       end\r
-      describe 'countに於いて' do\r
+      describe 'by_artistに於いて' do\r
         before do\r
-          @action = @actions['count']\r
+          @action = @actions['by_artist']\r
         end\r
-        it 'countタイプのアクションである' do\r
-          expect(@action.type).to eq 'count'\r
+        it 'listタイプのアクションである' do\r
+          expect(@action.type).to eq 'list'\r
         end\r
         it 'マニフェストから設定を取り出している' do\r
-          #スクロールの公開リストのカウントを返すように定義している\r
-          set_list_action? @action, 'scroll', 'public'\r
+          # 素材の絵師フィルタリストを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_artist'\r
         end\r
       end\r
-      describe 'count_by_authorに於いて' do\r
+      describe 'showに於いて' do\r
         before do\r
-          @action = @actions['count_by_author']\r
-        end\r
-        it 'countタイプのアクションである' do\r
-          expect(@action.type).to eq 'count'\r
+          @action = @actions['show']\r
         end\r
-        it 'マニフェストから設定を取り出している' do\r
-          # スクロールの作家フィルタリストのカウントを返すように定義している\r
-          set_list_action? @action, 'scroll', 'by_author'\r
+        it 'showタイプのアクションである' do\r
+          expect(@action.type).to eq 'show'\r
         end\r
       end\r
-      describe 'count_by_panelに於いて' do\r
+      describe 'countに於いて' do\r
         before do\r
-          @action = @actions['count_by_panel']\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, 'scroll', 'by_panel'\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 'scroll'\r
+          # 素材の公開リストのカウントを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'public'\r
         end\r
       end\r
-      describe 'editに於いて' do\r
+      describe 'count_by_license_groupに於いて' 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 'scroll'\r
+          @action = @actions['count_by_license_group']\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
+        it 'countタイプのアクションである' do\r
+          expect(@action.type).to eq 'count'\r
         end\r
-        it 'type' do\r
-          expect(@action.item_name).to eq 'scroll'\r
+        it 'マニフェストから設定を取り出している' do\r
+          # 素材のライセンスグループフィルタリストのカウントを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_license_group'\r
         end\r
       end\r
-      describe 'updateに於いて' do\r
+      describe 'count_by_licenseに於いて' do\r
         before do\r
-          @action = @actions['update']\r
+          @action = @actions['count_by_license']\r
         end\r
-        it 'updateタイプのアクションである' do\r
-          expect(@action.type).to eq 'update'\r
+        it 'countタイプのアクションである' do\r
+          expect(@action.type).to eq 'count'\r
         end\r
-        it 'type' do\r
-          expect(@action.item_name).to eq 'scroll'\r
+        it 'マニフェストから設定を取り出している' do\r
+          # 素材のライセンスフィルタリストのカウントを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_license'\r
         end\r
       end\r
-      describe 'destroyに於いて' do\r
+      describe 'count_by_artistに於いて' do\r
         before do\r
-          @action = @actions['destroy']\r
+          @action = @actions['count_by_artist']\r
         end\r
-        it 'destroyタイプのアクションである' do\r
-          expect(@action.type).to eq 'destroy'\r
+        it 'countタイプのアクションである' do\r
+          expect(@action.type).to eq 'count'\r
         end\r
-        it 'type' do\r
-          expect(@action.item_name).to eq 'scroll'\r
+        it 'マニフェストから設定を取り出している' do\r
+          # 素材の絵師フィルタリストのカウントを返すように定義している\r
+          set_list_action? @action, 'resource_picture', 'by_artist'\r
         end\r
       end\r
     end\r
@@ -178,76 +215,100 @@ describe ResourcePicture do
       @my_manifest = @model.my_manifest\r
     end\r
     it 'サポート機能が動作している' do\r
-      expect(@my_manifest.model_name).to eq 'scroll'\r
+      expect(@my_manifest.model_name).to eq 'resource_picture'\r
       expect(@my_manifest.classify).to eq @model\r
-      expect(@my_manifest.table_name).to eq 'scrolls'\r
+      expect(@my_manifest.table_name).to eq 'resource_pictures'\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
+          @names = ['original_picture', 'license_group', 'license', 'artist', 'system_picture']\r
         end\r
         it 'これらのモデルに所属している' do\r
           set_associations? @belongs_to, @names\r
         end\r
-        describe 'authorに於いて' do\r
+        describe 'original_pictureに於いて' do\r
           before do\r
-            @mani = @belongs_to['author']\r
+            @mani = @belongs_to['original_picture']\r
           end\r
           it 'マニフェストから設定を取り出している' do\r
             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
-            expect(@mani.model_name).to eq 'author'\r
-            expect(@mani.id_column).to eq 'author_id'\r
+            expect(@mani.model_name).to eq 'original_picture'\r
+            expect(@mani.id_column).to eq 'original_picture_id'\r
           end\r
           it 'サポート機能が動作している' do\r
             # モデルを再現できている\r
-            expect(@mani.model).to eq Author\r
+            expect(@mani.model).to eq OriginalPicture\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', 'panels']\r
+        describe 'license_groupに於いて' do\r
+          before do\r
+            @mani = @belongs_to['license_group']\r
+          end\r
+          it 'マニフェストから設定を取り出している' do\r
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+            expect(@mani.model_name).to eq 'license_group'\r
+            expect(@mani.id_column).to eq 'license_group_id'\r
+          end\r
+          it 'サポート機能が動作している' do\r
+            # モデルを再現できている\r
+            expect(@mani.model).to eq LicenseGroup\r
+          end\r
         end\r
-        it 'これらのモデルを所持している' do\r
-          set_associations? @has_many, @names\r
+        describe 'artistに於いて' do\r
+          before do\r
+            @mani = @belongs_to['artist']\r
+          end\r
+          it 'マニフェストから設定を取り出している' do\r
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+            expect(@mani.model_name).to eq 'artist'\r
+            expect(@mani.id_column).to eq 'artist_id'\r
+          end\r
+          it 'サポート機能が動作している' do\r
+            # モデルを再現できている\r
+            expect(@mani.model).to eq Artist\r
+          end\r
         end\r
-        describe 'scroll_panelsに於いて' do\r
+        describe 'licenseに於いて' do\r
           before do\r
-            @mani = @has_many['scroll_panels']\r
+            @mani = @belongs_to['license']\r
           end\r
           it 'マニフェストから設定を取り出している' do\r
-            # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
-            expect(@mani.model_name).to eq 'scroll_panel'\r
-            expect(@mani.foreign_key).to eq 'scroll_id'\r
-            expect(@mani.through).to be nil\r
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+            expect(@mani.model_name).to eq 'license'\r
+            expect(@mani.id_column).to eq 'license_id'\r
           end\r
           it 'サポート機能が動作している' do\r
-            # モデルを再現できている, 中間モデルフラグ\r
-            expect(@mani.through?).to be false\r
-            expect(@mani.model).to eq ScrollPanel\r
+            # モデルを再現できている\r
+            expect(@mani.model).to eq License\r
           end\r
         end\r
-        describe 'panelsに於いて' do\r
+        describe 'system_pictureに於いて' do\r
           before do\r
-            @mani = @has_many['panels']\r
+            @mani = @belongs_to['system_picture']\r
           end\r
           it 'マニフェストから設定を取り出している' do\r
-            # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
-            expect(@mani.model_name).to eq 'panel'\r
-            expect(@mani.foreign_key).to eq 'scroll_id'\r
-            expect(@mani.through).to eq 'scroll_panels'\r
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+            expect(@mani.model_name).to eq 'system_picture'\r
+            expect(@mani.id_column).to eq 'system_picture_id'\r
           end\r
           it 'サポート機能が動作している' do\r
-            # モデルを再現できている, 中間モデルフラグ\r
-            expect(@mani.through?).to be true\r
-            expect(@mani.model).to eq Panel\r
+            # モデルを再現できている\r
+            expect(@mani.model).to eq SystemPicture\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 = []\r
+        end\r
+        it 'これらのモデルを所持している' do\r
+          set_associations? @has_many, @names\r
+        end\r
+      end\r
     end\r
     \r
     describe 'attributesに於いて' do\r
@@ -256,45 +317,133 @@ describe ResourcePicture do
       end\r
       it 'これらのカラムを定義している' do\r
         set_attributes? @attributes, \r
-          ['id', 'title', 'description', 'visible', 'author_id', \r
+          ['id', 'original_picture_id', 'ext', \r
+          'width', 'height', 'filesize', 'artist_id', 'license_group_id', 'license_id', \r
+          'md5', 'system_picture_id', \r
+          'license_group_settings', 'credit_picture_settings', \r
+          'license_settings', 'picture_id', 'license_group_module_name', \r
           'created_at', 'updated_at']\r
       end\r
-      describe 'titleに於いて' do\r
+      describe 'original_picture_idに於いて' do\r
+        before do\r
+          @attribute = @attributes['original_picture_id']\r
+        end\r
+        it 'numberタイプである' do\r
+          expect(@attribute.type).to eq 'number'\r
+        end\r
+      end\r
+      describe 'extに於いて' do\r
         before do\r
-          @attribute = @attributes['title']\r
+          @attribute = @attributes['ext']\r
         end\r
         it 'textタイプである' do\r
           expect(@attribute.type).to eq 'text'\r
         end\r
       end\r
-      describe 'descriptionに於いて' do\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 'filesizeに於いて' do\r
+        before do\r
+          @attribute = @attributes['filesize']\r
+        end\r
+        it 'numberタイプである' do\r
+          expect(@attribute.type).to eq 'number'\r
+        end\r
+      end\r
+      describe 'artist_idに於いて' do\r
+        before do\r
+          @attribute = @attributes['artist_id']\r
+        end\r
+        it 'numberタイプである' do\r
+          expect(@attribute.type).to eq 'number'\r
+        end\r
+      end\r
+      describe 'license_group_idに於いて' do\r
         before do\r
-          @attribute = @attributes['description']\r
+          @attribute = @attributes['license_group_id']\r
+        end\r
+        it 'numberタイプである' do\r
+          expect(@attribute.type).to eq 'number'\r
+        end\r
+      end\r
+      describe 'license_idに於いて' do\r
+        before do\r
+          @attribute = @attributes['license_id']\r
+        end\r
+        it 'numberタイプである' do\r
+          expect(@attribute.type).to eq 'number'\r
+        end\r
+      end\r
+      describe 'md5に於いて' do\r
+        before do\r
+          @attribute = @attributes['md5']\r
         end\r
         it 'textタイプである' do\r
           expect(@attribute.type).to eq 'text'\r
         end\r
       end\r
-      describe 'visibleに於いて' do\r
+      describe 'system_picture_idに於いて' do\r
         before do\r
-          @attribute = @attributes['visible']\r
+          @attribute = @attributes['system_picture_id']\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 'scroll_visible_items'\r
+      end\r
+      describe 'license_group_settingsに於いて' do\r
+        before do\r
+          @attribute = @attributes['license_group_settings']\r
+        end\r
+        it 'textタイプである' do\r
+          expect(@attribute.type).to eq 'text'\r
         end\r
       end\r
-      describe 'author_idに於いて' do\r
+      describe 'credit_picture_settingsに於いて' do\r
         before do\r
-          @attribute = @attributes['author_id']\r
+          @attribute = @attributes['credit_picture_settings']\r
+        end\r
+        it 'textタイプである' do\r
+          expect(@attribute.type).to eq 'text'\r
+        end\r
+      end\r
+      describe 'license_settingsに於いて' do\r
+        before do\r
+          @attribute = @attributes['license_settings']\r
+        end\r
+        it 'textタイプである' do\r
+          expect(@attribute.type).to eq 'text'\r
+        end\r
+      end\r
+      describe 'picture_idに於いて' do\r
+        before do\r
+          @attribute = @attributes['picture_id']\r
         end\r
         it 'numberタイプである' do\r
           expect(@attribute.type).to eq 'number'\r
         end\r
       end\r
+      describe 'license_group_module_nameに於いて' do\r
+        before do\r
+          @attribute = @attributes['license_group_module_name']\r
+        end\r
+        it 'textタイプである' do\r
+          expect(@attribute.type).to eq 'text'\r
+        end\r
+      end\r
     end\r
     \r
   end\r