1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

bumped version

This commit is contained in:
Harvey Kandola 2017-08-22 17:23:30 +01:00
parent 07c8238664
commit c235fb569e
9 changed files with 819 additions and 664 deletions

View file

@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
## Latest version
v1.52.2
v1.53.0
## OS Support

View file

@ -35,11 +35,8 @@ type migrationsT []string
// migrations returns a list of the migrations to update the database as required for this version of the code.
func migrations(lastMigration string) (migrationsT, error) {
lastMigration = strings.TrimPrefix(strings.TrimSuffix(lastMigration, `"`), `"`)
//fmt.Println(`DEBUG Migrations("`+lastMigration+`")`)
files, err := web.AssetDir(migrationsDir)
if err != nil {
return nil, err

View file

@ -69,7 +69,7 @@ func (h *Handler) RobotsTxt(w http.ResponseWriter, r *http.Request) {
ctx := domain.GetRequestContext(r)
dom := organization.GetSubdomainFromHost(r)
org, err := h.Store.Organization.GetOrganizationByDomain(dom)
o, err := h.Store.Organization.GetOrganizationByDomain(dom)
// default is to deny
robots :=
@ -78,11 +78,13 @@ func (h *Handler) RobotsTxt(w http.ResponseWriter, r *http.Request) {
`
if err != nil {
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom), err)
h.Runtime.Log.Info(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom))
o = org.Organization{}
o.AllowAnonymousAccess = false
}
// Anonymous access would mean we allow bots to crawl.
if org.AllowAnonymousAccess {
if o.AllowAnonymousAccess {
sitemap := ctx.GetAppURL("sitemap.xml")
robots = fmt.Sprintf(
`User-agent: *
@ -113,10 +115,12 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
ctx := domain.GetRequestContext(r)
dom := organization.GetSubdomainFromHost(r)
org, err := h.Store.Organization.GetOrganizationByDomain(dom)
o, err := h.Store.Organization.GetOrganizationByDomain(dom)
if err != nil {
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom), err)
h.Runtime.Log.Info(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom))
o = org.Organization{}
o.AllowAnonymousAccess = false
}
sitemap :=
@ -131,9 +135,9 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
var items []sitemapItem
// Anonymous access means we announce folders/documents shared with 'Everyone'.
if org.AllowAnonymousAccess {
if o.AllowAnonymousAccess {
// Grab shared folders
folders, err := h.Store.Space.PublicSpaces(ctx, org.RefID)
folders, err := h.Store.Space.PublicSpaces(ctx, o.RefID)
if err != nil {
folders = []space.Space{}
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get folders for domain %s", method, dom), err)
@ -148,7 +152,7 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
// Grab documents from shared folders
var documents []doc.SitemapDocument
documents, err = h.Store.Document.PublicDocuments(ctx, org.RefID)
documents, err = h.Store.Document.PublicDocuments(ctx, o.RefID)
if err != nil {
documents = []doc.SitemapDocument{}
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get documents for domain %s", method, dom), err)

View file

@ -0,0 +1,95 @@
package space
import (
"testing"
"github.com/documize/community/core/uniqueid"
"github.com/documize/community/domain/test"
"github.com/documize/community/model/space"
)
//add a new space and get it. if the get returns the same space as the one just added it passes the test
func TestAddSpace(t *testing.T) {
//Setup - get the necessary info to add a space, generate a test space
rt, s, ctx := test.SetupTest()
var err error
//Run test - Add a space to the DB, read it to make sure it was added correctly
ctx.Transaction, err = rt.Db.Beginx()
if err != nil {
return
}
sp := space.Space{}
sp.RefID = uniqueid.Generate()
sp.OrgID = ctx.OrgID
sp.Type = space.ScopePrivate
sp.UserID = ctx.UserID
sp.Name = "test"
err = s.Space.Add(ctx, sp)
if err != nil {
ctx.Transaction.Rollback()
return
}
ctx.Transaction.Commit()
sp2, err := s.Space.Get(ctx, sp.RefID)
if err != nil {
return
}
if sp != sp2 {
t.Errorf("Test Failed, space one (%v) does not match space 2(%v)", sp, sp2)
}
}
// Function to create a space with an identifier, remove it and then try get it using that Identifier, if it doesnt get it, it is removed
// func TestRemoveSpace(t *testing.T) {
// //Setup - get the necessary info to add a space, generate a test space
// rt, s, ctx := test.SetupTest()
// var err error
// println("marker 1")
// //Run test - Add a space
// ctx.Transaction, err = rt.Db.Beginx()
// if err != nil {
// return
// }
// println("marker 2")
// sp := space.Space{}
// sp.RefID = uniqueid.Generate()
// sp.OrgID = ctx.OrgID
// sp.Type = space.ScopePrivate
// sp.UserID = ctx.UserID
// sp.Name = "test-toBeDeleted"
// println("marker 3")
// err = s.Space.Add(ctx, sp)
// if err != nil {
// ctx.Transaction.Rollback()
// return
// }
// ctx.Transaction.Commit()
// //Remove the space
// ctx.Transaction, err = rt.Db.Beginx()
// _, err = s.Space.Delete(ctx, sp.RefID)
// move := "moveToId"
// err = s.Document.MoveDocumentSpace(ctx, sp.RefID, move)
// err = s.Space.MoveSpaceRoles(ctx, sp.RefID, move)
// _, err = s.Pin.DeletePinnedSpace(ctx, sp.RefID)
// s.Audit.Record(ctx, audit.EventTypeSpaceDelete)
// ctx.Transaction.Commit()
// _, err = s.Space.Get(ctx, sp.RefID)
// }

59
domain/test/test.go Normal file
View file

@ -0,0 +1,59 @@
package test
import (
"fmt"
"github.com/documize/community/core/env"
"github.com/documize/community/domain"
"github.com/documize/community/edition/boot"
"github.com/documize/community/edition/logging"
_ "github.com/go-sql-driver/mysql" // testing
)
// SetupTest prepares test environment
func SetupTest() (rt *env.Runtime, s *domain.Store, ctx domain.RequestContext) {
rt, s = startRuntime()
ctx = setupContext()
return rt, s, ctx
}
func startRuntime() (rt *env.Runtime, s *domain.Store) {
rt = new(env.Runtime)
s = new(domain.Store)
rt.Log = logging.NewLogger()
rt.Product = env.ProdInfo{}
rt.Product.Major = "0"
rt.Product.Minor = "0"
rt.Product.Patch = "0"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Test"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
rt.Product.License = env.License{}
rt.Product.License.Seats = 1
rt.Product.License.Valid = true
rt.Product.License.Trial = false
rt.Product.License.Edition = "Community"
// parse settings from command line and environment
rt.Flags = env.ParseFlags()
boot.InitRuntime(rt, s)
// section.Register(rt, s)
return rt, s
}
// setup testing context
func setupContext() domain.RequestContext {
ctx := domain.RequestContext{}
ctx.AllowAnonymousAccess = true
ctx.Authenticated = true
ctx.Administrator = true
ctx.Guest = false
ctx.Editor = true
ctx.Global = true
ctx.UserID = "1"
ctx.OrgID = "1"
return ctx
}

View file

@ -37,8 +37,8 @@ func main() {
// product details
rt.Product = env.ProdInfo{}
rt.Product.Major = "1"
rt.Product.Minor = "52"
rt.Product.Patch = "2"
rt.Product.Minor = "53"
rt.Product.Patch = "0"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Community"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "documize",
"version": "1.52.2",
"version": "1.53.0",
"description": "The Document IDE",
"private": true,
"repository": "",

View file

@ -1,16 +1,16 @@
{
"community":
{
"version": "1.52.2",
"version": "1.53.0",
"major": 1,
"minor": 52,
"patch": 2
"minor": 53,
"patch": 0
},
"enterprise":
{
"version": "1.54.2",
"version": "1.55.0",
"major": 1,
"minor": 54,
"patch": 2
"minor": 55,
"patch": 0
}
}