2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe List do
|
2019-02-15 15:39:39 +05:30
|
|
|
it_behaves_like 'having unique enum values'
|
2021-03-08 18:12:59 +05:30
|
|
|
it_behaves_like 'boards listable model', :list
|
2021-04-17 20:07:23 +05:30
|
|
|
it_behaves_like 'list_preferences_for user', :list, :list_id
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
describe 'relationships' do
|
|
|
|
it { is_expected.to belong_to(:board) }
|
|
|
|
it { is_expected.to belong_to(:label) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:board) }
|
|
|
|
it { is_expected.to validate_presence_of(:label) }
|
|
|
|
it { is_expected.to validate_presence_of(:list_type) }
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe '.without_types' do
|
|
|
|
it 'exclude lists of given types' do
|
|
|
|
board = create(:list, list_type: :label).board
|
|
|
|
# closed list is created by default
|
|
|
|
backlog_list = create(:list, list_type: :backlog, board: board)
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
exclude_type = [described_class.list_types[:label], described_class.list_types[:closed]]
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
lists = described_class.without_types(exclude_type)
|
|
|
|
expect(lists.where(board: board)).to match_array([backlog_list])
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|