diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-02-11 15:30:06 +0800 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-02-11 15:30:06 +0800 |
commit | 3dbf06733c2c76768f1076a3b638a1622532efb2 (patch) | |
tree | e44d1ab8dd776c7efde96edd2e8dfb9a79ca0418 | |
parent | ae9a392154c12919a4ace6beaa9997999d591ebf (diff) | |
download | gitlab-ce-3dbf06733c2c76768f1076a3b638a1622532efb2.tar.gz |
Revert "Fix polling for replies to individual notes"
This reverts commit 16ebbbc54ec2a9d477883f0081ae183cfbeb240f.
-rw-r--r-- | app/models/concerns/throttled_touch.rb | 5 | ||||
-rw-r--r-- | app/services/notes/create_service.rb | 5 | ||||
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/shared_examples/throttled_touch.rb | 23 |
4 files changed, 10 insertions, 31 deletions
diff --git a/app/models/concerns/throttled_touch.rb b/app/models/concerns/throttled_touch.rb index ffd675de6b2..797c46f6cc5 100644 --- a/app/models/concerns/throttled_touch.rb +++ b/app/models/concerns/throttled_touch.rb @@ -6,8 +6,7 @@ module ThrottledTouch # The amount of time to wait before "touch" can update a record again. TOUCH_INTERVAL = 1.minute - def touch(*args, **kwargs) - force = kwargs.delete(:force) - super if force || (Time.zone.now - updated_at) > TOUCH_INTERVAL + def touch(*args) + super if (Time.zone.now - updated_at) > TOUCH_INTERVAL end end diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index 08eeb1e7cc4..b975c3a8cb6 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -35,10 +35,7 @@ module Notes if !only_commands && note.save if note.part_of_discussion? && note.discussion.can_convert_to_discussion? - converted_discussion = note.discussion.convert_to_discussion! - converted_discussion.save - # Force update of `updated_at` because of https://gitlab.com/gitlab-org/gitlab-ce/issues/57324 - converted_discussion.first_note.touch(force: true) + note.discussion.convert_to_discussion!.save(touch: false) end todo_service.new_note(note, current_user) diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index d4b15b6bd7b..48f1d696ff6 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -311,13 +311,7 @@ describe Notes::CreateService do end it 'converts existing note to DiscussionNote' do - existing_note - - expect do - Timecop.freeze(Time.now + 30.seconds) { subject } - existing_note.reload - end.to change { existing_note.type }.from(nil).to('DiscussionNote') - .and change { existing_note.updated_at } + expect { subject }.to change { existing_note.reload.type }.from(nil).to('DiscussionNote') end end end diff --git a/spec/support/shared_examples/throttled_touch.rb b/spec/support/shared_examples/throttled_touch.rb index 83f602f77a9..eba990d4037 100644 --- a/spec/support/shared_examples/throttled_touch.rb +++ b/spec/support/shared_examples/throttled_touch.rb @@ -7,25 +7,14 @@ shared_examples_for 'throttled touch' do end end - context 'when updating more than once per minute' do - let(:first_updated_at) { Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 2) } - let(:second_updated_at) { Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 1.5) } + it 'updates the object at most once per minute' do + first_updated_at = Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 2) + second_updated_at = Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 1.5) - before do - Timecop.freeze(first_updated_at) { subject.touch } - end - - it 'does not update the timestamp' do - Timecop.freeze(second_updated_at) { subject.touch } - - expect(subject.updated_at).to be_like_time(first_updated_at) - end - - it 'updates the timestamp when `force` is true' do - Timecop.freeze(second_updated_at) { subject.touch(force: true) } + Timecop.freeze(first_updated_at) { subject.touch } + Timecop.freeze(second_updated_at) { subject.touch } - expect(subject.updated_at).to be_like_time(second_updated_at) - end + expect(subject.updated_at).to be_like_time(first_updated_at) end end end |