Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/discussions_spec.rb')
-rw-r--r--spec/requests/api/discussions_spec.rb69
1 files changed, 68 insertions, 1 deletions
diff --git a/spec/requests/api/discussions_spec.rb b/spec/requests/api/discussions_spec.rb
index 258bd26c05a..38016375b8f 100644
--- a/spec/requests/api/discussions_spec.rb
+++ b/spec/requests/api/discussions_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe API::Discussions do
+RSpec.describe API::Discussions, feature_category: :team_planning do
let(:user) { create(:user) }
let!(:project) { create(:project, :public, :repository, namespace: user.namespace) }
let(:private_user) { create(:user) }
@@ -29,6 +29,73 @@ RSpec.describe API::Discussions 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) }