testTemplates = map[string]services.TemplateSummary{
				"chewbaca-guid": {
					Name: "Star Wars",
				},
				"giant-friendly-robot-guid": {
					Name: "Big Hero 6",
				},
				"boring-template-guid": {
					Name: "Blah",
				},
				"starvation-guid": {
					Name: "Hungry Play",
				},
			}

			lister = mocks.NewTemplateLister()
			lister.ListCall.Returns.TemplateSummaries = testTemplates

			writer = httptest.NewRecorder()
			errorWriter = mocks.NewErrorWriter()

			database = mocks.NewDatabase()
			context = stack.NewContext()
			context.Set("database", database)

			handler = templates.NewListHandler(lister, errorWriter)
		})

		Context("when the lister does not error", func() {
			BeforeEach(func() {
				var err error
Example #2
0
	. "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() {
		It("routes GET /templates", func() {
			request, err := http.NewRequest("GET", "/templates", nil)
			Expect(err).NotTo(HaveOccurred())