Skip to content

Commit

Permalink
Fix time dependent test
Browse files Browse the repository at this point in the history
Test is dependent on the current time: recurring meetings are created
from 31-12-2024 and the expectations to have 3 occurrences showing up
fail if current time is after 01-01-2025.

Use fixed current time using `travel_to`, but for one test it had to be
in a `before_all` block because some objects were created with
`shared_let`, and modifying them then generated an error because of the
journal creation dates not being in order. It then also had to be
duplicated in the `before(:each)` block of the test but I'm not sure
why.
  • Loading branch information
cbliard committed Jan 3, 2025
1 parent 338cb95 commit 20f76d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
let(:show_page) { Pages::RecurringMeeting::Show.new(meeting) }
let(:meetings_page) { Pages::Meetings::Index.new(project:) }

before do
travel_to(Date.new(2024, 12, 1))
end

context "with a user with permissions" do
it "can create a recurring meeting" do
login_as current_user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
with_flag: { recurring_meetings: true } 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,
Expand Down Expand Up @@ -71,6 +79,7 @@
let(:meetings_page) { Pages::Meetings::Index.new(project:) }

before do
travel_to(Date.new(2024, 12, 1))
login_as current_user

# Assuming the first init job has run
Expand Down

0 comments on commit 20f76d9

Please sign in to comment.