Skip to content

Commit

Permalink
make the conflict spec less flaky
Browse files Browse the repository at this point in the history
The dependence on the time could have made the spec flaky (with
timecop), as depending on the specs running speed the advancement in
secods was not deterministic really. We now set explicit times when
simulating the conflict.
  • Loading branch information
koffeinfrei committed Aug 31, 2024
1 parent 4a728e1 commit ecf0bb3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spec/features/edit_note_conflict_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@
expect(page).to have_content 'note content'

# ...in the meantime there's an edit
travel_to Time.zone.local(2016, 8, 1, 15, 34)
note.update! content: '<p>note content - update 1</p>'

travel_to Time.zone.local(2016, 8, 1, 15, 35)
find('.ql-editor').set('note content - update 2')

after_save_cycle do
expect(page).to have_content 'SAVED'
end

expect(page).to have_content 'my note (conflict 2016-08-01 15:33)'
expect(page).to have_content 'my note (conflict 2016-08-01 15:35)'

# the note has the updated content
expect(note.reload.content).to eq '<p>note content - update 2</p>'

# the conflict copy has the old content
expect(Note.last).to have_attributes(
title: 'my note (conflict 2016-08-01 15:33)',
title: 'my note (conflict 2016-08-01 15:35)',
content: '<p>note content - update 1</p>'
)
end
Expand Down

0 comments on commit ecf0bb3

Please sign in to comment.