OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / original_picture_license_spec.rb
diff --git a/spec/manifests/original_picture_license_spec.rb b/spec/manifests/original_picture_license_spec.rb
new file mode 100644 (file)
index 0000000..4ada650
--- /dev/null
@@ -0,0 +1,179 @@
+# -*- encoding: utf-8 -*-
+#原画ライセンス
+require 'spec_helper'
+
+describe OriginalPictureLicense do
+  include ManifestsMacros
+  before do
+    @model = OriginalPictureLicense
+  end
+  
+  describe 'ペタナイズに於いて' do
+    it 'アイテムである' do
+      expect(@model.ancestors.include?(Peta::Item)).to eq true
+    end
+    it '親モデルは持たない' do
+      expect(@model.my_peta.parent_model_name).to be_blank
+    end
+    describe 'ブーストに於いて' do
+      before do
+        @boosts = @model.my_peta.boost
+        @boosts_names = ['license']
+      end
+      it 'これらのブーストが定義されている' do
+        set_boosts? @boosts, @boosts_names
+      end
+      describe 'ライセンスに於いて' do
+        before do
+          @mani = @boosts['license']
+        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_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
+    end
+    
+  end
+  
+  describe 'コントローラに於いて' do
+  end
+  
+  describe 'モデルに於いて' do
+    before do
+      @my_manifest = @model.my_manifest
+    end
+    it 'サポート機能が動作している' do
+      expect(@my_manifest.model_name).to eq 'original_picture_license'
+      expect(@my_manifest.classify).to eq @model
+      expect(@my_manifest.table_name).to eq 'original_picture_licenses'
+    end
+    
+    describe 'associationsに於いて' do
+      describe 'belongs_toに於いて' do
+        before do
+          @belongs_to = @my_manifest.associations.belongs_to
+          @names = ['original_picture', 'license', 'system_picture']
+        end
+        it 'これらのモデルに所属している' do
+          set_associations? @belongs_to, @names
+        end
+        describe 'original_pictureに於いて' do
+          before do
+            @mani = @belongs_to['original_picture']
+          end
+          it 'マニフェストから設定を取り出している' do
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'original_picture'
+            expect(@mani.id_column).to eq 'original_picture_id'
+          end
+          it 'サポート機能が動作している' do
+            # モデルを再現できている
+            expect(@mani.model).to eq OriginalPicture
+          end
+        end
+        describe 'licenseに於いて' do
+          before do
+            @mani = @belongs_to['license']
+          end
+          it 'マニフェストから設定を取り出している' do
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'license'
+            expect(@mani.id_column).to eq 'license_id'
+          end
+          it 'サポート機能が動作している' do
+            # モデルを再現できている
+            expect(@mani.model).to eq License
+          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 = []
+        end
+        it 'これらのモデルを所持している' do
+          set_associations? @has_many, @names
+        end
+      end
+    end
+    
+    describe 'attributesに於いて' do
+      before do
+        @attributes = @model.my_manifest.attributes
+      end
+      it 'これらのカラムを定義している' do
+        set_attributes? @attributes, 
+          ['id', 'original_picture_id', 'license_group_id', 'license_id', 
+          'license_settings', 'license_group_module_name', 
+          'created_at', 'updated_at']
+      end
+      describe 'original_picture_idに於いて' do
+        before do
+          @attribute = @attributes['original_picture_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      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_idに於いて' do
+        before do
+          @attribute = @attributes['license_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        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
+  
+end