1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
shared_examples 'issuable notes filter' do
it 'sets discussion filter' do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter
expect(user.reload.notes_filter_for(issuable)).to eq(notes_filter)
expect(UserPreference.count).to eq(1)
end
it 'expires notes e-tag cache for issuable if filter changed' do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
expect_any_instance_of(issuable.class).to receive(:expire_note_etag_cache)
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter
end
it 'does not expires notes e-tag cache for issuable if filter did not change' do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
user.set_notes_filter(notes_filter, issuable)
expect_any_instance_of(issuable.class).not_to receive(:expire_note_etag_cache)
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter
end
it 'does not set notes filter when database is in read only mode' do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter
expect(user.reload.notes_filter_for(issuable)).to eq(0)
end
it 'returns no system note' do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issuable)
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid
expect(JSON.parse(response.body).count).to eq(1)
end
context 'when filter is set to "only_comments"' do
it 'does not merge label event notes' do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issuable)
expect(ResourceEvents::MergeIntoNotesService).not_to receive(:new)
get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid
end
end
end
|