-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_test.rb
93 lines (76 loc) · 2.04 KB
/
event_test.rb
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require 'test_helper'
class EventTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@user = users(:one)
@normUser = users(:three)
end
test 'should save valid event' do
event = Event.new
event.user_id = @user.id
event.name = 'newEvent'
event.description = 'description'
event.location = '130 Weston Road, GU2 8AW'
event.eventType = 1
event.eventDate = "2021-12-25 18:00:00"
event.save
assert event.valid?
end
test 'should not save empty event' do
event = Event.new
event.save
refute event.valid?
end
test 'should not save event without seller' do
event = Event.new
event.name = 'newEvent'
event.description = 'description'
event.location = '130 Weston Road, GU2 8AW'
event.save
refute event.valid?
end
test 'should not save event without name' do
event = Event.new
event.user_id = @user.id
event.description = 'description'
event.location = '130 Weston Road, GU2 8AW'
event.eventType = 1
event.eventDate = "2021-12-25 18:00:00"
event.save
refute event.valid?
end
test 'should not save event without location' do
event = Event.new
event.user_id = @user.id
event.name = 'newEvent'
event.description = 'description'
event.eventType = 1
event.eventDate = "2021-12-25 18:00:00"
event.save
refute event.valid?
end
test 'should not save date in future' do
event = Event.new
event.user_id = @user.id
event.name = 'newEvent'
event.description = 'description'
event.eventType = 1
event.eventDate = "2018-12-25 18:00:00"
event.location = '130 Weston Road, GU2 8AW'
event.save
refute event.valid?
end
test 'should not save new event if not business' do
event = Event.new
event.user_id = @normUser.id
event.name = 'newEvent'
event.description = 'description'
event.location = '130 Weston Road, GU2 8AW'
event.eventType = 1
event.eventDate = "2021-12-25 18:00:00"
event.save
refute event.valid?
end
end