OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / picture_spec.rb
index bc7802e..7a41481 100644 (file)
@@ -9,15 +9,76 @@ describe Picture do
   end
   
   describe 'ペタナイズに於いて' do
-    it 'スクコマを閉じるためのバインダーである' do
-      expect(@model.ancestors.include?(Peta::Binder)).to eq true
+    it '絵師が投稿するコンテンツである' do
+      expect(@model.ancestors.include?(Peta::Content)).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', 'license', '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['license']
+        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 'license_settings'
+          expect(@mani.foreign_key).to eq 'license_group_id'
+        end
+        it 'フキダシテンプレート' do
+          expect(@mani.item_name_for_extend_model).to eq 'attribute'
+          expect(@mani.setter_method_name).to eq 'attribute_extend='
+          expect(@mani.getter_method_name).to eq 'attribute_extend'
+          expect(@mani.extend_model_class_name).to eq 'Attribute'
+          expect(@mani.extend_module_name).to eq 'AttributeModule'
+        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,15 +88,14 @@ describe Picture 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 'picture'
     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', 
-          'new', 'edit', 'create', 'update', 'destroy']
+        @actions_names = ['index', 'by_artist', 'show', 
+          'count', 'count_by_artist']
       end
       it 'これらのアクションが定義されている' do
         set_actions? @actions, @actions_names
@@ -50,32 +110,20 @@ describe Picture do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの公開リストを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          # 実素材の公開リストを返すように定義している
+          set_list_action? @action, 'picture', 'public'
         end
       end
-      describe 'by_authorに於いて' do
+      describe 'by_artistに於いて' do
         before do
-          @action = @actions['by_author']
+          @action = @actions['by_artist']
         end
         it 'listタイプのアクションである' do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
-        end
-      end
-      describe 'by_panelに於いて' do
-        before do
-          @action = @actions['by_panel']
-        end
-        it 'listタイプのアクションである' do
-          expect(@action.type).to eq 'list'
-        end
-        it 'マニフェストから設定を取り出している' do
-          #スクロールのコマフィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          # 実素材の絵師フィルタリストを返すように定義している
+          set_list_action? @action, 'picture', 'by_artist'
         end
       end
       describe 'countに於いて' do
@@ -86,87 +134,28 @@ describe Picture do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          #スクロールの公開リストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          #実素材の公開リストのカウントを返すように定義している
+          set_list_action? @action, 'picture', 'public'
         end
       end
-      describe 'count_by_authorに於いて' do
+      describe 'showに於いて' do
         before do
-          @action = @actions['count_by_author']
-        end
-        it 'countタイプのアクションである' do
-          expect(@action.type).to eq 'count'
+          @action = @actions['show']
         end
-        it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+        it 'showタイプのアクションである' do
+          expect(@action.type).to eq 'show'
         end
       end
-      describe 'count_by_panelに於いて' do
+      describe 'count_by_artistに於いて' do
         before do
-          @action = @actions['count_by_panel']
+          @action = @actions['count_by_artist']
         end
         it 'countタイプのアクションである' do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールのコマフィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
-        end
-      end
-      describe 'newに於いて' do
-        before do
-          @action = @actions['new']
-        end
-        it 'newタイプのアクションである' do
-          expect(@action.type).to eq 'new'
-        end
-        it 'type' do
-          expect(@action.item_name).to eq 'scroll'
-        end
-      end
-      describe 'editに於いて' do
-        before do
-          @action = @actions['edit']
-        end
-        it 'editタイプのアクションである' do
-          expect(@action.type).to eq 'edit'
-        end
-        it 'type' do
-          expect(@action.item_name).to eq 'scroll'
-        end
-      end
-      describe 'createに於いて' do
-        before do
-          @action = @actions['create']
-        end
-        it 'createタイプのアクションである' do
-          expect(@action.type).to eq 'create'
-        end
-        it 'type' do
-          expect(@action.item_name).to eq 'scroll'
-        end
-      end
-      describe 'updateに於いて' do
-        before do
-          @action = @actions['update']
-        end
-        it 'updateタイプのアクションである' do
-          expect(@action.type).to eq 'update'
-        end
-        it 'type' do
-          expect(@action.item_name).to eq 'scroll'
-        end
-      end
-      describe 'destroyに於いて' do
-        before do
-          @action = @actions['destroy']
-        end
-        it 'destroyタイプのアクションである' do
-          expect(@action.type).to eq 'destroy'
-        end
-        it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          # 実素材の絵師フィルタリストのカウントを返すように定義している
+          set_list_action? @action, 'picture', 'by_artist'
         end
       end
     end
@@ -178,76 +167,72 @@ describe Picture do
       @my_manifest = @model.my_manifest
     end
     it 'サポート機能が動作している' do
-      expect(@my_manifest.model_name).to eq 'scroll'
+      expect(@my_manifest.model_name).to eq 'picture'
       expect(@my_manifest.classify).to eq @model
-      expect(@my_manifest.table_name).to eq 'scrolls'
+      expect(@my_manifest.table_name).to eq 'pictures'
     end
     
     describe 'associationsに於いて' do
       describe 'belongs_toに於いて' do
         before do
           @belongs_to = @my_manifest.associations.belongs_to
