diff options
Diffstat (limited to 'spec/models/import_failure_spec.rb')
-rw-r--r-- | spec/models/import_failure_spec.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/models/import_failure_spec.rb b/spec/models/import_failure_spec.rb index 101da1212cf..a8ada156dd7 100644 --- a/spec/models/import_failure_spec.rb +++ b/spec/models/import_failure_spec.rb @@ -36,23 +36,39 @@ RSpec.describe ImportFailure do describe 'Associations' do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:group) } + it { is_expected.to belong_to(:user) } end describe 'Validations' do - context 'has no group' do + let_it_be(:group) { build(:group) } + let_it_be(:project) { build(:project) } + let_it_be(:user) { build(:user) } + + context 'has project' do + before do + allow(subject).to receive(:project).and_return(project) + end + + it { is_expected.to validate_absence_of(:group) } + it { is_expected.to validate_absence_of(:user) } + end + + context 'has group' do before do - allow(subject).to receive(:group).and_return(nil) + allow(subject).to receive(:group).and_return(group) end - it { is_expected.to validate_presence_of(:project) } + it { is_expected.to validate_absence_of(:project) } + it { is_expected.to validate_absence_of(:user) } end - context 'has no project' do + context 'has user' do before do - allow(subject).to receive(:project).and_return(nil) + allow(subject).to receive(:user).and_return(user) end - it { is_expected.to validate_presence_of(:group) } + it { is_expected.to validate_absence_of(:project) } + it { is_expected.to validate_absence_of(:group) } end describe '#external_identifiers' do |