mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Stabilize time-sensitive feature specs
Use shared_let for frozen feature spec times
This commit is contained in:
@@ -247,14 +247,6 @@ RSpec.describe "Meeting Backlogs", :js do
|
||||
end
|
||||
|
||||
describe "for meeting series" do
|
||||
before_all do
|
||||
travel_to(Date.new(2024, 12, 1))
|
||||
end
|
||||
|
||||
after(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
travel_back
|
||||
end
|
||||
|
||||
shared_let(:recurring_meeting) do
|
||||
create :recurring_meeting,
|
||||
project:,
|
||||
@@ -276,6 +268,10 @@ RSpec.describe "Meeting Backlogs", :js do
|
||||
RecurringMeetings::InitNextOccurrenceJob.perform_now(recurring_meeting, next_occurrence_time)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
describe "backlog visibility" do
|
||||
context "when the meeting is 'open'" do
|
||||
it "is expanded" do
|
||||
|
||||
@@ -32,6 +32,12 @@ require "spec_helper"
|
||||
require_relative "../support/pages/meetings/index"
|
||||
|
||||
RSpec.describe "Meetings", "Index", :js do
|
||||
shared_let(:business_day_at_noon) { Time.zone.local(2025, 1, 8, 12, 0, 0) }
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
# The order the Projects are created in is important. By naming `project` alphanumerically
|
||||
# after `other_project`, we can ensure that subsequent specs that assert sorting is
|
||||
# correct for the right reasons (sorting by Project name and not id)
|
||||
@@ -55,14 +61,14 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Awesome meeting today!",
|
||||
start_time: Time.current)
|
||||
start_time: business_day_at_noon - 5.minutes)
|
||||
end
|
||||
shared_let(:tomorrows_meeting) do
|
||||
create(:meeting,
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Awesome meeting tomorrow!",
|
||||
start_time: 1.day.from_now,
|
||||
start_time: business_day_at_noon + 1.day,
|
||||
duration: 2.0,
|
||||
location: "no-protocol.com")
|
||||
end
|
||||
@@ -71,7 +77,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Boring meeting without a location!",
|
||||
start_time: 1.day.from_now,
|
||||
start_time: business_day_at_noon + 1.day + 5.minutes,
|
||||
location: "")
|
||||
end
|
||||
shared_let(:meeting_with_malicious_location) do
|
||||
@@ -79,7 +85,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Sneaky meeting!",
|
||||
start_time: 1.day.from_now,
|
||||
start_time: business_day_at_noon + 1.day + 10.minutes,
|
||||
location: "<script>alert('Description');</script>")
|
||||
end
|
||||
shared_let(:yesterdays_meeting) do
|
||||
@@ -87,7 +93,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Awesome meeting yesterday!",
|
||||
start_time: 1.day.ago)
|
||||
start_time: business_day_at_noon - 1.day)
|
||||
end
|
||||
|
||||
shared_let(:other_project_meeting) do
|
||||
@@ -95,7 +101,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project: other_project,
|
||||
title: "Awesome other project meeting!",
|
||||
start_time: 2.days.from_now,
|
||||
start_time: business_day_at_noon + 2.days,
|
||||
duration: 2.0,
|
||||
location: "not-a-url")
|
||||
end
|
||||
@@ -104,7 +110,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
:author_participates,
|
||||
project:,
|
||||
title: "Awesome ongoing meeting!",
|
||||
start_time: 30.minutes.ago)
|
||||
start_time: business_day_at_noon - 30.minutes)
|
||||
end
|
||||
|
||||
def setup_meeting_involvement
|
||||
@@ -120,6 +126,7 @@ RSpec.describe "Meetings", "Index", :js do
|
||||
end
|
||||
|
||||
before do
|
||||
travel_to(business_day_at_noon)
|
||||
login_as user
|
||||
end
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ RSpec.describe "Move agenda items to section", :js do
|
||||
login_as current_user
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
describe "for one-time meetings" do
|
||||
shared_let(:meeting) do
|
||||
create :meeting,
|
||||
|
||||
@@ -74,6 +74,10 @@ RSpec.describe "Recurring meetings creation",
|
||||
travel_to(Date.new(2024, 12, 1))
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
context "with a user with permissions" do
|
||||
it "can create a recurring meeting" do
|
||||
login_as current_user
|
||||
|
||||
@@ -38,14 +38,6 @@ RSpec.describe "Recurring meetings CRUD",
|
||||
:js do
|
||||
include Components::Autocompleter::NgSelectAutocompleteHelpers
|
||||
|
||||
before_all do
|
||||
travel_to(Date.new(2024, 12, 1))
|
||||
end
|
||||
|
||||
after(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
travel_back
|
||||
end
|
||||
|
||||
shared_let(:project) { create(:project, enabled_module_names: %w[meetings]) }
|
||||
shared_let(:user) do
|
||||
create :user,
|
||||
@@ -85,6 +77,10 @@ RSpec.describe "Recurring meetings CRUD",
|
||||
RecurringMeetings::InitNextOccurrenceJob.perform_now(meeting, meeting.first_occurrence.to_time)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
it "can delete a recurring meeting from the show page and return to the index page" do
|
||||
show_page.visit!
|
||||
|
||||
|
||||
+4
-8
@@ -37,14 +37,6 @@ require_relative "../../support/pages/meetings/index"
|
||||
RSpec.describe "Recurring meetings global CRUD", :js do
|
||||
include Components::Autocompleter::NgSelectAutocompleteHelpers
|
||||
|
||||
before_all do
|
||||
travel_to(Date.new(2024, 12, 1))
|
||||
end
|
||||
|
||||
after(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
travel_back
|
||||
end
|
||||
|
||||
shared_let(:project) { create(:project, enabled_module_names: %w[meetings]) }
|
||||
shared_let(:user) do
|
||||
create :user,
|
||||
@@ -84,6 +76,10 @@ RSpec.describe "Recurring meetings global CRUD", :js do
|
||||
RecurringMeetings::InitNextOccurrenceJob.perform_now(meeting, meeting.first_occurrence.to_time)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
it "can delete a recurring meeting from the show page and return to the index page" do
|
||||
show_page.visit!
|
||||
|
||||
|
||||
+4
-8
@@ -193,14 +193,6 @@ RSpec.describe "Meetings CRUD",
|
||||
end
|
||||
|
||||
context "for meeting series, across the same occurrence" do
|
||||
before_all do
|
||||
travel_to(Date.new(2024, 12, 1))
|
||||
end
|
||||
|
||||
after(:all) do # rubocop:disable RSpec/BeforeAfterAll
|
||||
travel_back
|
||||
end
|
||||
|
||||
let(:recurring_meeting) do
|
||||
create :recurring_meeting,
|
||||
project:,
|
||||
@@ -222,6 +214,10 @@ RSpec.describe "Meetings CRUD",
|
||||
RecurringMeetings::InitNextOccurrenceJob.perform_now(recurring_meeting, first_occurrence_time)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
it_behaves_like "no flash appears when interacting with backlog in multiple windows"
|
||||
end
|
||||
|
||||
|
||||
@@ -556,26 +556,36 @@ RSpec.describe "filter work packages", :js do
|
||||
end
|
||||
|
||||
describe "datetime filters" do
|
||||
shared_let(:business_day_at_noon) { Time.find_zone!("Europe/Kyiv").local(2025, 1, 8, 12, 0, 0) }
|
||||
|
||||
before do
|
||||
travel_to(business_day_at_noon)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
shared_let(:wp_updated_today) do
|
||||
create(:work_package,
|
||||
subject: "Created today",
|
||||
project:,
|
||||
created_at: Time.current.change(hour: 12),
|
||||
updated_at: Time.current.change(hour: 12))
|
||||
created_at: business_day_at_noon,
|
||||
updated_at: business_day_at_noon)
|
||||
end
|
||||
shared_let(:wp_updated_3d_ago) do
|
||||
create(:work_package,
|
||||
subject: "Created 3d ago",
|
||||
project:,
|
||||
created_at: 3.days.ago,
|
||||
updated_at: 3.days.ago)
|
||||
created_at: business_day_at_noon - 3.days,
|
||||
updated_at: business_day_at_noon - 3.days)
|
||||
end
|
||||
shared_let(:wp_updated_5d_ago) do
|
||||
create(:work_package,
|
||||
subject: "Created 5d ago",
|
||||
project:,
|
||||
created_at: 5.days.ago,
|
||||
updated_at: 5.days.ago)
|
||||
created_at: business_day_at_noon - 5.days,
|
||||
updated_at: business_day_at_noon - 5.days)
|
||||
end
|
||||
|
||||
it "filters on date by created_at (Regression #28459)" do
|
||||
|
||||
@@ -50,6 +50,10 @@ module TableHelpers::ColumnType
|
||||
travel_to(fake_today)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
describe "origin day" do
|
||||
it "is identified by the 'M' in 'MTWTFSS' in the header and corresponds to the next monday" do
|
||||
expect(parsed_attributes(<<~TABLE))
|
||||
|
||||
@@ -45,6 +45,10 @@ module TableHelpers
|
||||
travel_to(fake_today)
|
||||
end
|
||||
|
||||
after do
|
||||
travel_back
|
||||
end
|
||||
|
||||
it "applies attribute changes to a group of work packages from a visual table representation" do
|
||||
main = build_stubbed(:work_package, subject: "main")
|
||||
second = build_stubbed(:work_package, subject: "second")
|
||||
|
||||
Reference in New Issue
Block a user