diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-14 09:08:01 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-14 09:08:01 +0000 |
commit | af60c8a79f77c8230292a133fb9d09dab5cd5cd3 (patch) | |
tree | 7db57df336144ae99b2e299e467b6c75f3356daf /spec/requests/api/discussions_spec.rb | |
parent | b747a99e48ac36c351ec6f4329b8e5f75d5ed253 (diff) | |
download | gitlab-ce-af60c8a79f77c8230292a133fb9d09dab5cd5cd3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/discussions_spec.rb')
-rw-r--r-- | spec/requests/api/discussions_spec.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/requests/api/discussions_spec.rb b/spec/requests/api/discussions_spec.rb index 89769314daa..38016375b8f 100644 --- a/spec/requests/api/discussions_spec.rb +++ b/spec/requests/api/discussions_spec.rb @@ -29,6 +29,73 @@ RSpec.describe API::Discussions, feature_category: :team_planning do end end + context 'when noteable is a WorkItem' do + let!(:work_item) { create(:work_item, :issue, project: project, author: user) } + let!(:work_item_note) { create(:discussion_note_on_issue, noteable: work_item, project: project, author: user) } + + let(:parent) { project } + let(:noteable) { work_item } + let(:note) { work_item_note } + let(:url) { "/projects/#{parent.id}/issues/#{noteable[:iid]}/discussions" } + + it_behaves_like 'discussions API', 'projects', 'issues', 'iid', can_reply_to_individual_notes: true + + context 'with work item without notes widget' do + before do + stub_const('WorkItems::Type::BASE_TYPES', { issue: { name: 'NoNotesWidget', enum_value: 0 } }) + stub_const('WorkItems::Type::WIDGETS_FOR_TYPE', { issue: [::WorkItems::Widgets::Description] }) + end + + context 'when fetching discussions' do + it "returns 404" do + get api(url, user) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when single fetching discussion by discussion_id' do + it "returns 404" do + get api("#{url}/#{work_item_note.discussion_id}", user) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when trying to create a new discussion' do + it "returns 404" do + post api(url, user), params: { body: 'hi!' } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when trying to create a new comment on a discussion' do + it 'returns 404' do + post api("#{url}/#{note.discussion_id}/notes", user), params: { body: 'Hello!' } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when trying to update a new comment on a discussion' do + it 'returns 404' do + put api("#{url}/notes/#{note.id}", user), params: { body: 'Update Hello!' } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when deleting a note' do + it 'returns 404' do + delete api("#{url}/#{note.discussion_id}/notes/#{note.id}", user) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end + end + context 'when noteable is a Snippet' do let!(:snippet) { create(:project_snippet, project: project, author: user) } let!(:snippet_note) { create(:discussion_note_on_project_snippet, noteable: snippet, project: project, author: user) } |