OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / original_picture_spec.rb
index 32f7884..41a6736 100644 (file)
@@ -9,8 +9,8 @@ describe OriginalPicture 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
@@ -27,14 +27,14 @@ describe OriginalPicture 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 'original_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', 
+        @actions_names = ['index', 'history', 'show', 
+          'count', 
           'new', 'edit', 'create', 'update', 'destroy']
       end
       it 'これらのアクションが定義されている' do
@@ -50,32 +50,30 @@ describe OriginalPicture do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの公開リストを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          # オーナーしか操作できないアイテムなので、
+          # 不特定多数のユーザで共有する必要がない。
+          # よって、 privateリスト(自分の原画リスト)に割り当てる。 
+          set_list_action? @action, 'original_picture', 'private'
         end
       end
-      describe 'by_authorに於いて' do
+      describe 'historyに於いて' do
         before do
-          @action = @actions['by_author']
+          @action = @actions['history']
         end
-        it 'listタイプのアクションである' do
-          expect(@action.type).to eq 'list'
-        end
-        it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+        # 投稿履歴を一覧するための機能。
+        # 一覧そのものは実素材の原画フィルタで見られるが、
+        # 過去の実素材を他人が見る事はできないので、
+        # オーナーであることが保証される原画にこの機能を備えてある。 
+        it 'showタイプのアクションである' do
+          expect(@action.type).to eq 'show'
         end
       end
-      describe 'by_panelに於いて' do
+      describe 'showに於いて' do
         before do
-          @action = @actions['by_panel']
+          @action = @actions['show']
         end
-        it 'listタイプのアクションである' do
-          expect(@action.type).to eq 'list'
-        end
-        it 'マニフェストから設定を取り出している' do
-          #スクロールのコマフィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+        it 'showタイプのアクションである' do
+          expect(@action.type).to eq 'show'
         end
       end
       describe 'countに於いて' do
@@ -86,32 +84,8 @@ describe OriginalPicture do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          #スクロールの公開リストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
-        end
-      end
-      describe 'count_by_authorに於いて' do
-        before do
-          @action = @actions['count_by_author']
-        end
-        it 'countタイプのアクションである' do
-          expect(@action.type).to eq 'count'
-        end
-        it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
-        end
-      end
-      describe 'count_by_panelに於いて' do
-        before do
-          @action = @actions['count_by_panel']
-        end
-        it 'countタイプのアクションである' do
-          expect(@action.type).to eq 'count'
-        end
-        it 'マニフェストから設定を取り出している' do
-          # スクロールのコマフィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          # indexがprivateリストなので、当然件数取得もprivateリストの総数を返す。 
+          set_list_action? @action, 'original_picture', 'private'
         end
       end
       describe 'newに於いて' do
@@ -122,7 +96,7 @@ describe OriginalPicture do
           expect(@action.type).to eq 'new'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'original_picture'
         end
       end
       describe 'editに於いて' do
@@ -133,7 +107,7 @@ describe OriginalPicture do
           expect(@action.type).to eq 'edit'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'original_picture'
         end
       end
       describe 'createに於いて' do
@@ -144,7 +118,7 @@ describe OriginalPicture do
           expect(@action.type).to eq 'create'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'original_picture'
         end
       end
       describe 'updateに於いて' do
@@ -155,7 +129,7 @@ describe OriginalPicture do
           expect(@action.type).to eq 'update'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'original_picture'
         end
       end
       describe 'destroyに於いて' do
@@ -166,7 +140,7 @@ describe OriginalPicture do
           expect(@action.type).to eq 'destroy'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'original_picture'
         end
       end
     end
@@ -178,73 +152,80 @@ describe OriginalPicture do
       @my_manifest = @model.my_manifest
     end
     it 'サポート機能が動作している' do
-      expect(@my_manifest.model_name).to eq 'scroll'
+      expect(@my_manifest.model_name).to eq 'original_picture'
       expect(@my_manifest.classify).to eq @model
-      expect(@my_manifest.table_name).to eq 'scrolls'
+      expect(@my_manifest.table_name).to eq 'original_pictures'
     end
     
     describe 'associationsに於いて' do
       describe 'belongs_toに於いて' do
         before do
           @belongs_to = @my_manifest.associations.belongs_to
-          @names = ['author']
+          @names = ['artist']
         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']
+          @names = ['pictures']
         end
         it 'これらのモデルを所持している' do
           set_associations? @has_many, @names
         end
-        describe 'scroll_panelsに於いて' do
+        describe 'picturesに於いて' do
           before do
-            @mani = @has_many['scroll_panels']
+            @mani = @has_many['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 'picture'
+            expect(@mani.foreign_key).to eq 'original_picture_id'
             expect(@mani.through).to be nil
           end
           it 'サポート機能が動作している' do
             # モデルを再現できている, 中間モデルフラグ
             expect(@mani.through?).to be false
-            expect(@mani.model).to eq ScrollPanel
+            expect(@mani.model).to eq Picture
           end
         end
-        describe 'panelsに於いて' do
+      end
+      describe 'has_oneに於いて' do
+        before do
+          @has_one = @model.my_manifest.associations.has_one
+          @names = ['resource_picture']
+        end
+        it 'これらのモデルを所持している' do
+          set_associations? @has_one, @names
+        end
+        describe 'resource_pictureに於いて' do
           before do
-            @mani = @has_many['panels']
+            @mani = @has_one['resource_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 'resource_picture'
+            expect(@mani.foreign_key).to eq 'original_picture_id'
           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,45 +237,83 @@ describe OriginalPicture do
       end
       it 'これらのカラムを定義している' do
         set_attributes? @attributes, 
-          ['id', 'title', 'description', 'visible', 'author_id', 
+          ['id', 'ext', 
+          'width', 'height', 'filesize', 'artist_id', 'md5', 
+          'uploaded_at', 'published_at', 'stopped_at', 
           'created_at', 'updated_at']
       end
-      describe 'titleに於いて' do
+      describe 'extに於いて' do
         before do
-          @attribute = @attributes['title']
+          @attribute = @attributes['ext']
         end
         it 'textタイプである' do
           expect(@attribute.type).to eq 'text'
         end
       end
-      describe 'descriptionに於いて' do
+      describe 'widthに於いて' do
         before do
-          @attribute = @attributes['description']
+          @attribute = @attributes['width']
         end
-        it 'textタイプである' do
-          expect(@attribute.type).to eq 'text'
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
         end
       end
-      describe 'visibleに於いて' do
+      describe 'heightに於いて' do
         before do
-          @attribute = @attributes['visible']
+          @attribute = @attributes['height']
         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 'filesizeに於いて' do
+        before do
+          @attribute = @attributes['filesize']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
         end
       end
-      describe 'author_idに於いて' do
+      describe 'artist_idに於いて' do
         before do
-          @attribute = @attributes['author_id']
+          @attribute = @attributes['artist_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 'uploaded_atに於いて' do
+        before do
+          @attribute = @attributes['uploaded_at']
+        end
+        it 'datetimeタイプである' do
+          expect(@attribute.type).to eq 'datetime'
+        end
+      end
+      describe 'published_atに於いて' do
+        before do
+          @attribute = @attributes['published_at']
+        end
+        it 'datetimeタイプである' do
+          expect(@attribute.type).to eq 'datetime'
+        end
+      end
+      describe 'stopped_atに於いて' do
+        before do
+          @attribute = @attributes['stopped_at']
+        end
+        it 'datetimeタイプである' do
+          expect(@attribute.type).to eq 'datetime'
+        end
+      end
     end
     
   end