Ejemplo n.º 1
0
func (m *Mother) NotificationsUpdater() services.NotificationsUpdater {
	_, kindsRepo := m.Repos()
	return services.NewNotificationsUpdater(kindsRepo)
}
var _ = Describe("NotificationUpdater", func() {
	var (
		notificationsUpdater services.NotificationsUpdater
		kindsRepo            *mocks.KindsRepo
		database             *mocks.Database
		conn                 *mocks.Connection
	)

	BeforeEach(func() {
		kindsRepo = mocks.NewKindsRepo()
		conn = mocks.NewConnection()
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = conn

		notificationsUpdater = services.NewNotificationsUpdater(kindsRepo)
	})

	Describe("Update", func() {
		It("updates the correct model with the new fields provided", func() {
			kindsRepo.UpdateCall.Returns.Kind = models.Kind{
				ID:          "my-current-kind-id",
				ClientID:    "my-current-client-id",
				Description: "What a beautiful description",
				TemplateID:  "my-current-template-id",
				Critical:    false,
			}

			err := notificationsUpdater.Update(database, models.Kind{
				ID:          "my-current-kind-id",
				Description: "some-description",