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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-30 18:10:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-30 18:10:49 +0300
commit3b28c7e3b25265042fdac8ea83d5fb960eb345b2 (patch)
tree86ef6a9fbe4141d24c4d5e2f5ac4ce51174a011a /spec/controllers
parent8b03b8c00a03f7e55d5880486d7cfe4615cff1c1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/notes_controller_spec.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb
index 52991e3ca93..940f6fed906 100644
--- a/spec/controllers/projects/notes_controller_spec.rb
+++ b/spec/controllers/projects/notes_controller_spec.rb
@@ -155,6 +155,12 @@ RSpec.describe Projects::NotesController, type: :controller, feature_category: :
expect(note_json[:discussion_line_code]).to be_nil
end
+ it 'sets the correct feature category' do
+ get :index, params: params
+
+ expect(::Gitlab::ApplicationContext.current_context_attribute(:feature_category)).to eq('source_code_management')
+ end
+
context 'when user cannot read commit' do
before do
allow(Ability).to receive(:allowed?).and_call_original
@@ -170,6 +176,28 @@ RSpec.describe Projects::NotesController, type: :controller, feature_category: :
end
end
+ context 'for a snippet note' do
+ let(:project_snippet) { create(:project_snippet, project: project) }
+ let!(:note) { create(:note_on_project_snippet, project: project, noteable: project_snippet) }
+
+ let(:params) { request_params.merge(target_type: 'project_snippet', target_id: project_snippet.id, html: true) }
+
+ it 'responds with the expected attributes' do
+ get :index, params: params
+
+ expect(note_json[:id]).to eq(note.id)
+ expect(note_json[:discussion_html]).to be_nil
+ expect(note_json[:diff_discussion_html]).to be_nil
+ expect(note_json[:discussion_line_code]).to be_nil
+ end
+
+ it 'sets the correct feature category' do
+ get :index, params: params
+
+ expect(::Gitlab::ApplicationContext.current_context_attribute(:feature_category)).to eq('source_code_management')
+ end
+ end
+
context 'for a merge request note' do
let!(:note) { create(:note_on_merge_request, project: project) }
@@ -289,6 +317,44 @@ RSpec.describe Projects::NotesController, type: :controller, feature_category: :
end
end
+ context 'on a commit' do
+ let(:commit_id) { RepoHelpers.sample_commit.id }
+ let(:request_params) do
+ {
+ note: { note: note_text, commit_id: commit_id, noteable_type: 'Commit' },
+ namespace_id: project.namespace,
+ project_id: project,
+ target_type: 'commit',
+ target_id: commit_id
+ }
+ end
+
+ it 'sets the correct feature category' do
+ create!
+
+ expect(::Gitlab::ApplicationContext.current_context_attribute(:feature_category)).to eq('source_code_management')
+ end
+ end
+
+ context 'on a project snippet' do
+ let(:project_snippet) { create(:project_snippet, project: project) }
+ let(:request_params) do
+ {
+ note: { note: note_text, noteable_id: project_snippet.id, noteable_type: 'ProjectSnippet' },
+ namespace_id: project.namespace,
+ project_id: project,
+ target_type: 'project_snippet',
+ target_id: project_snippet.id
+ }
+ end
+
+ it 'sets the correct feature category' do
+ create!
+
+ expect(::Gitlab::ApplicationContext.current_context_attribute(:feature_category)).to eq('source_code_management')
+ end
+ end
+
context 'the project is publically available' do
context 'for HTML' do
it "returns status 302" do