diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 18:08:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 18:08:37 +0300 |
commit | 37eff29d5ce44899e34c7c2ac319b314f2f26d15 (patch) | |
tree | b74e1632fdb58ea10972f270bfec70a4e6ee07b0 /spec/models/board_spec.rb | |
parent | 9411a664118a3247d0a56baf7e7ef4549c1201c3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/board_spec.rb')
-rw-r--r-- | spec/models/board_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/board_spec.rb b/spec/models/board_spec.rb index f6eee67e539..0987c8e2b65 100644 --- a/spec/models/board_spec.rb +++ b/spec/models/board_spec.rb @@ -3,6 +3,9 @@ require 'spec_helper' describe Board do + let(:project) { create(:project) } + let(:other_project) { create(:project) } + describe 'relationships' do it { is_expected.to belong_to(:project) } it { is_expected.to have_many(:lists).order(list_type: :asc, position: :asc).dependent(:delete_all) } @@ -11,4 +14,28 @@ describe Board do describe 'validations' do it { is_expected.to validate_presence_of(:project) } end + + describe '#order_by_name_asc' do + let!(:second_board) { create(:board, name: 'Secondary board', project: project) } + let!(:first_board) { create(:board, name: 'First board', project: project) } + + it 'returns in alphabetical order' do + expect(project.boards.order_by_name_asc).to eq [first_board, second_board] + end + end + + describe '#first_board' do + let!(:other_board) { create(:board, name: 'Other board', project: other_project) } + let!(:second_board) { create(:board, name: 'Secondary board', project: project) } + let!(:first_board) { create(:board, name: 'First board', project: project) } + + it 'return the first alphabetical board as a relation' do + expect(project.boards.first_board).to eq [first_board] + end + + # BoardsActions#board expects this behavior + it 'raises an error when find is done on a non-existent record' do + expect { project.boards.first_board.find(second_board.id) }.to raise_error(ActiveRecord::RecordNotFound) + end + end end |