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()
			expectedResult.Add(preferences[0])
			expectedResult.Add(preferences[1])
			expectedResult.GlobalUnsubscribe = true

			resultPreferences, err := finder.Find(database, "correct-user")
			Expect(err).NotTo(HaveOccurred())
			Expect(resultPreferences).To(Equal(expectedResult))

			Expect(preferencesRepo.FindNonCriticalPreferencesCall.Receives.Connection).To(Equal(conn))
			Expect(preferencesRepo.FindNonCriticalPreferencesCall.Receives.UserGUID).To(Equal("correct-user"))
Exemple #2
0
func (m *Mother) PreferencesFinder() *services.PreferencesFinder {
	return services.NewPreferencesFinder(v1models.NewPreferencesRepo(), m.GlobalUnsubscribesRepo())
}