)

var _ = Describe("UpdateDefaultHandler", func() {
	var (
		handler     templates.UpdateDefaultHandler
		writer      *httptest.ResponseRecorder
		request     *http.Request
		context     stack.Context
		updater     *mocks.TemplateUpdater
		errorWriter *mocks.ErrorWriter
		database    *mocks.Database
	)

	BeforeEach(func() {
		var err error
		updater = mocks.NewTemplateUpdater()
		errorWriter = mocks.NewErrorWriter()
		writer = httptest.NewRecorder()
		request, err = http.NewRequest("PUT", "/default_template", strings.NewReader(`{
			"name": "Defaultish Template",
			"subject": "{{.Subject}}",
			"html": "<p>something</p>",
			"text": "something",
			"metadata": {"hello": true}
		}`))
		Expect(err).NotTo(HaveOccurred())

		database = mocks.NewDatabase()
		context = stack.NewContext()
		context.Set("database", database)
示例#2
0
	"github.com/cloudfoundry-incubator/notifications/web"
	"github.com/ryanmoran/stack"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Routes", func() {
	var muxer web.Muxer

	BeforeEach(func() {
		muxer = web.NewMuxer()
		templates.Routes{
			ErrorWriter:               mocks.NewErrorWriter(),
			TemplateFinder:            mocks.NewTemplateFinder(),
			TemplateUpdater:           mocks.NewTemplateUpdater(),
			TemplateCreator:           mocks.NewTemplateCreator(),
			TemplateDeleter:           mocks.NewTemplateDeleter(),
			TemplateLister:            mocks.NewTemplateLister(),
			TemplateAssociationLister: mocks.NewTemplateAssociationLister(),

			RequestCounter:                          middleware.RequestCounter{},
			RequestLogging:                          middleware.RequestLogging{},
			DatabaseAllocator:                       middleware.DatabaseAllocator{},
			NotificationsManageAuthenticator:        middleware.Authenticator{Scopes: []string{"notifications.manage"}},
			NotificationTemplatesReadAuthenticator:  middleware.Authenticator{Scopes: []string{"notification_templates.read"}},
			NotificationTemplatesWriteAuthenticator: middleware.Authenticator{Scopes: []string{"notification_templates.write"}},
		}.Register(muxer)
	})

	Describe("/templates", func() {