Commit 8e44b089 authored by Eulyeon Ko's avatar Eulyeon Ko

Apply DB maintainer suggestions

- Remove redundant where condition
- Add spec coverage for updating title to a blank value
parent 88447821
......@@ -42,7 +42,7 @@ module EE
scope :in_iteration_scope, ->(iteration_scope) { joins(:iteration).merge(iteration_scope) }
scope :in_iteration_cadences, ->(iteration_cadences) { joins(:iteration).where(sprints: { iterations_cadence_id: iteration_cadences }) }
scope :with_iteration_title, ->(iteration_title) { joins(:iteration).where(sprints: { title: iteration_title }) }
scope :without_iteration_title, ->(iteration_title) { left_outer_joins(:iteration).where('sprints.title IS DISTINCT FROM ? OR sprints.id IS NULL', iteration_title) }
scope :without_iteration_title, ->(iteration_title) { left_outer_joins(:iteration).where('sprints.title IS DISTINCT FROM ?', iteration_title) }
scope :on_status_page, -> do
joins(project: :status_page_setting)
.where(status_page_settings: { enabled: true })
......
......@@ -72,6 +72,16 @@ RSpec.describe Iteration do
it { is_expected.to eq('Sep 30, 2022 - Oct 4, 2022') }
end
describe '#title' do
let_it_be(:iteration) { create(:iteration, title: "foobar", group: create(:group)) }
it 'updates title to a blank value', :aggregate_failures do
iteration.update!(title: "")
expect(iteration.title).to be_nil
end
end
describe '.reference_pattern' do
let_it_be(:group) { create(:group) }
let_it_be(:iteration_cadence) { create(:iterations_cadence, group: group) }
......
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