Commit 03f74a31 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Create BoardAssignee model and set has_one relation

parent c197361d
class BoardAssignee < ActiveRecord::Base
belongs_to :board
belongs_to :assignee, class_name: 'User'
validates :board, presence: true
validates :assignee, presence: true
end
......@@ -5,9 +5,14 @@ module EE
prepended do
belongs_to :group
belongs_to :milestone
belongs_to :assignee, class_name: 'User'
has_many :board_labels
# These can safely be changed to has_many when we support
# multiple assignees on the board configuration.
has_one :board_assignee
has_one :assignee, through: :board_assignee
has_many :labels, through: :board_labels
validates :name, presence: true
......
require 'spec_helper'
describe BoardAssignee do
describe 'relationships' do
it { is_expected.to belong_to(:board) }
it { is_expected.to belong_to(:assignee).class_name('User') }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:board) }
it { is_expected.to validate_presence_of(:assignee) }
end
end
......@@ -4,7 +4,8 @@ describe Board do
describe 'relationships' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:milestone) }
it { is_expected.to belong_to(:assignee).class_name('User') }
it { is_expected.to have_one(:board_assignee) }
it { is_expected.to have_one(:assignee).through(:board_assignee) }
it { is_expected.to have_many(:board_labels) }
it { is_expected.to have_many(:labels).through(:board_labels) }
......
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