2016-07-27 19:32:32 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe List do
|
|
|
|
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) }
|
|
|
|
it { is_expected.to validate_presence_of(:position) }
|
|
|
|
it { is_expected.to validate_numericality_of(:position).only_integer.is_greater_than_or_equal_to(0) }
|
|
|
|
|
2016-07-28 22:26:16 +00:00
|
|
|
context 'when list_type is set to backlog' do
|
|
|
|
subject { described_class.new(list_type: :backlog) }
|
2016-07-27 19:32:32 +00:00
|
|
|
|
2016-07-28 22:26:16 +00:00
|
|
|
it { is_expected.not_to validate_presence_of(:label) }
|
|
|
|
it { is_expected.not_to validate_presence_of(:position) }
|
2016-07-27 19:32:32 +00:00
|
|
|
end
|
|
|
|
|
2016-07-28 22:26:16 +00:00
|
|
|
context 'when list_type is set to done' do
|
|
|
|
subject { described_class.new(list_type: :done) }
|
2016-07-27 19:32:32 +00:00
|
|
|
|
2016-07-28 22:26:16 +00:00
|
|
|
it { is_expected.not_to validate_presence_of(:label) }
|
|
|
|
it { is_expected.not_to validate_presence_of(:position) }
|
2016-07-27 19:32:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|