22
33class HackathonTest < ActiveSupport ::TestCase
44 setup do
5- # This contains the bare basics of an instantiable Hackathon object
5+ Current . user = users ( :gary )
6+
67 @hackathon = Hackathon . new (
78 name : "TestHacks" ,
89 starts_at : Time . now ,
910 ends_at : 2 . days . from_now ,
1011 website : "https://hackclub.com" ,
11- high_school_led : true ,
1212 expected_attendees : 100 ,
13- modality : "in_person" ,
14- financial_assistance : true ,
15- logo : active_storage_blobs ( :assemble_logo ) ,
16- banner : active_storage_blobs ( :assemble ) ,
17- applicant : users ( :gary )
13+ modality : :in_person
1814 )
1915 end
2016
2117 test "creating a hackathon" do
2218 assert @hackathon . save
19+ assert_equal users ( :gary ) , @hackathon . applicant
2320 end
2421
2522 test "creating a hackathon with invalid dates" do
@@ -28,29 +25,37 @@ class HackathonTest < ActiveSupport::TestCase
2825 starts_at : Time . now ,
2926 ends_at : 2 . days . ago ,
3027 website : "https://hackclub.com" ,
31- high_school_led : true ,
3228 expected_attendees : 100 ,
33- modality : "in_person" ,
34- financial_assistance : true ,
35- logo : active_storage_blobs ( :assemble_logo ) ,
36- banner : active_storage_blobs ( :assemble ) ,
37- applicant : users ( :gary )
29+ modality : :in_person
3830 )
3931
4032 assert_not hackathon . save
33+
34+ hackathon . ends_at = 2 . days . from_now
35+
36+ assert hackathon . save
4137 end
4238
4339 test "creating a hackathon without an applicant" do
40+ Current . user = nil
41+
4442 hackathon = Hackathon . new (
4543 name : "TestHacks" ,
44+ website : "https://hackclub.com" ,
4645 starts_at : Time . now ,
4746 ends_at : 2 . days . from_now
4847 )
4948
5049 assert_not hackathon . save
50+
51+ Current . user = users ( :gary )
52+
53+ assert hackathon . save
5154 end
5255
53- test "create a hackathon with swag mailing address" do
56+ test "creating a hackathon wanting swag mailed" do
57+ assert_not @hackathon . requested_swag?
58+
5459 @hackathon . swag_mailing_address_attributes = {
5560 line1 : "123 Test St" ,
5661 city : "Test City" ,
@@ -61,8 +66,4 @@ class HackathonTest < ActiveSupport::TestCase
6166 assert @hackathon . save
6267 assert @hackathon . requested_swag?
6368 end
64-
65- test "#requested_swag? without swag mailing address" do
66- assert_not @hackathon . requested_swag?
67- end
6869end
0 commit comments