@@ -5,69 +5,68 @@ def setup
55 @job_application = build ( :job_application )
66 end
77
8- test "valid job application" do
9- assert @job_application . valid? , "Job application is not valid. Errors: #{ @job_application . errors . full_messages } "
8+ test "job application is valid with valid attributes " do
9+ assert @job_application . valid?
1010 end
1111
12- test "invalid without date_applied" do
12+ test "job application is invalid without date_applied" do
1313 @job_application . date_applied = nil
1414 assert_not @job_application . valid?
1515 assert_not_nil @job_application . errors [ :date_applied ]
1616 end
1717
18- test "invalid without company_name" do
18+ test "job application is invalid without company_name" do
1919 @job_application . company_name = nil
2020 assert_not @job_application . valid?
2121 assert_not_nil @job_application . errors [ :company_name ]
2222 end
2323
24- test "invalid without method_of_contact" do
24+ test "job application is invalid without method_of_contact" do
2525 @job_application . method_of_contact = nil
2626 assert_not @job_application . valid?
2727 assert_not_nil @job_application . errors [ :method_of_contact ]
2828 end
2929
30- test "invalid without position_type" do
30+ test "job application is invalid without position_type" do
3131 @job_application . position_type = nil
3232 assert_not @job_application . valid?
3333 assert_not_nil @job_application . errors [ :position_type ]
3434 end
3535
36- test "invalid without position_title" do
36+ test "job application is invalid without position_title" do
3737 @job_application . position_title = nil
3838 assert_not @job_application . valid?
3939 assert_not_nil @job_application . errors [ :position_title ]
4040 end
4141
42- test "requires email_address when method_of_contact is email" do
42+ test "job application requires email_address when method_of_contact is email" do
43+ @job_application . method_of_contact = "email"
4344 @job_application . email_address = nil
4445 assert_not @job_application . valid?
4546 assert_not_nil @job_application . errors [ :email_address ]
4647 end
4748
48- test "requires website_link when method_of_contact is internet job application" do
49- @job_application = build ( :job_application ,
50- method_of_contact : "internet_job_application" ,
51- website_link : nil )
52-
49+ test "job application requires website_link when method_of_contact is internet job application" do
50+ @job_application . method_of_contact = "internet_job_application"
51+ @job_application . website_link = nil
5352 assert_not @job_application . valid?
54- assert_includes @job_application . errors . full_messages , "Website link can't be blank"
53+ assert_includes @job_application . errors [ :website_link ] , "can't be blank"
5554 end
5655
57- test "validates website_link format" do
58- @job_application = build ( :job_application , :with_website )
56+ test "job application validates website_link format" do
57+ @job_application . method_of_contact = "internet_job_application"
5958 @job_application . website_link = "invalid-url"
6059 assert_not @job_application . valid?
6160 assert_not_nil @job_application . errors [ :website_link ]
6261 end
6362
64- test "validates status inclusion" do
63+ test "job application validates status inclusion" do
6564 assert_raises ( ArgumentError ) do
6665 build ( :job_application , status : "invalid_status" )
6766 end
6867 end
6968
70- test "search scope" do
69+ test "search scope finds job applications by company_name or position_title " do
7170 create ( :job_application , company_name : "Unique Company" )
7271 create ( :job_application , position_title : "Unique Position" )
7372
@@ -76,64 +75,46 @@ def setup
7675 assert_equal 2 , JobApplication . search ( "Unique" ) . count
7776 end
7877
79- test "by_method_of_contact scope" do
78+ test "by_method_of_contact scope finds job applications by method_of_contact " do
8079 JobApplication . destroy_all
8180 create ( :job_application , method_of_contact : "email" )
82- create ( :job_application , :with_website )
83-
84- puts "Total job applications: #{ JobApplication . count } "
85- puts "Email job applications: #{ JobApplication . by_method_of_contact ( "email" ) . count } "
86- puts "Internet job applications: #{ JobApplication . by_method_of_contact ( "internet_job_application" ) . count } "
81+ create ( :job_application , method_of_contact : "internet_job_application" , website_link : "http://example.com" )
8782
8883 assert_equal 1 , JobApplication . by_method_of_contact ( "email" ) . count
8984 assert_equal 1 , JobApplication . by_method_of_contact ( "internet_job_application" ) . count
9085 end
9186
92- test "by_position_type scope" do
87+ test "by_position_type scope finds job applications by position_type " do
9388 JobApplication . destroy_all
9489 create ( :job_application , position_type : "full_time" )
9590 create ( :job_application , position_type : "part_time" )
9691
97- puts "Total job applications: #{ JobApplication . count } "
98- puts "Full-time job applications: #{ JobApplication . by_position_type ( "full_time" ) . count } "
99- puts "Part-time job applications: #{ JobApplication . by_position_type ( "part_time" ) . count } "
100-
10192 assert_equal 1 , JobApplication . by_position_type ( "full_time" ) . count
10293 assert_equal 1 , JobApplication . by_position_type ( "part_time" ) . count
10394 end
10495
105- test "by_status scope" do
96+ test "by_status scope finds job applications by status " do
10697 JobApplication . destroy_all
10798 create ( :job_application , status : "interviewing" )
10899 create ( :job_application , status : "hired" )
109100
110- puts "Total job applications: #{ JobApplication . count } "
111- puts "Interviewing job applications: #{ JobApplication . by_status ( "interviewing" ) . count } "
112- puts "Hired job applications: #{ JobApplication . by_status ( "hired" ) . count } "
113-
114101 assert_equal 1 , JobApplication . by_status ( "interviewing" ) . count
115102 assert_equal 1 , JobApplication . by_status ( "hired" ) . count
116103 end
117104
118- test "claimed_for_unemployment scope" do
105+ test "claimed_for_unemployment scope finds job applications claimed for unemployment " do
119106 JobApplication . destroy_all
120107 create ( :job_application , claimed_for_unemployment : true )
121108 create ( :job_application , claimed_for_unemployment : false )
122109
123- puts "Total job applications: #{ JobApplication . count } "
124- puts "Claimed for unemployment: #{ JobApplication . claimed_for_unemployment . count } "
125-
126110 assert_equal 1 , JobApplication . claimed_for_unemployment . count
127111 end
128112
129- test "not_claimed_for_unemployment scope" do
113+ test "not_claimed_for_unemployment scope finds job applications not claimed for unemployment " do
130114 JobApplication . destroy_all
131115 create ( :job_application , claimed_for_unemployment : true )
132116 create ( :job_application , claimed_for_unemployment : false )
133117
134- puts "Total job applications: #{ JobApplication . count } "
135- puts "Not claimed for unemployment: #{ JobApplication . not_claimed_for_unemployment . count } "
136-
137118 assert_equal 1 , JobApplication . not_claimed_for_unemployment . count
138119 end
139120end
0 commit comments