From ed63e7de628d91ac257988492af541b451f0cc83 Mon Sep 17 00:00:00 2001 From: Nicolas Piganeau Date: Mon, 22 Jun 2020 22:06:07 +0200 Subject: [PATCH] Several improvments in view inheritance --- README.md | 1 + src/templates/templates.go | 4 +- src/templates/templates_test.go | 213 +++++++++++++++++++++----------- src/tools/xmlutils/etree.go | 37 +++--- src/tools/xmlutils/xml.go | 32 +++-- src/tools/xmlutils/xml_test.go | 25 +++- src/views/init.go | 2 +- src/views/views.go | 28 +++-- src/views/views_test.go | 46 +++---- 9 files changed, 250 insertions(+), 138 deletions(-) diff --git a/README.md b/README.md index 70425fee..0645b6ff 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Go Report Card](https://goreportcard.com/badge/hexya-erp/hexya)](https://goreportcard.com/report/hexya-erp/hexya) [![codecov](https://codecov.io/gh/hexya-erp/hexya/branch/master/graph/badge.svg)](https://codecov.io/gh/hexya-erp/hexya) [![godoc reference](https://godoc.org/github.com/hexya-erp/hexya?status.png)](https://godoc.org/github.com/hexya-erp/hexya) +[![Gitter](https://badges.gitter.im/hexya-erp/community.svg)](https://gitter.im/hexya-erp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) # Hexya diff --git a/src/templates/templates.go b/src/templates/templates.go index 479c8a02..7b870b43 100644 --- a/src/templates/templates.go +++ b/src/templates/templates.go @@ -114,7 +114,7 @@ func (t *Template) updateFromXML(templateXML *TemplateXML) { if err != nil { log.Panic("Unable to read inheritance specs", "error", err, "arch", string(templateXML.Content)) } - content, err := xmlutils.XMLToElement(string(t.hWebContent)) + content, err := xmlutils.XMLToDocument(string(t.hWebContent)) if err != nil { log.Panic("Error while reading base template content", "error", err, "template", t.ID, "content", string(t.hWebContent)) } @@ -123,7 +123,7 @@ func (t *Template) updateFromXML(templateXML *TemplateXML) { log.Panic("Error while applying template extension specs", "error", err, "specTmpl", templateXML.ID, "specs", string(templateXML.Content), "template", t.ID, "content", string(t.hWebContent)) } - ncs, err := xmlutils.ElementToXMLNoIndent(newContent) + ncs, err := xmlutils.DocumentToXMLNoIndent(newContent) if err != nil { log.Panic("Error while converting back to XML", "error", err, "content", newContent, "specTmpl", templateXML.ID, "template", t.ID) diff --git a/src/templates/templates_test.go b/src/templates/templates_test.go index 736c1464..da45462c 100644 --- a/src/templates/templates_test.go +++ b/src/templates/templates_test.go @@ -43,24 +43,22 @@ var tmplDef2 = ` var tmplDef3 = ` ` var tmplDef4 = ` ` @@ -76,21 +74,26 @@ var tmplDef5 = ` var tmplDef8 = ` ` var tmplDef9 = ` +` + +var tmplDef10 = ` + ` -func loadView(xml string) { +func loadTemplate(xml string) { elt, err := xmlutils.XMLToElement(xml) if err != nil { panic(err) @@ -98,12 +101,12 @@ func loadView(xml string) { LoadFromEtree(elt) } -func TestViews(t *testing.T) { +func TestTemplates(t *testing.T) { Convey("Setting two languages", t, func() { i18n.Langs = []string{"fr", "de"} }) Convey("Creating Template 1", t, func() { - loadView(tmplDef1) + loadTemplate(tmplDef1) BootStrap() So(len(Registry.collection.templates), ShouldEqual, 1) So(Registry.collection.GetByID("my_id"), ShouldNotBeNil) @@ -125,8 +128,8 @@ func TestViews(t *testing.T) { `) }) Convey("Creating Template 2", t, func() { - loadView(tmplDef1) - loadView(tmplDef2) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) BootStrap() So(len(Registry.collection.templates), ShouldEqual, 2) So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) @@ -150,9 +153,9 @@ func TestViews(t *testing.T) { `) }) Convey("Inheriting Template 2", t, func() { - loadView(tmplDef1) - loadView(tmplDef2) - loadView(tmplDef3) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) BootStrap() So(len(Registry.collection.templates), ShouldEqual, 2) So(Registry.collection.GetByID("my_id"), ShouldNotBeNil) @@ -170,89 +173,110 @@ func TestViews(t *testing.T) { `) template2 := Registry.collection.GetByID("my_other_id") So(string(template2.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

Name

{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Email }}{{ Phone }}
-
`) + +`) }) Convey("More inheritance on Template 2", t, func() { - loadView(tmplDef1) - loadView(tmplDef2) - loadView(tmplDef3) - loadView(tmplDef4) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) + loadTemplate(tmplDef4) BootStrap() So(len(Registry.collection.templates), ShouldEqual, 2) So(Registry.collection.GetByID("my_id"), ShouldNotBeNil) So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) template2 := Registry.collection.GetByID("my_other_id") So(string(template2.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Phone }}
-
`) + +`) }) Convey("Modifying inherited modifications on Template 2", t, func() { - loadView(tmplDef1) - loadView(tmplDef2) - loadView(tmplDef3) - loadView(tmplDef4) - loadView(tmplDef5) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) + loadTemplate(tmplDef4) + loadTemplate(tmplDef5) BootStrap() So(len(Registry.collection.templates), ShouldEqual, 2) So(Registry.collection.GetByID("my_id"), ShouldNotBeNil) So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) template2 := Registry.collection.GetByID("my_other_id") So(string(template2.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Phone }}
-
`) + +`) }) Convey("Create new base template from inheritance", t, func() { - loadView(tmplDef1) - loadView(tmplDef2) - loadView(tmplDef3) - loadView(tmplDef4) - loadView(tmplDef5) - loadView(tmplDef8) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) + loadTemplate(tmplDef4) + loadTemplate(tmplDef5) + loadTemplate(tmplDef8) BootStrap() So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) So(Registry.collection.GetByID("new_base_view"), ShouldNotBeNil) template2 := Registry.collection.GetByID("my_other_id") newTemplate := Registry.collection.GetByID("new_base_view") So(string(template2.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Phone }}
-
`) + +`) So(template2.Priority, ShouldEqual, 12) So(template2.Page, ShouldBeFalse) So(template2.Optional, ShouldBeTrue) @@ -262,56 +286,105 @@ func TestViews(t *testing.T) { So(newTemplate.Optional, ShouldBeTrue) So(newTemplate.OptionalDefault, ShouldBeFalse) So(string(newTemplate.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Fax|safe }}{{ Phone }}
-
`) + +`) }) Convey("Inheriting new base template from inheritance", t, func() { Registry.collection = newCollection() - loadView(tmplDef1) - loadView(tmplDef2) - loadView(tmplDef3) - loadView(tmplDef4) - loadView(tmplDef5) - loadView(tmplDef8) - loadView(tmplDef9) + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) + loadTemplate(tmplDef4) + loadTemplate(tmplDef5) + loadTemplate(tmplDef8) + loadTemplate(tmplDef9) BootStrap() So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) So(Registry.collection.GetByID("new_base_view"), ShouldNotBeNil) template2 := Registry.collection.GetByID("my_other_id") newTemplate := Registry.collection.GetByID("new_base_view") So(string(template2.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Phone }}
-
`) + +`) So(string(newTemplate.Content("")), ShouldEqual, - `{% set _1 = _0 %}
+ `{% set _1 = _0 %} +

{{ Name }}

+
{{ Function }} - {{ CompanyName }}
+ {{ CompanyName }} +
{{ Address }} -

+
+
+
{{ Email }}{{ Mobile|safe }}{{ Fax|safe }}{{ Phone }}
-
`) + +`) + }) + Convey("Inherited modifications on root element", t, func() { + loadTemplate(tmplDef1) + loadTemplate(tmplDef2) + loadTemplate(tmplDef3) + loadTemplate(tmplDef4) + loadTemplate(tmplDef5) + loadTemplate(tmplDef10) + BootStrap() + So(Registry.collection.GetByID("my_other_id"), ShouldNotBeNil) + template2 := Registry.collection.GetByID("my_other_id") + So(string(template2.Content("")), ShouldEqual, + `{% set _1 = _0 %} +
+

{{ Name }}

+ +
+ {{ Function }} + {{ CompanyName }} +
+
+ {{ Address }} +
+
+
+ {{ Email }}{{ Phone }} +
+
+
1
+
2
+ `) }) Convey("Testing gin loading", t, func() { inst := Registry.Instance("my_id", pongo2.Context{ diff --git a/src/tools/xmlutils/etree.go b/src/tools/xmlutils/etree.go index 65e8553a..b168cb86 100644 --- a/src/tools/xmlutils/etree.go +++ b/src/tools/xmlutils/etree.go @@ -20,6 +20,28 @@ import ( "github.com/beevik/etree" ) +// DocumentToXML returns the XML bytes of the given document +func DocumentToXML(doc *etree.Document) ([]byte, error) { + doc.IndentTabs() + xml, err := doc.WriteToBytes() + if err != nil { + return nil, fmt.Errorf("unable to marshal document: %s", err) + } + return xml, nil +} + +// DocumentToXMLNoIndent returns the XML bytes of the given document +// without indenting the result. +// +// Use this function when the XML is HTML that needs to keep syntax +func DocumentToXMLNoIndent(doc *etree.Document) ([]byte, error) { + xml, err := doc.WriteToBytes() + if err != nil { + return nil, fmt.Errorf("unable to marshal document: %s", err) + } + return xml, nil +} + // ElementToXML returns the XML bytes of the given element and // all its children. func ElementToXML(element *etree.Element) ([]byte, error) { @@ -77,21 +99,6 @@ func NextSibling(token etree.Token) etree.Token { return nil } -// PreviousSibling returns the previous sibling of the given token. -// If this is the first token of its parent, return this token. -func PreviousSibling(token etree.Token) etree.Token { - var found bool - for i := len(token.Parent().Child) - 1; i >= 0; i-- { - if found { - return token.Parent().Child[i] - } - if token.Parent().Child[i] == token { - found = true - } - } - return token -} - // HasParentTag returns true if this element has at least // one ancestor node with the given parent tag name func HasParentTag(element *etree.Element, parent string) bool { diff --git a/src/tools/xmlutils/xml.go b/src/tools/xmlutils/xml.go index 8ef9da96..3dd63799 100644 --- a/src/tools/xmlutils/xml.go +++ b/src/tools/xmlutils/xml.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "io/ioutil" + "strings" "github.com/beevik/etree" ) @@ -61,41 +62,48 @@ func ConcatXML(fileNames []string) ([]byte, [sha1.Size]byte, error) { } // ApplyExtensions returns a copy of base with extension specs applied. -func ApplyExtensions(base *etree.Element, specs *etree.Document) (*etree.Element, error) { - baseElem := CopyElement(base) +func ApplyExtensions(base *etree.Document, specs *etree.Document) (*etree.Document, error) { + baseElem := base.Copy() for _, spec := range specs.ChildElements() { xpath, err := getInheritXPathFromSpec(spec) if err != nil { specBytes, _ := ElementToXML(spec) return nil, fmt.Errorf("error in spec %s: %s", string(specBytes), err) } - nodeToModify := baseElem.Parent().FindElement(xpath) + nodeToModify := baseElem.FindElement(xpath) if nodeToModify == nil { return nil, fmt.Errorf("node not found in parent view: %s", xpath) } - nextNode := NextSibling(nodeToModify) modifyAction := spec.SelectAttr("position") if modifyAction == nil { specBytes, _ := ElementToXML(spec) return nil, fmt.Errorf("spec should include 'position' attribute : %s", string(specBytes)) } + specChild := spec.Copy().Child + if len(specChild) > 0 { + if sp0, ok := specChild[0].(*etree.CharData); ok && strings.HasPrefix(sp0.Data, "\n") { + // Remove first \n from spec if present + sp0.Data = strings.TrimPrefix(sp0.Data, "\n") + } + } switch modifyAction.Value { case "before": - for _, node := range spec.ChildElements() { - nodeToModify.Parent().InsertChild(nodeToModify, node) + for _ = range specChild { + nodeToModify.Parent().InsertChild(nodeToModify, specChild[0]) } case "after": - for _, node := range spec.ChildElements() { - nodeToModify.Parent().InsertChild(nextNode, node) + nextNode := NextSibling(nodeToModify) + for _ = range specChild { + nodeToModify.Parent().InsertChild(nextNode, specChild[0]) } case "replace": - for _, node := range spec.ChildElements() { - nodeToModify.Parent().InsertChild(nodeToModify, node) + for _ = range specChild { + nodeToModify.Parent().InsertChild(nodeToModify, specChild[0]) } nodeToModify.Parent().RemoveChild(nodeToModify) case "inside": - for _, node := range spec.ChildElements() { - nodeToModify.AddChild(node) + for _ = range specChild { + nodeToModify.AddChild(specChild[0]) } case "attributes": for _, node := range spec.FindElements("./attribute") { diff --git a/src/tools/xmlutils/xml_test.go b/src/tools/xmlutils/xml_test.go index dc0b306e..f21877c5 100644 --- a/src/tools/xmlutils/xml_test.go +++ b/src/tools/xmlutils/xml_test.go @@ -57,6 +57,10 @@ var ( +` + baseTemplate = ` + + ` specs = ` @@ -78,6 +82,11 @@ var ( address Address +` + templateAppendSpec = ` + + + ` notASpec = ` @@ -98,13 +107,13 @@ var ( func TestApplyExtensions(t *testing.T) { Convey("Testing ApplyExtensions", t, func() { - baseElem, _ := XMLToElement(baseXML) + baseElem, _ := XMLToDocument(baseXML) specDoc := etree.NewDocument() Convey("Correct XML Extension spec", func() { specDoc.ReadFromString(specs) res, err := ApplyExtensions(baseElem, specDoc) So(err, ShouldBeNil) - xml, _ := ElementToXML(res) + xml, _ := DocumentToXML(res) So(string(xml), ShouldEqual, `

@@ -122,6 +131,18 @@ func TestApplyExtensions(t *testing.T) { +`) + }) + Convey("Template spec", func() { + baseTmplDoc, _ := XMLToDocument(baseTemplate) + specDoc.ReadFromString(templateAppendSpec) + res, err := ApplyExtensions(baseTmplDoc, specDoc) + So(err, ShouldBeNil) + xml, _ := DocumentToXMLNoIndent(res) + So(string(xml), ShouldEqual, ` + + + `) }) Convey("XML which is not a spec should fail", func() { diff --git a/src/views/init.go b/src/views/init.go index 5eecc0a1..2a087487 100644 --- a/src/views/init.go +++ b/src/views/init.go @@ -68,7 +68,7 @@ func BootStrap() { arch: baseView.arch, Name: baseView.Name, Type: baseView.Type, - arches: make(map[string]*etree.Element), + arches: make(map[string]*etree.Document), FieldParent: baseView.FieldParent, } newView.updateViewFromXML(xmlView) diff --git a/src/views/views.go b/src/views/views.go index d23db3e5..5f01d7a4 100644 --- a/src/views/views.go +++ b/src/views/views.go @@ -246,7 +246,7 @@ func (vc *Collection) GetFirstViewForModel(model string, viewType ViewType) *Vie // defaultViewForModel returns a default view for the given model and type func (vc *Collection) defaultViewForModel(model string, viewType ViewType) *View { xmlStr := fmt.Sprintf(`<%s>`, viewType, viewType) - arch, err := xmlutils.XMLToElement(xmlStr) + arch, err := xmlutils.XMLToDocument(xmlStr) if err != nil { log.Panic("unable to create default view", "error", err, "view", xmlStr) } @@ -255,11 +255,11 @@ func (vc *Collection) defaultViewForModel(model string, viewType ViewType) *View Type: viewType, Fields: []string{}, arch: arch, - arches: make(map[string]*etree.Element), + arches: make(map[string]*etree.Document), } if _, ok := models.Registry.MustGet(model).Fields().Get("name"); ok { xmlStr = fmt.Sprintf(`<%s>`, viewType, viewType) - arch, err = xmlutils.XMLToElement(xmlStr) + arch, err = xmlutils.XMLToDocument(xmlStr) if err != nil { log.Panic("unable to create default view", "error", err, "view", xmlStr) } @@ -313,7 +313,7 @@ func (vc *Collection) createNewViewFromXML(viewXML *ViewXML) { name = viewXML.Name } - arch, err := xmlutils.XMLToElement(viewXML.Arch) + arch, err := xmlutils.XMLToDocument(viewXML.Arch) if err != nil { log.Panic("unable to create view from XML", "error", err, "view", viewXML.Arch) } @@ -325,7 +325,7 @@ func (vc *Collection) createNewViewFromXML(viewXML *ViewXML) { arch: arch, FieldParent: viewXML.FieldParent, SubViews: make(map[string]SubViews), - arches: make(map[string]*etree.Element), + arches: make(map[string]*etree.Document), } vc.Add(&view) } @@ -337,11 +337,11 @@ type View struct { Model string Type ViewType Priority uint8 - arch *etree.Element + arch *etree.Document FieldParent string Fields []string SubViews map[string]SubViews - arches map[string]*etree.Element + arches map[string]*etree.Document } // A SubViews is a holder for embedded views of a field @@ -357,7 +357,7 @@ func (v *View) populateFieldNames() { // Arch returns the arch XML string of this view for the given language. // Call with empty string to get the default language's arch -func (v *View) Arch(lang string) *etree.Element { +func (v *View) Arch(lang string) *etree.Document { res, ok := v.arches[lang] if !ok || lang == "" { res = v.arch @@ -368,13 +368,13 @@ func (v *View) Arch(lang string) *etree.Element { // setViewType sets the Type field with the view type // scanned from arch func (v *View) setViewType() { - v.Type = ViewType(v.arch.Tag) + v.Type = ViewType(v.arch.Root().Tag) } // extractSubViews recursively scans arch for embedded views, // extract them from arch and add them to SubViews. func (v *View) extractSubViews(model *models.Model, fInfos map[string]*models.FieldInfo) { - archElem := xmlutils.CopyElement(v.arch) + archElem := v.arch.Copy() fieldElems := archElem.FindElements("//field") for _, f := range fieldElems { if xmlutils.HasParentTag(f, "field") { @@ -386,11 +386,13 @@ func (v *View) extractSubViews(model *models.Model, fInfos map[string]*models.Fi if _, exists := v.SubViews[fieldName]; !exists { v.SubViews[fieldName] = make(SubViews) } + childDoc := etree.NewDocument() + childDoc.SetRoot(xmlutils.CopyElement(childElement)) childView := View{ ID: fmt.Sprintf("%s_childview_%s_%d", v.ID, fieldName, i), - arch: xmlutils.CopyElement(childElement), + arch: childDoc, SubViews: make(map[string]SubViews), - arches: make(map[string]*etree.Element), + arches: make(map[string]*etree.Document), Model: fInfos[model.JSONizeFieldName(fieldName)].Relation, } childView.postProcess() @@ -475,7 +477,7 @@ func (v *View) SanitizeSearchView() { func (v *View) translateArch() { labels := v.TranslatableStrings() for _, lang := range i18n.Langs { - tArchElt := xmlutils.CopyElement(v.arch) + tArchElt := v.arch.Copy() for _, label := range labels { attrElts := tArchElt.FindElements(fmt.Sprintf("//[@%s]", label.Attribute)) for i, attrElt := range attrElts { diff --git a/src/views/views_test.go b/src/views/views_test.go index 0666485a..1531e456 100644 --- a/src/views/views_test.go +++ b/src/views/views_test.go @@ -159,8 +159,8 @@ var viewDef10 = ` ` -func elementToXMLString(elt *etree.Element) string { - xmlData, err := xmlutils.ElementToXML(elt) +func documentToXMLString(elt *etree.Document) string { + xmlData, err := xmlutils.DocumentToXML(elt) if err != nil { panic(err) } @@ -185,7 +185,7 @@ func TestViews(t *testing.T) { So(view.Name, ShouldEqual, "My View") So(view.Model, ShouldEqual, "User") So(view.Priority, ShouldEqual, 16) - So(elementToXMLString(view.Arch("")), ShouldEqual, + So(documentToXMLString(view.Arch("")), ShouldEqual, `
@@ -206,7 +206,7 @@ func TestViews(t *testing.T) { So(view.Name, ShouldEqual, "my.other.id") So(view.Model, ShouldEqual, "Partner") So(view.Priority, ShouldEqual, 12) - So(elementToXMLString(view.Arch("")), ShouldEqual, + So(documentToXMLString(view.Arch("")), ShouldEqual, `

@@ -272,7 +272,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("my_id"), ShouldNotBeNil) So(Registry.GetByID("my_other_id"), ShouldNotBeNil) view1 := Registry.GetByID("my_id") - So(elementToXMLString(view1.Arch("")), ShouldEqual, + So(documentToXMLString(view1.Arch("")), ShouldEqual, ` @@ -282,7 +282,7 @@ func TestViews(t *testing.T) { `) view2 := Registry.GetByID("my_other_id") - So(elementToXMLString(view2.Arch("")), ShouldEqual, + So(documentToXMLString(view2.Arch("")), ShouldEqual, `

@@ -309,7 +309,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("my_id"), ShouldNotBeNil) So(Registry.GetByID("my_other_id"), ShouldNotBeNil) view2 := Registry.GetByID("my_other_id") - So(elementToXMLString(view2.Arch("")), ShouldEqual, + So(documentToXMLString(view2.Arch("")), ShouldEqual, `

@@ -341,7 +341,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("my_id"), ShouldNotBeNil) So(Registry.GetByID("my_other_id"), ShouldNotBeNil) view2 := Registry.GetByID("my_other_id") - So(elementToXMLString(view2.Arch("")), ShouldEqual, + So(documentToXMLString(view2.Arch("")), ShouldEqual, `

@@ -396,7 +396,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("embedded_form_childview_2"), ShouldBeNil) view := Registry.GetByID("embedded_form") So(view.ID, ShouldEqual, "embedded_form") - So(elementToXMLString(view.Arch("")), ShouldEqual, + So(documentToXMLString(view.Arch("")), ShouldEqual, ` @@ -411,7 +411,7 @@ func TestViews(t *testing.T) { So(viewCategories, ShouldHaveLength, 2) viewCategoriesForm := viewCategories[ViewTypeForm] So(viewCategoriesForm.ID, ShouldEqual, "embedded_form_childview_Categories_1") - So(elementToXMLString(viewCategoriesForm.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewCategoriesForm.Arch("")), ShouldEqual, `

This is my form

@@ -420,7 +420,7 @@ func TestViews(t *testing.T) { `) viewCategoriesTree := viewCategories[ViewTypeTree] So(viewCategoriesTree.ID, ShouldEqual, "embedded_form_childview_Categories_0") - So(elementToXMLString(viewCategoriesTree.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewCategoriesTree.Arch("")), ShouldEqual, ` @@ -430,7 +430,7 @@ func TestViews(t *testing.T) { So(viewGroups, ShouldHaveLength, 1) viewGroupsTree := viewGroups[ViewTypeTree] So(viewGroupsTree.ID, ShouldEqual, "embedded_form_childview_Groups_0") - So(elementToXMLString(viewGroupsTree.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewGroupsTree.Arch("")), ShouldEqual, ` @@ -453,7 +453,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("embedded_form_childview_2"), ShouldBeNil) view := Registry.GetByID("embedded_form") So(view.ID, ShouldEqual, "embedded_form") - So(elementToXMLString(view.Arch("")), ShouldEqual, + So(documentToXMLString(view.Arch("")), ShouldEqual, ` @@ -468,7 +468,7 @@ func TestViews(t *testing.T) { So(viewCategories, ShouldHaveLength, 2) viewCategoriesForm := viewCategories[ViewTypeForm] So(viewCategoriesForm.ID, ShouldEqual, "embedded_form_childview_Categories_1") - So(elementToXMLString(viewCategoriesForm.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewCategoriesForm.Arch("")), ShouldEqual, `

This is my form

@@ -477,7 +477,7 @@ func TestViews(t *testing.T) { `) viewCategoriesTree := viewCategories[ViewTypeTree] So(viewCategoriesTree.ID, ShouldEqual, "embedded_form_childview_Categories_0") - So(elementToXMLString(viewCategoriesTree.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewCategoriesTree.Arch("")), ShouldEqual, ` @@ -487,7 +487,7 @@ func TestViews(t *testing.T) { So(viewGroups, ShouldHaveLength, 1) viewGroupsTree := viewGroups[ViewTypeTree] So(viewGroupsTree.ID, ShouldEqual, "embedded_form_childview_Groups_0") - So(elementToXMLString(viewGroupsTree.Arch("")), ShouldEqual, ` + So(documentToXMLString(viewGroupsTree.Arch("")), ShouldEqual, ` @@ -507,12 +507,12 @@ func TestViews(t *testing.T) { "Name": fields.Char{}, }) soSearch := Registry.GetFirstViewForModel("SaleOrder", ViewTypeSearch) - So(elementToXMLString(soSearch.arch), ShouldEqual, ` + So(documentToXMLString(soSearch.arch), ShouldEqual, ` `) soTree := Registry.GetFirstViewForModel("SaleOrder", ViewTypeTree) - So(elementToXMLString(soTree.arch), ShouldEqual, ` + So(documentToXMLString(soTree.arch), ShouldEqual, ` `) @@ -532,7 +532,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("new_base_view"), ShouldNotBeNil) view2 := Registry.GetByID("my_other_id") newView := Registry.GetByID("new_base_view") - So(elementToXMLString(view2.Arch("")), ShouldEqual, + So(documentToXMLString(view2.Arch("")), ShouldEqual, `

@@ -551,7 +551,7 @@ func TestViews(t *testing.T) { `) - So(elementToXMLString(newView.Arch("")), ShouldEqual, + So(documentToXMLString(newView.Arch("")), ShouldEqual, `

@@ -588,7 +588,7 @@ func TestViews(t *testing.T) { So(Registry.GetByID("new_base_view"), ShouldNotBeNil) view2 := Registry.GetByID("my_other_id") newView := Registry.GetByID("new_base_view") - So(elementToXMLString(view2.Arch("")), ShouldEqual, + So(documentToXMLString(view2.Arch("")), ShouldEqual, `

@@ -607,7 +607,7 @@ func TestViews(t *testing.T) { `) - So(elementToXMLString(newView.Arch("")), ShouldEqual, + So(documentToXMLString(newView.Arch("")), ShouldEqual, `

@@ -716,7 +716,7 @@ func TestViews(t *testing.T) { BootStrap() So(Registry.GetByID("search_view"), ShouldNotBeNil) searchView := Registry.GetByID("search_view") - So(elementToXMLString(searchView.Arch("")), ShouldEqual, + So(documentToXMLString(searchView.Arch("")), ShouldEqual, `