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>2022-08-12 00:09:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-12 00:09:14 +0300
commit0f079aa28d93f40ad7fda398fb2280c3e358098d (patch)
treebc67abda12fd05a9712cd0bd97f82e33eb6c927f /spec/controllers
parent603ee53dbdbd3adaced752e1a119eb40d64e9979 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin/topics_controller_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/controllers/admin/topics_controller_spec.rb b/spec/controllers/admin/topics_controller_spec.rb
index ee36d5f1def..87093e0263b 100644
--- a/spec/controllers/admin/topics_controller_spec.rb
+++ b/spec/controllers/admin/topics_controller_spec.rb
@@ -173,4 +173,44 @@ RSpec.describe Admin::TopicsController do
end
end
end
+
+ describe 'POST #merge' do
+ let_it_be(:source_topic) { create(:topic, name: 'source_topic') }
+ let_it_be(:project) { create(:project, topic_list: source_topic.name ) }
+
+ it 'merges source topic into target topic' do
+ post :merge, params: { source_topic_id: source_topic.id, target_topic_id: topic.id }
+
+ expect(response).to redirect_to(admin_topics_path)
+ expect(topic.projects).to contain_exactly(project)
+ expect { source_topic.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ it 'renders a 404 error for non-existing id' do
+ post :merge, params: { source_topic_id: non_existing_record_id, target_topic_id: topic.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect { topic.reload }.not_to raise_error
+ end
+
+ it 'renders a 400 error for identical topic ids' do
+ post :merge, params: { source_topic_id: topic, target_topic_id: topic.id }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect { topic.reload }.not_to raise_error
+ end
+
+ context 'as a normal user' do
+ before do
+ sign_in(user)
+ end
+
+ it 'renders a 404 error' do
+ post :merge, params: { source_topic_id: source_topic.id, target_topic_id: topic.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect { source_topic.reload }.not_to raise_error
+ end
+ end
+ end
end