1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GroupImportState do
describe 'validations' do
let_it_be(:group) { create(:group) }
it { is_expected.to belong_to(:user).required }
it { is_expected.to validate_presence_of(:group) }
it { is_expected.to validate_presence_of(:status) }
it 'can be created without a jid' do
import_state = build(:group_import_state, :created, group: group, jid: nil)
expect(import_state).to be_valid
end
it 'cannot be started without a jid' do
import_state = build(:group_import_state, :started, group: group, jid: nil)
expect(import_state).not_to be_valid
expect(import_state.errors[:jid]).to include "can't be blank"
end
it 'cannot be finished without a jid' do
import_state = build(:group_import_state, :finished, group: group, jid: nil)
expect(import_state).not_to be_valid
expect(import_state.errors[:jid]).to include "can't be blank"
end
it 'can fail without a jid' do
import_state = build(:group_import_state, :failed, group: group, jid: nil)
expect(import_state).to be_valid
end
end
describe '#in_progress?' do
context "when the import is 'created'" do
it "returns true" do
group_import_state = build(:group_import_state, :created)
expect(group_import_state.in_progress?).to eq true
end
end
context "when the import is 'started'" do
it "returns true" do
group_import_state = build(:group_import_state, :started)
expect(group_import_state.in_progress?).to eq true
end
end
context "when the import is 'finished'" do
it "returns false" do
group_import_state = build(:group_import_state, :finished)
expect(group_import_state.in_progress?).to eq false
end
end
context "when the import is 'failed'" do
it "returns false" do
group_import_state = build(:group_import_state, :failed)
expect(group_import_state.in_progress?).to eq false
end
end
end
end
|