Commit f6c7410e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix time being used to poll for resource events

We should query based on the last_fetched_at value passed by the client
and not the new value for the next poll
parent 82692f7f
......@@ -13,9 +13,7 @@ module NotesActions
end
def index
current_fetched_at = Time.current.to_i
notes_json = { notes: [], last_fetched_at: current_fetched_at }
notes_json = { notes: [], last_fetched_at: Time.current.to_i }
notes = notes_finder
.execute
......@@ -24,7 +22,7 @@ module NotesActions
if notes_filter != UserPreference::NOTES_FILTERS[:only_comments]
notes =
ResourceEvents::MergeIntoNotesService
.new(noteable, current_user, last_fetched_at: current_fetched_at)
.new(noteable, current_user, last_fetched_at: last_fetched_at)
.execute(notes)
end
......
---
title: Fix polling for resource events
merge_request: 33025
author:
type: fixed
......@@ -37,7 +37,7 @@ describe Projects::NotesController do
project.add_developer(user)
end
it 'passes last_fetched_at from headers to NotesFinder' do
it 'passes last_fetched_at from headers to NotesFinder and MergeIntoNotesService' do
last_fetched_at = 3.hours.ago.to_i
request.headers['X-Last-Fetched-At'] = last_fetched_at
......@@ -46,6 +46,10 @@ describe Projects::NotesController do
.with(anything, hash_including(last_fetched_at: last_fetched_at))
.and_call_original
expect(ResourceEvents::MergeIntoNotesService).to receive(:new)
.with(anything, anything, hash_including(last_fetched_at: last_fetched_at))
.and_call_original
get :index, params: request_params
end
......
......@@ -25,7 +25,7 @@ RSpec.shared_examples 'thread comments' do |resource_name|
end
if resource_name == 'issue'
it "clicking 'Comment & close #{resource_name}' will post a comment and close the #{resource_name}", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/218757' do
it "clicking 'Comment & close #{resource_name}' will post a comment and close the #{resource_name}" do
find("#{form_selector} .note-textarea").send_keys(comment)
click_button 'Comment & close issue'
......@@ -206,7 +206,7 @@ RSpec.shared_examples 'thread comments' do |resource_name|
end
if resource_name == 'issue'
it "clicking 'Start thread & close #{resource_name}' will post a thread and close the #{resource_name}", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/218757' do
it "clicking 'Start thread & close #{resource_name}' will post a thread and close the #{resource_name}" do
click_button 'Start thread & close issue'
expect(page).to have_content(comment)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment