Commit fec70b63 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'project-topics-remove-tag_list' into 'master'

Replace 'tag_list' with 'topic_list' attribute on project

See merge request gitlab-org/gitlab!63493
parents bdd5434c 2ff0b5e3
...@@ -387,6 +387,10 @@ module Types ...@@ -387,6 +387,10 @@ module Types
::Security::CiConfiguration::SastParserService.new(object).configuration ::Security::CiConfiguration::SastParserService.new(object).configuration
end end
def tag_list
object.topic_list
end
private private
def project def project
......
...@@ -15,16 +15,6 @@ module TagsHelper ...@@ -15,16 +15,6 @@ module TagsHelper
project_tags_path(@project, @id, options) project_tags_path(@project, @id, options)
end end
def tag_list(project)
html = []
project.tag_list.each do |tag|
html << link_to(tag, tag_path(tag))
end
html.join.html_safe
end
def protected_tag?(project, tag) def protected_tag?(project, tag)
ProtectedTag.protected?(project, tag.name) ProtectedTag.protected?(project, tag.name)
end end
......
...@@ -127,10 +127,6 @@ class Project < ApplicationRecord ...@@ -127,10 +127,6 @@ class Project < ApplicationRecord
after_create :check_repository_absence! after_create :check_repository_absence!
acts_as_ordered_taggable_on :topics acts_as_ordered_taggable_on :topics
# The 'tag_list' alias is required during the 'tags -> topics' migration
# TODO: eliminate 'tag_list' in the further process of the migration
# https://gitlab.com/gitlab-org/gitlab/-/issues/328226
alias_attribute :tag_list, :topic_list
attr_accessor :old_path_with_namespace attr_accessor :old_path_with_namespace
attr_accessor :template_name attr_accessor :template_name
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Projects > Show > Schema Markup' do RSpec.describe 'Projects > Show > Schema Markup' do
let_it_be(:project) { create(:project, :repository, :public, :with_avatar, description: 'foobar', tag_list: 'tag1, tag2') } let_it_be(:project) { create(:project, :repository, :public, :with_avatar, description: 'foobar', topic_list: 'topic1, topic2') }
it 'shows SoftwareSourceCode structured markup', :js do it 'shows SoftwareSourceCode structured markup', :js do
visit project_path(project) visit project_path(project)
...@@ -16,7 +16,7 @@ RSpec.describe 'Projects > Show > Schema Markup' do ...@@ -16,7 +16,7 @@ RSpec.describe 'Projects > Show > Schema Markup' do
expect(page).to have_selector('[itemprop="identifier"]', text: "Project ID: #{project.id}") expect(page).to have_selector('[itemprop="identifier"]', text: "Project ID: #{project.id}")
expect(page).to have_selector('[itemprop="description"]', text: project.description) expect(page).to have_selector('[itemprop="description"]', text: project.description)
expect(page).to have_selector('[itemprop="license"]', text: project.repository.license.name) expect(page).to have_selector('[itemprop="license"]', text: project.repository.license.name)
expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.tag_list.map(&:capitalize)) expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.topic_list.map(&:capitalize))
expect(page).to have_selector('[itemprop="about"]') expect(page).to have_selector('[itemprop="about"]')
end end
end end
......
...@@ -10,7 +10,7 @@ RSpec.describe Resolvers::ProjectsResolver do ...@@ -10,7 +10,7 @@ RSpec.describe Resolvers::ProjectsResolver do
let_it_be(:group) { create(:group, name: 'public-group') } let_it_be(:group) { create(:group, name: 'public-group') }
let_it_be(:private_group) { create(:group, name: 'private-group') } let_it_be(:private_group) { create(:group, name: 'private-group') }
let_it_be(:project) { create(:project, :public, tag_list: %w(ruby javascript)) } let_it_be(:project) { create(:project, :public, topic_list: %w(ruby javascript)) }
let_it_be(:other_project) { create(:project, :public) } let_it_be(:other_project) { create(:project, :public) }
let_it_be(:group_project) { create(:project, :public, group: group) } let_it_be(:group_project) { create(:project, :public, group: group) }
let_it_be(:private_project) { create(:project, :private) } let_it_be(:private_project) { create(:project, :private) }
......
...@@ -6945,7 +6945,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -6945,7 +6945,7 @@ RSpec.describe Project, factory_default: :keep do
end end
describe 'topics' do describe 'topics' do
let_it_be(:project) { create(:project, tag_list: 'topic1, topic2, topic3') } let_it_be(:project) { create(:project, topic_list: 'topic1, topic2, topic3') }
it 'topic_list returns correct string array' do it 'topic_list returns correct string array' do
expect(project.topic_list).to match_array(%w[topic1 topic2 topic3]) expect(project.topic_list).to match_array(%w[topic1 topic2 topic3])
...@@ -6955,12 +6955,6 @@ RSpec.describe Project, factory_default: :keep do ...@@ -6955,12 +6955,6 @@ RSpec.describe Project, factory_default: :keep do
expect(project.topics.first.class.name).to eq('ActsAsTaggableOn::Tag') expect(project.topics.first.class.name).to eq('ActsAsTaggableOn::Tag')
expect(project.topics.map(&:name)).to match_array(%w[topic1 topic2 topic3]) expect(project.topics.map(&:name)).to match_array(%w[topic1 topic2 topic3])
end end
context 'aliases' do
it 'tag_list returns correct string array' do
expect(project.tag_list).to match_array(%w[topic1 topic2 topic3])
end
end
end end
shared_examples 'all_runners' do shared_examples 'all_runners' do
......
...@@ -65,7 +65,7 @@ RSpec.describe 'getting project information' do ...@@ -65,7 +65,7 @@ RSpec.describe 'getting project information' do
end end
it 'includes topics array' do it 'includes topics array' do
project.update!(tag_list: 'topic1, topic2, topic3') project.update!(topic_list: 'topic1, topic2, topic3')
post_graphql(query, current_user: current_user) post_graphql(query, current_user: current_user)
......
...@@ -287,9 +287,9 @@ RSpec.describe API::Projects do ...@@ -287,9 +287,9 @@ RSpec.describe API::Projects do
expect(json_response.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count') expect(json_response.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count')
end end
context 'filter by topic (column tag_list)' do context 'filter by topic (column topic_list)' do
before do before do
project.update!(tag_list: %w(ruby javascript)) project.update!(topic_list: %w(ruby javascript))
end end
it 'returns no projects' do it 'returns no projects' do
...@@ -1105,7 +1105,7 @@ RSpec.describe API::Projects do ...@@ -1105,7 +1105,7 @@ RSpec.describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond]) expect(json_response['topics']).to eq(%w[tagFirst tagSecond])
end end
it 'sets topics to a project' do it 'sets topics to a project' do
...@@ -1113,7 +1113,7 @@ RSpec.describe API::Projects do ...@@ -1113,7 +1113,7 @@ RSpec.describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(json_response['tag_list']).to eq(%w[topic1 topics2]) expect(json_response['topics']).to eq(%w[topic1 topics2])
end end
it 'uploads avatar for project a project' do it 'uploads avatar for project a project' do
...@@ -3111,7 +3111,7 @@ RSpec.describe API::Projects do ...@@ -3111,7 +3111,7 @@ RSpec.describe API::Projects do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['tag_list']).to eq(%w[topic1]) expect(json_response['topics']).to eq(%w[topic1])
end end
it 'updates topics' do it 'updates topics' do
...@@ -3121,7 +3121,7 @@ RSpec.describe API::Projects do ...@@ -3121,7 +3121,7 @@ RSpec.describe API::Projects do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['tag_list']).to eq(%w[topic2]) expect(json_response['topics']).to eq(%w[topic2])
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment