@@ -413,7 +413,7 @@ def mock_failing_update(error_messages = ["Update error"])
413413
414414 inspection . reload
415415 expect ( inspection . unit ) . to eq ( unit1 )
416-
416+
417417 # Verify event logging
418418 event = Event . for_resource ( inspection ) . last
419419 expect ( event . action ) . to eq ( "unit_changed" )
@@ -424,7 +424,6 @@ def mock_failing_update(error_messages = ["Update error"])
424424 patch "/inspections/#{ inspection . id } /update_unit" , params : { unit_id : "invalid" }
425425 expect_redirect_with_alert ( select_unit_inspection_path ( inspection ) , /invalid.*unit/i )
426426 end
427-
428427 end
429428 end
430429
@@ -495,7 +494,7 @@ def mock_failing_update(error_messages = ["Update error"])
495494
496495 describe "HEAD requests" do
497496 let ( :inspection ) { create ( :inspection , user : user , unit : unit ) }
498-
497+
499498 it "returns 200 OK for HEAD request" do
500499 head "/inspections/#{ inspection . id } "
501500 expect ( response ) . to have_http_status ( :ok )
@@ -505,7 +504,7 @@ def mock_failing_update(error_messages = ["Update error"])
505504
506505 describe "GET /log" do
507506 let ( :inspection ) { create ( :inspection , user : user , unit : unit ) }
508-
507+
509508 before do
510509 # Create some events for the inspection
511510 Event . log (
@@ -532,7 +531,6 @@ def mock_failing_update(error_messages = ["Update error"])
532531 end
533532 end
534533
535-
536534 describe "prefill functionality" do
537535 let ( :previous_inspection ) do
538536 create ( :inspection , :completed ,
@@ -552,8 +550,8 @@ def mock_failing_update(error_messages = ["Update error"])
552550
553551 describe "translate_field_name" do
554552 it "translates field names for prefill display" do
555- get "/inspections/#{ new_inspection . id } /edit" , params : { tab : "inspection" }
556-
553+ get "/inspections/#{ new_inspection . id } /edit" , params : { tab : "inspection" }
554+
557555 expect ( response ) . to have_http_status ( :success )
558556 # The prefilled_fields will be set if there are fields to prefill
559557 expect ( assigns ( :prefilled_fields ) ) . to be_an ( Array )
@@ -565,9 +563,9 @@ def mock_failing_update(error_messages = ["Update error"])
565563 containing_wall_height : 100 ,
566564 containing_wall_height_comment : "Test comment"
567565 )
568-
569- get "/inspections/#{ new_inspection . id } /edit" , params : { tab : "user_height" }
570-
566+
567+ get "/inspections/#{ new_inspection . id } /edit" , params : { tab : "user_height" }
568+
571569 expect ( response ) . to have_http_status ( :success )
572570 expect ( assigns ( :previous_inspection ) ) . to eq ( previous_inspection )
573571 # Prefilled fields would include the ground_clearance fields
@@ -593,7 +591,7 @@ def mock_failing_update(error_messages = ["Update error"])
593591
594592 describe "validate_tab_parameter" do
595593 let ( :inspection ) { create ( :inspection , user : user , unit : unit ) }
596-
594+
597595 it "redirects with invalid tab parameter" do
598596 get "/inspections/#{ inspection . id } /edit" , params : { tab : "invalid_tab" }
599597
@@ -642,12 +640,12 @@ def mock_failing_update(error_messages = ["Update error"])
642640
643641 describe "calculate_changes" do
644642 let ( :inspection ) { create ( :inspection , user : user , unit : unit ) }
645-
643+
646644 it "tracks changes correctly in update" do
647645 # Store original values
648646 original_passed = inspection . passed
649- original_risk = inspection . risk_assessment
650-
647+ inspection . risk_assessment
648+
651649 patch "/inspections/#{ inspection . id } " , params : {
652650 inspection : {
653651 passed : !original_passed ,
@@ -656,7 +654,7 @@ def mock_failing_update(error_messages = ["Update error"])
656654 }
657655
658656 expect ( response ) . to redirect_to ( inspection_path ( inspection ) )
659-
657+
660658 # Check the event was logged with changed data
661659 event = Event . for_resource ( inspection ) . last
662660 expect ( event . action ) . to eq ( "updated" )
@@ -666,8 +664,8 @@ def mock_failing_update(error_messages = ["Update error"])
666664 end
667665
668666 it "ignores unchanged values" do
669- original_value = inspection . risk_assessment
670-
667+ inspection . risk_assessment
668+
671669 patch "/inspections/#{ inspection . id } " , params : {
672670 inspection : {
673671 risk_assessment : "New risk" ,
@@ -676,7 +674,7 @@ def mock_failing_update(error_messages = ["Update error"])
676674 }
677675
678676 expect ( response ) . to redirect_to ( inspection_path ( inspection ) )
679-
677+
680678 # Check that only changed fields are in changed_data
681679 event = Event . for_resource ( inspection ) . last
682680 expect ( event . action ) . to eq ( "updated" )
@@ -712,14 +710,14 @@ def mock_failing_update(error_messages = ["Update error"])
712710 end
713711
714712 context "in production environment" do
715- before do
713+ before do
716714 allow ( Rails . env ) . to receive ( :local? ) . and_return ( false )
717715 allow ( Rails . logger ) . to receive ( :error )
718716 end
719717
720718 it "logs error but continues" do
721719 get "/inspections/#{ invalid_complete_inspection . id } "
722-
720+
723721 expect ( Rails . logger ) . to have_received ( :error ) . with ( /DATA INTEGRITY ERROR/ )
724722 expect ( response ) . to have_http_status ( :success )
725723 end
@@ -744,7 +742,7 @@ def mock_failing_update(error_messages = ["Update error"])
744742 get "/inspections/#{ inspection . id } .json"
745743 expect ( response ) . to have_http_status ( :success )
746744 expect ( response . content_type ) . to include ( "application/json" )
747-
745+
748746 json = JSON . parse ( response . body )
749747 expect ( json ) . to be_present
750748 expect ( json ) . to have_key ( "complete" )
0 commit comments