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>2021-12-20 16:37:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/requests/api/topics_spec.rb
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/requests/api/topics_spec.rb')
-rw-r--r--spec/requests/api/topics_spec.rb40
1 files changed, 37 insertions, 3 deletions
diff --git a/spec/requests/api/topics_spec.rb b/spec/requests/api/topics_spec.rb
index a5746a4022e..70eee8a1af9 100644
--- a/spec/requests/api/topics_spec.rb
+++ b/spec/requests/api/topics_spec.rb
@@ -5,15 +5,15 @@ require 'spec_helper'
RSpec.describe API::Topics do
include WorkhorseHelpers
- let_it_be(:topic_1) { create(:topic, name: 'Git', total_projects_count: 1) }
+ let_it_be(:file) { fixture_file_upload('spec/fixtures/dk.png') }
+
+ let_it_be(:topic_1) { create(:topic, name: 'Git', total_projects_count: 1, avatar: file) }
let_it_be(:topic_2) { create(:topic, name: 'GitLab', total_projects_count: 2) }
let_it_be(:topic_3) { create(:topic, name: 'other-topic', total_projects_count: 3) }
let_it_be(:admin) { create(:user, :admin) }
let_it_be(:user) { create(:user) }
- let(:file) { fixture_file_upload('spec/fixtures/dk.png') }
-
describe 'GET /topics', :aggregate_failures do
it 'returns topics ordered by total_projects_count' do
get api('/topics')
@@ -184,6 +184,14 @@ RSpec.describe API::Topics do
expect(json_response['avatar_url']).to end_with('dk.png')
end
+ it 'keeps avatar when updating other fields' do
+ put api("/topics/#{topic_1.id}", admin), params: { name: 'my-topic' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['name']).to eq('my-topic')
+ expect(topic_1.reload.avatar_url).not_to be_nil
+ end
+
it 'returns 404 for non existing id' do
put api("/topics/#{non_existing_record_id}", admin), params: { name: 'my-topic' }
@@ -196,6 +204,32 @@ RSpec.describe API::Topics do
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eql('id is invalid')
end
+
+ context 'with blank avatar' do
+ it 'removes avatar' do
+ put api("/topics/#{topic_1.id}", admin), params: { avatar: '' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['avatar_url']).to be_nil
+ expect(topic_3.reload.avatar_url).to be_nil
+ end
+
+ it 'removes avatar besides other changes' do
+ put api("/topics/#{topic_1.id}", admin), params: { name: 'new-topic-name', avatar: '' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['name']).to eq('new-topic-name')
+ expect(json_response['avatar_url']).to be_nil
+ expect(topic_1.reload.avatar_url).to be_nil
+ end
+
+ it 'does not remove avatar in case of other errors' do
+ put api("/topics/#{topic_1.id}", admin), params: { name: topic_2.name, avatar: '' }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(topic_1.reload.avatar_url).not_to be_nil
+ end
+ end
end
context 'as normal user' do