ClientID:          "raptors",
				SourceDescription: "raptors description",
				KindID:            "non-critical-kind",
				KindDescription:   "non critical kind description",
				Email:             true,
			},
			{
				ClientID:          "raptors",
				SourceDescription: "raptors description",
				KindID:            "other-kind",
				KindDescription:   "other kind description",
				Email:             false,
			},
		}

		fakeGlobalUnsubscribesRepo := mocks.NewGlobalUnsubscribesRepo()
		fakeGlobalUnsubscribesRepo.GetCall.Returns.Unsubscribed = true

		preferencesRepo = mocks.NewPreferencesRepo()
		preferencesRepo.FindNonCriticalPreferencesCall.Returns.Preferences = preferences

		conn = mocks.NewConnection()
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = conn

		finder = services.NewPreferencesFinder(preferencesRepo, fakeGlobalUnsubscribesRepo)
	})

	Describe("Find", func() {
		It("returns the set of notifications that are not critical", func() {
			expectedResult := services.NewPreferencesBuilder()
예제 #2
0
		messageID              string
		messageStatusUpdater   *mocks.MessageStatusUpdater
		deliveryFailureHandler *mocks.DeliveryFailureHandler
	)

	BeforeEach(func() {
		buffer = bytes.NewBuffer([]byte{})

		logger = lager.NewLogger("notifications")
		logger.RegisterSink(lager.NewWriterSink(buffer, lager.DEBUG))
		logger = logger.Session("worker", lager.Data{"worker_id": 1234})

		mailClient = mocks.NewMailClient()
		queue = mocks.NewQueue()
		unsubscribesRepo = mocks.NewUnsubscribesRepo()
		globalUnsubscribesRepo = mocks.NewGlobalUnsubscribesRepo()

		kindsRepo = mocks.NewKindsRepo()
		kindsRepo.FindCall.Returns.Kinds = []models.Kind{
			{
				ID:       "some-kind",
				ClientID: "some-client",
				Critical: false,
			},
		}

		conn = mocks.NewConnection()
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = conn

		strategyDeterminer = mocks.NewStrategyDeterminer()