Commit 11345e04 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'fix-incorrectly-passing-elasticsearch-issues-notes-spec' into 'master'

Fix incorrectly passing issue spec for Elasticsearch indexing

See merge request gitlab-org/gitlab!48745
parents b2d6ae0f a2a62867
...@@ -489,36 +489,33 @@ RSpec.describe Issue do ...@@ -489,36 +489,33 @@ RSpec.describe Issue do
context 'when updating an Issue' do context 'when updating an Issue' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, confidential: true) } let(:issue) { create(:issue, project: project, confidential: true) }
let!(:note) { create(:note, noteable: issue, project: project) }
let!(:system_note) { create(:note, :system, noteable: issue, project: project) }
before do context 'when changing the confidential value' do
Sidekiq::Testing.disable! do it 'updates issue notes excluding system notes' do
create(:note, note: 'the_normal_note', noteable: issue, project: project) expect_any_instance_of(Note).to receive(:maintain_elasticsearch_update) do |instance|
expect(instance.id).to eq(note.id)
end end
Sidekiq::Testing.inline! do
project.maintain_elasticsearch_update
issue.update!(update_field => update_value) issue.update!(confidential: false)
ensure_elasticsearch_index!
end end
end end
context 'when changing the confidential value' do context 'when changing the author' do
let(:update_field) { :confidential }
let(:update_value) { false }
it 'updates issue notes excluding system notes' do it 'updates issue notes excluding system notes' do
expect(issue.elasticsearch_issue_notes_need_updating?).to eq(true) expect_any_instance_of(Note).to receive(:maintain_elasticsearch_update) do |instance|
expect(Note.elastic_search('the_normal_note', options: { project_ids: [issue.project.id] }).present?).to eq(true) expect(instance.id).to eq(note.id)
end
issue.update!(author: create(:user))
end end
end end
context 'when changing the title' do context 'when changing the title' do
let(:update_field) { :title }
let(:update_value) { 'abc' }
it 'does not update issue notes' do it 'does not update issue notes' do
expect(issue.elasticsearch_issue_notes_need_updating?).to eq(false) expect_any_instance_of(Note).not_to receive(:maintain_elasticsearch_update)
expect(Note.elastic_search('the_normal_note', options: { project_ids: [issue.project.id] }).present?).to eq(false) issue.update!(title: 'the new title')
end end
end end
end end
......
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