Commit c5c79378 authored by charlie ablett's avatar charlie ablett

Address reviewer feedback

- Remove unneeded FOSS placeholder
- Place model in boards namespace
parent a780fe59
...@@ -5,23 +5,23 @@ class AddEpicBoardPositions < ActiveRecord::Migration[6.0] ...@@ -5,23 +5,23 @@ class AddEpicBoardPositions < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
disable_ddl_transaction!
def up def up
with_lock_retries do with_lock_retries do
create_table :epic_board_positions do |t| create_table :boards_epic_board_positions do |t|
t.references :board, foreign_key: { on_delete: :cascade }, null: false, index: false t.references :board, foreign_key: { on_delete: :cascade }, null: false, index: false
t.references :epic, foreign_key: { on_delete: :cascade }, null: false, index: true t.references :epic, foreign_key: { on_delete: :cascade }, null: false, index: true
t.integer :relative_position t.integer :relative_position
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.index [:board_id, :epic_id], unique: true, name: :index_epic_board_positions_on_board_id_and_epic_id t.index [:board_id, :epic_id], unique: true, name: :index_boards_epic_board_positions_on_board_id_and_epic_id
end end
end end
end end
def down def down
drop_table :epic_board_positions with_lock_retries do
drop_table :boards_epic_board_positions
end
end end
end end
# frozen_string_literal: true
module Boards
class EpicBoardPosition < ApplicationRecord
include RelativePositioning
self.table_name = 'boards_epic_board_positions'
belongs_to :board
belongs_to :epic
validates :board, presence: true
validates :epic, presence: true, uniqueness: { scope: :board_id }
alias_attribute :parent, :board
scope :order_relative_position, -> do
reorder('relative_position ASC', 'id DESC')
end
def self.relative_positioning_query_base(position)
where(board_id: position.board_id)
end
def self.relative_positioning_parent_column
:board_id
end
end
end
# frozen_string_literal: true
module EE
module EpicBoardPosition
extend ActiveSupport::Concern
prepended do
include RelativePositioning
belongs_to :board
belongs_to :epic
validates :board, presence: true
validates :epic, presence: true, uniqueness: { scope: :board_id }
alias_attribute :parent, :board
scope :order_relative_position, -> do
reorder('relative_position ASC', 'id DESC')
end
end
class_methods do
extend ::Gitlab::Utils::Override
def relative_positioning_query_base(position)
where(board_id: position.board_id)
end
def relative_positioning_parent_column
:board_id
end
end
end
end
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :epic_board_position do factory :epic_board_position, class: 'Boards::EpicBoardPosition' do
epic epic
board board
relative_position { RelativePositioning::START_POSITION } relative_position { RelativePositioning::START_POSITION }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe EpicBoardPosition do RSpec.describe Boards::EpicBoardPosition do
let_it_be(:epic) { create(:epic) } let_it_be(:epic) { create(:epic) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:board) { create(:board, group: group) } let_it_be(:board) { create(:board, 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