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

Attempt to fix flaky specs where the toast might disappear before the page finished loading

Dombi Attilaa56c43a85980
diff --git a/modules/meeting/spec/mailers/meeting_mailer_spec.rb b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
index c7119eb9156..af06a91f25f 100644
--- a/modules/meeting/spec/mailers/meeting_mailer_spec.rb
+++ b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
@@ -86,7 +86,7 @@ RSpec.describe MeetingMailer do
end
context "with a recipient with another time zone" do
- let!(:preference) { create(:user_preference, user: watcher1, time_zone: "Asia/Tokyo") }
+ let!(:preference) { watcher1.pref.update(time_zone: "Asia/Tokyo") }
it "renders the mail with the correcet locale" do
expect(mail.text_part.body).to include("Tokyo")
@@ -119,7 +119,7 @@ RSpec.describe MeetingMailer do
end
describe "it renders november 10th for Tokyo zone" do
- let!(:preference) { create(:user_preference, user: watcher1, time_zone: "Asia/Tokyo") }
+ let!(:preference) { watcher1.pref.update(time_zone: "Asia/Tokyo") }
let(:mail) { described_class.invited(meeting, watcher1, author) }
it "renders the mail with the correct locale" do
@@ -203,7 +203,7 @@ RSpec.describe MeetingMailer do
end
context "with a recipient with another time zone" do
- let!(:preference) { create(:user_preference, user: watcher1, time_zone: "Asia/Tokyo") }
+ let!(:preference) { watcher1.pref.update(time_zone: "Asia/Tokyo") }
let(:mail) { described_class.icalendar_notification(meeting, watcher1, author) }
it "renders the mail with the correct locale" do
@@ -237,7 +237,7 @@ RSpec.describe MeetingMailer do
describe "it renders november 10th for Tokyo zone" do
let(:mail) { described_class.icalendar_notification(meeting, watcher1, author) }
- let!(:preference) { create(:user_preference, user: watcher1, time_zone: "Asia/Tokyo") }
+ let!(:preference) { watcher1.pref.update(time_zone: "Asia/Tokyo") }
it "renders the mail with the correct locale" do
expect(mail.text_part.body).to include("11/10/2021 07:00 AM-08:00 AM (GMT+09:00) Asia/Tokyo")
diff --git a/modules/meeting/spec/services/meetings/ical_service_spec.rb b/modules/meeting/spec/services/meetings/ical_service_spec.rb
index 3fbba0ffe0b..ffb78425398 100644
--- a/modules/meeting/spec/services/meetings/ical_service_spec.rb
+++ b/modules/meeting/spec/services/meetings/ical_service_spec.rb
@@ -30,11 +30,8 @@ require "spec_helper"
RSpec.describe Meetings::ICalService, type: :model do # rubocop:disable RSpec/SpecFilePathFormat
shared_let(:user) do
- create(:user, firstname: "Bob", lastname: "Barker", mail: "[email protected]").tap do |u|
- u.pref[:time_zone] = "America/New_York"
-
- u.save!
- end
+ create(:user, firstname: "Bob", lastname: "Barker",
+ mail: "[email protected]", preferences: { time_zone: "America/New_York" })
end
shared_let(:user2) { create(:user, firstname: "Foo", lastname: "Fooer", mail: "[email protected]") }
shared_let(:project) { create(:project, name: "My Project") }
diff --git a/spec/support/settings.rb b/spec/support/settings.rb
index eb01bb58f9d..bda04058981 100644
--- a/spec/support/settings.rb
+++ b/spec/support/settings.rb
@@ -69,10 +69,15 @@ def get_week_days(*days)
end
end
+def default_auto_hide_popups_false
+ Setting.default_auto_hide_popups = false
+end
+
RSpec.configure do |config|
config.before(:suite) do
# The test suite assumes the default of all days working.
# Since the Setting default is with Sat-Sun non-working, we update it before the tests.
week_with_all_days_working
+ default_auto_hide_popups_false
end
end