Commit 6050b348 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'dz-cleanup-deprecated-code' into 'master'

Remove some deprecated code

See merge request gitlab-org/gitlab-ce!29222
parents 338c7b31 15ba85ab
...@@ -43,7 +43,7 @@ class IssuableFinder ...@@ -43,7 +43,7 @@ class IssuableFinder
FILTER_NONE = 'none'.freeze FILTER_NONE = 'none'.freeze
FILTER_ANY = 'any'.freeze FILTER_ANY = 'any'.freeze
# This is accepted as a deprecated filter and is also used in unassigning users # This is used in unassigning users
NONE = '0'.freeze NONE = '0'.freeze
attr_accessor :current_user, :params attr_accessor :current_user, :params
...@@ -248,8 +248,7 @@ class IssuableFinder ...@@ -248,8 +248,7 @@ class IssuableFinder
def filter_by_no_label? def filter_by_no_label?
downcased = label_names.map(&:downcase) downcased = label_names.map(&:downcase)
# Label::NONE is deprecated and should be removed in 12.0 downcased.include?(FILTER_NONE)
downcased.include?(FILTER_NONE) || downcased.include?(Label::NONE)
end end
def filter_by_any_label? def filter_by_any_label?
...@@ -449,8 +448,7 @@ class IssuableFinder ...@@ -449,8 +448,7 @@ class IssuableFinder
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def filter_by_no_assignee? def filter_by_no_assignee?
# Assignee_id takes precedence over assignee_username params[:assignee_id].to_s.downcase == FILTER_NONE
[NONE, FILTER_NONE].include?(params[:assignee_id].to_s.downcase) || params[:assignee_username].to_s == NONE
end end
def filter_by_any_assignee? def filter_by_any_assignee?
......
...@@ -17,13 +17,11 @@ class BroadcastMessage < ApplicationRecord ...@@ -17,13 +17,11 @@ class BroadcastMessage < ApplicationRecord
default_value_for :font, '#FFFFFF' default_value_for :font, '#FFFFFF'
CACHE_KEY = 'broadcast_message_current_json'.freeze CACHE_KEY = 'broadcast_message_current_json'.freeze
LEGACY_CACHE_KEY = 'broadcast_message_current'.freeze
after_commit :flush_redis_cache after_commit :flush_redis_cache
def self.current def self.current
messages = cache.fetch(CACHE_KEY, as: BroadcastMessage, expires_in: cache_expires_in) do messages = cache.fetch(CACHE_KEY, as: BroadcastMessage, expires_in: cache_expires_in) do
remove_legacy_cache_key
current_and_future_messages current_and_future_messages
end end
...@@ -50,14 +48,6 @@ class BroadcastMessage < ApplicationRecord ...@@ -50,14 +48,6 @@ class BroadcastMessage < ApplicationRecord
nil nil
end end
# This can be removed in GitLab 12.0+
# The old cache key had an indefinite lifetime, and in an HA
# environment a one-shot migration would not work because the cache
# would be repopulated by a node that has not been upgraded.
def self.remove_legacy_cache_key
cache.expire(LEGACY_CACHE_KEY)
end
def active? def active?
started? && !ended? started? && !ended?
end end
...@@ -84,6 +74,5 @@ class BroadcastMessage < ApplicationRecord ...@@ -84,6 +74,5 @@ class BroadcastMessage < ApplicationRecord
def flush_redis_cache def flush_redis_cache
self.class.cache.expire(CACHE_KEY) self.class.cache.expire(CACHE_KEY)
self.class.remove_legacy_cache_key
end end
end end
...@@ -13,7 +13,6 @@ class Label < ApplicationRecord ...@@ -13,7 +13,6 @@ class Label < ApplicationRecord
cache_markdown_field :description, pipeline: :single_line cache_markdown_field :description, pipeline: :single_line
DEFAULT_COLOR = '#428BCA' DEFAULT_COLOR = '#428BCA'
NONE = 'no label'
default_value_for :color, DEFAULT_COLOR default_value_for :color, DEFAULT_COLOR
......
...@@ -210,7 +210,7 @@ describe 'Issues' do ...@@ -210,7 +210,7 @@ describe 'Issues' do
let(:issue) { @issue } let(:issue) { @issue }
it 'allows filtering by issues with no specified assignee' do it 'allows filtering by issues with no specified assignee' do
visit project_issues_path(project, assignee_id: IssuableFinder::NONE) visit project_issues_path(project, assignee_id: IssuableFinder::FILTER_NONE)
expect(page).to have_content 'foobar' expect(page).to have_content 'foobar'
expect(page).not_to have_content 'barbaz' expect(page).not_to have_content 'barbaz'
......
...@@ -33,7 +33,7 @@ describe 'Merge requests > User lists merge requests' do ...@@ -33,7 +33,7 @@ describe 'Merge requests > User lists merge requests' do
end end
it 'filters on no assignee' do it 'filters on no assignee' do
visit_merge_requests(project, assignee_id: IssuableFinder::NONE) visit_merge_requests(project, assignee_id: IssuableFinder::FILTER_NONE)
expect(current_path).to eq(project_merge_requests_path(project)) expect(current_path).to eq(project_merge_requests_path(project))
expect(page).to have_content 'merge-test' expect(page).to have_content 'merge-test'
......
...@@ -241,14 +241,6 @@ describe IssuesFinder do ...@@ -241,14 +241,6 @@ describe IssuesFinder do
end end
end end
context 'filtering by legacy No+Label' do
let(:params) { { label_name: Label::NONE } }
it 'returns issues with no labels' do
expect(issues).to contain_exactly(issue1, issue3, issue4)
end
end
context 'filtering by any label' do context 'filtering by any label' do
let(:params) { { label_name: described_class::FILTER_ANY } } let(:params) { { label_name: described_class::FILTER_ANY } }
......
...@@ -88,13 +88,6 @@ describe BroadcastMessage do ...@@ -88,13 +88,6 @@ describe BroadcastMessage do
expect(Rails.cache).not_to receive(:delete).with(described_class::CACHE_KEY) expect(Rails.cache).not_to receive(:delete).with(described_class::CACHE_KEY)
expect(described_class.current.length).to eq(0) expect(described_class.current.length).to eq(0)
end end
it 'clears the legacy cache key' do
create(:broadcast_message, :future)
expect(Rails.cache).to receive(:delete).with(described_class::LEGACY_CACHE_KEY)
expect(described_class.current.length).to eq(0)
end
end end
describe '#attributes' do describe '#attributes' do
...@@ -164,7 +157,6 @@ describe BroadcastMessage do ...@@ -164,7 +157,6 @@ describe BroadcastMessage do
message = create(:broadcast_message) message = create(:broadcast_message)
expect(Rails.cache).to receive(:delete).with(described_class::CACHE_KEY) expect(Rails.cache).to receive(:delete).with(described_class::CACHE_KEY)
expect(Rails.cache).to receive(:delete).with(described_class::LEGACY_CACHE_KEY)
message.flush_redis_cache message.flush_redis_cache
end end
......
...@@ -273,14 +273,6 @@ describe API::Issues do ...@@ -273,14 +273,6 @@ describe API::Issues do
expect_paginated_array_response(issue2.id) expect_paginated_array_response(issue2.id)
end end
it 'returns issues with no assignee' do
issue2 = create(:issue, author: user2, project: project)
get api('/issues', user), params: { assignee_id: 0, scope: 'all' }
expect_paginated_array_response(issue2.id)
end
it 'returns issues with no assignee' do it 'returns issues with no assignee' do
issue2 = create(:issue, author: user2, project: project) issue2 = create(:issue, author: user2, project: project)
...@@ -496,18 +488,6 @@ describe API::Issues do ...@@ -496,18 +488,6 @@ describe API::Issues do
expect_paginated_array_response(closed_issue.id) expect_paginated_array_response(closed_issue.id)
end end
it 'returns an array of issues with no label when using the legacy No+Label filter' do
get api('/issues', user), params: { labels: 'No Label' }
expect_paginated_array_response(closed_issue.id)
end
it 'returns an array of issues with no label when using the legacy No+Label filter with labels param as array' do
get api('/issues', user), params: { labels: ['No Label'] }
expect_paginated_array_response(closed_issue.id)
end
end end
it 'returns an empty array if no issue matches milestone' do it 'returns an empty array if no issue matches milestone' do
......
...@@ -19,12 +19,6 @@ shared_examples 'no assignee filter' do ...@@ -19,12 +19,6 @@ shared_examples 'no assignee filter' do
expect(issuables).to contain_exactly(*expected_issuables) expect(issuables).to contain_exactly(*expected_issuables)
end end
it 'returns issuables not assigned to any assignee' do
params[:assignee_id] = 0
expect(issuables).to contain_exactly(*expected_issuables)
end
it 'returns issuables not assigned to any assignee' do it 'returns issuables not assigned to any assignee' do
params[:assignee_id] = 'none' params[:assignee_id] = 'none'
......
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