@@ -137,6 +137,33 @@ class Staff::MarkScoresControllerTest < ActionDispatch::IntegrationTest
137137 assert_equal [ 4 ] , response_body . fetch ( "need_review_evaluations" ) . pluck ( "mark_score_group" ) . uniq
138138 end
139139
140+ test "save does not overwrite a review after manager scoring is complete" do
141+ euc = evaluation_user_capabilities ( :euc_supervisor_high )
142+ euc . update! (
143+ form_status : "manager_scored" ,
144+ work_quality : 3 ,
145+ work_load : 3 ,
146+ work_attitude : 3
147+ )
148+
149+ put staff_mark_score_path ( @manager , format : :json ) , params : {
150+ company_evaluation_ids : [ company_evaluations ( :ce_one ) . id ] ,
151+ group_level : "supervisor" ,
152+ mark_score_group : "4" ,
153+ mark_score : [ {
154+ id_user : euc . user_id ,
155+ id_cet : euc . company_evaluation_template_id ,
156+ id_euc : euc . id ,
157+ work_quality : 0 ,
158+ work_load : 0 ,
159+ work_attitude : 0
160+ } ]
161+ } , as : :json
162+
163+ assert_response :success
164+ assert_equal [ 3 , 3 , 3 ] , euc . reload . values_at ( :work_quality , :work_load , :work_attitude ) . map ( &:to_i )
165+ end
166+
140167 test "score confirm returns mark scores path when reviews remain" do
141168 euc = evaluation_user_capabilities ( :euc_supervisor_high )
142169 company_evaluation_ids = [ company_evaluations ( :ce_one ) . id ]
@@ -168,4 +195,31 @@ class Staff::MarkScoresControllerTest < ActionDispatch::IntegrationTest
168195 assert_response :success
169196 assert_equal staff_root_path , JSON . parse ( response . body ) . fetch ( "go_path" )
170197 end
198+
199+ test "score confirm is idempotent after manager scoring is complete" do
200+ euc = evaluation_user_capabilities ( :euc_supervisor_high )
201+ company_evaluation_ids = [ company_evaluations ( :ce_one ) . id ]
202+
203+ put score_confirm_staff_mark_score_path ( @manager , format : :json ) , params : {
204+ euc_ids : [ euc . id ] ,
205+ company_evaluation_ids : company_evaluation_ids
206+ } , as : :json
207+
208+ assert_response :success
209+ assert_equal 1 , euc . euc_form_status_histories . where (
210+ previous_form_status : "self_assessment_done" ,
211+ form_status : "manager_scored"
212+ ) . count
213+
214+ put score_confirm_staff_mark_score_path ( @manager , format : :json ) , params : {
215+ euc_ids : [ euc . id ] ,
216+ company_evaluation_ids : company_evaluation_ids
217+ } , as : :json
218+
219+ assert_response :success
220+ assert_equal 1 , euc . euc_form_status_histories . where (
221+ previous_form_status : "self_assessment_done" ,
222+ form_status : "manager_scored"
223+ ) . count
224+ end
171225end
0 commit comments