Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add test case for user without preferences

ulfertsf0692790c575
diff --git a/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb b/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
index fe41aa2895e..875a376d909 100644
--- a/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
+++ b/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
@@ -30,7 +30,7 @@
require 'spec_helper'
-describe User, '.with_reminder_mail_to_send', type: :job do
+describe User, '.having_reminder_mail_to_send', type: :job do
subject(:scope) do
described_class.having_reminder_mail_to_send(scope_time)
end
@@ -337,4 +337,30 @@ describe User, '.with_reminder_mail_to_send', type: :job do
.to raise_error ArgumentError
end
end
+
+ context 'for a user without preferences at 08:00' do
+ let(:current_utc_time) { ActiveSupport::TimeZone['UTC'].parse("08:00").utc }
+
+ before do
+ paris_user.pref.destroy
+ end
+
+ it 'is including the user as UTC at 08:00 is assumed' do
+ expect(scope)
+ .to match_array([paris_user])
+ end
+ end
+
+ context 'for a user without preferences at 10:00' do
+ let(:current_utc_time) { ActiveSupport::TimeZone['UTC'].parse("10:00").utc }
+
+ before do
+ paris_user.pref.destroy
+ end
+
+ it 'is empty as UTC at 08:00 is assumed' do
+ expect(scope)
+ .to be_empty
+ end
+ end
end