-          @names = ['author']
+          @names = ['artist', 'license', 'system_picture']
         end
         it 'これらのモデルに所属している' do
           set_associations? @belongs_to, @names
         end
-        describe 'authorに於いて' do
+        describe 'artistに於いて' do
           before do
-            @mani = @belongs_to['author']
+            @mani = @belongs_to['artist']
           end
           it 'マニフェストから設定を取り出している' do
             # モデル名と外部キーが定義あるいはデフォルト値補充されている
-            expect(@mani.model_name).to eq 'author'
-            expect(@mani.id_column).to eq 'author_id'
+            expect(@mani.model_name).to eq 'artist'
+            expect(@mani.id_column).to eq 'artist_id'
           end
           it 'サポート機能が動作している' do
             # モデルを再現できている
-            expect(@mani.model).to eq Author
+            expect(@mani.model).to eq Artist
           end
         end
-      end
-      describe 'has_manyに於いて' do
-        before do
-          @has_many = @model.my_manifest.associations.has_many
-          @names = ['scroll_panels', 'panels']
-        end
-        it 'これらのモデルを所持している' do
-          set_associations? @has_many, @names
-        end
-        describe 'scroll_panelsに於いて' do
+        describe 'licenseに於いて' do
           before do
-            @mani = @has_many['scroll_panels']
+            @mani = @belongs_to['license']
           end
           it 'マニフェストから設定を取り出している' do
-            # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
-            expect(@mani.model_name).to eq 'scroll_panel'
-            expect(@mani.foreign_key).to eq 'scroll_id'
-            expect(@mani.through).to be nil
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'license'
+            expect(@mani.id_column).to eq 'license_id'
           end
           it 'サポート機能が動作している' do
-            # モデルを再現できている, 中間モデルフラグ
-            expect(@mani.through?).to be false
-            expect(@mani.model).to eq ScrollPanel
+            # モデルを再現できている
+            expect(@mani.model).to eq License
           end
         end
-        describe 'panelsに於いて' do
+        describe 'system_pictureに於いて' do
           before do
-            @mani = @has_many['panels']
+            @mani = @belongs_to['system_picture']
           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'
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'system_picture'
+            expect(@mani.id_column).to eq 'system_picture_id'
           end
           it 'サポート機能が動作している' do
-            # モデルを再現できている, 中間モデルフラグ
-            expect(@mani.through?).to be true
-            expect(@mani.model).to eq Panel
+            # モデルを再現できている
+            expect(@mani.model).to eq SystemPicture
           end
         end
       end
+      describe 'has_manyに於いて' do
+        before do
+          @has_many = @model.my_manifest.associations.has_many
+          @names = []
+        end
+        it 'これらのモデルを所持している' do
+          set_associations? @has_many, @names
+        end
+      end
     end
     
     describe 'attributesに於いて' do
@@ -256,45 +241,124 @@ describe Picture do
       end
       it 'これらのカラムを定義している' do
         set_attributes? @attributes, 
-          ['id', 'title', 'description', 'visible', 'author_id', 
+          ['id', 'original_picture_id', 'revision', 'ext', 
+          'width', 'height', 'filesize', 'artist_id', 'license_id', 'md5', 'system_picture_id', 
+          'license_group_settings', 'credit_picture_settings', 
+          'license_settings', 'license_group_module_name', 
           'created_at', 'updated_at']
       end
-      describe 'titleに於いて' do
+      describe 'original_picture_idに於いて' do
         before do
-          @attribute = @attributes['title']
+          @attribute = @attributes['original_picture_id']
         end
-        it 'textタイプである' do
-          expect(@attribute.type).to eq 'text'
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
         end
       end
-      describe 'descriptionに於いて' do
+      describe 'revisionに於いて' do
         before do
-          @attribute = @attributes['description']
+          @attribute = @attributes['revision']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'extに於いて' do
+        before do
+          @attribute = @attributes['ext']
         end
         it 'textタイプである' do
           expect(@attribute.type).to eq 'text'
         end
       end
-      describe 'visibleに於いて' do
+      describe 'widthに於いて' do
         before do
-          @attribute = @attributes['visible']
+          @attribute = @attributes['width']
         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 'heightに於いて' do
+        before do
+          @attribute = @attributes['height']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
         end
       end
-      describe 'author_idに於いて' do
+      describe 'filesizeに於いて' do
         before do
-          @attribute = @attributes['author_id']
+          @attribute = @attributes['filesize']
         end
         it 'numberタイプである' do
           expect(@attribute.type).to eq 'number'
         end
       end
+      describe 'artist_idに於いて' do
+        before do
+          @attribute = @attributes['artist_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'license_idに於いて' do
+        before do
+          @attribute = @attributes['license_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'md5に於いて' do
+        before do
+          @attribute = @attributes['md5']
+        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
+      end
+      describe 'license_group_settingsに於いて' do
+        before do
+          @attribute = @attributes['license_group_settings']
+        end
+        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
+      describe 'license_settingsに於いて' do
+        before do
+          @attribute = @attributes['license_settings']
+        end
+        it 'textタイプである' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
+      describe 'license_group_module_nameに於いて' do
+        before do
+          @attribute = @attributes['license_group_module_name']
+        end
+        it 'textタイプである' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
     end
     
   end