예제 #1
0
		gorma.GormaDesign = nil
		InitDesign()
		RandomPayload = Type("UserPayload", func() {
			Attribute("first_name", String)
			Attribute("last_name", String)
		})

	})

	JustBeforeEach(func() {
		gdsl.StorageGroup(sgname, func() {
			gdsl.Store(storename, gorma.MySQL, func() {
				gdsl.Model(modelname, func() {
					gdsl.BuiltFrom(RandomPayload)
					gdsl.Field(name, ft, dsl)
					gdsl.Field("id", gorma.PKInteger, dsl) // use lowercase "id" to test sanitizer
					gdsl.Field("CreatedAt", gorma.Timestamp)
					gdsl.Field("UpdatedAt", gorma.Timestamp)
					gdsl.Field("DeletedAt", gorma.NullableTimestamp)
				})
			})
		})
		Run()

	})

	Context("with no DSL", func() {
		BeforeEach(func() {
			name = "FirstName"
		})

		It("produces a valid Relational Field definition", func() {
예제 #2
0
		})
		HasOnePayload = Type("HasOnePayload", func() {
			Attribute("first_name", String)
			Attribute("last_name", String)
		})

		HasManyPayload = Type("HasManyPayload", func() {
			Attribute("first_name", String)
			Attribute("last_name", String)
		})

	})

	JustBeforeEach(func() {
		storedsl = func() {
			gdsl.Model(name, dsl)
			gdsl.Model("Child", func() {
				gdsl.BuildsFrom(func() {
					gdsl.Payload("testresource", "create")
				})
				gdsl.RendersTo(ChildMedia)
				gdsl.BelongsTo(name)
			})
			gdsl.Model("One", func() {
				gdsl.BuildsFrom(func() {
					gdsl.Payload("testresource", "create")
				})
				gdsl.HasOne("Child")
			})
			gdsl.Model("Many", func() {
				gdsl.BuildsFrom(func() {
예제 #3
0
		HasOnePayload = Type("HasOnePayload", func() {
			Attribute("first_name", String)
			Attribute("last_name", String)
		})

		HasManyPayload = Type("HasManyPayload", func() {
			Attribute("first_name", String)
			Attribute("last_name", String)
		})

	})

	JustBeforeEach(func() {
		gdsl.StorageGroup(sgname, func() {
			gdsl.Store(storename, gorma.MySQL, func() {
				gdsl.Model(name, dsl)
				gdsl.Model("Child", func() {
					gdsl.BuiltFrom(ChildPayload)
					gdsl.BelongsTo(name)
				})
				gdsl.Model("One", func() {
					gdsl.BuiltFrom(HasOnePayload)
					gdsl.HasOne("Child")
				})
				gdsl.Model("Many", func() {
					gdsl.BuiltFrom(HasManyPayload)
					gdsl.HasMany("Children", "Child")
				})

			})
		})
예제 #4
0
	JustBeforeEach(func() {

		modeldsl = func() {
			//gdsl.BuildsFrom(RandomPayload)
			gdsl.Field(name, ft, dsl)
			gdsl.Field("id", gorma.Integer, dsl) // use lowercase "id" to test sanitizer
			gdsl.Field("MiddleName", gorma.String)
			gdsl.Field("CreatedAt", gorma.Timestamp)
			gdsl.Field("UpdatedAt", gorma.Timestamp)
			gdsl.Field("DeletedAt", gorma.NullableTimestamp)

		}
		gdsl.StorageGroup(sgname, func() {
			gdsl.Store(storename, gorma.MySQL, func() {
				gdsl.Model(modelname, modeldsl)
			})
		})
		Run()

	})

	Context("with no DSL", func() {
		BeforeEach(func() {
			name = "FirstName"
		})

		It("produces a valid Relational Field definition", func() {
			Ω(Design.Validate()).ShouldNot(HaveOccurred())
			sg := gorma.GormaDesign
			rs := sg.RelationalStores[storename]