My question today is:
How do I write function test to simulate the user changing a value in an
edit form? Say, I have a form with a lookup to tech_id. When the user
selects a different tech_id, I want to verify that other fields have
also
changed ie( tech_name, tech_pay_rate, etc). This is what I have so far:
def test_changing_technician_id
get :edit, :id => 1
assert_response :success
assert_template ‘edit’
assert_not_nil assigns(:work_order_labor)
assert assigns(:work_order_labor).valid? # but how do I access the
:work_order_labor object?
verify that we have the correct name the technician id
this line doesn’t work
assert_equal 'Alfred', work_order_labor.technician_name
# change technician id to 2
post :update,
work_order_labor = WorkOrderLabor.find_by_id(1)
# verify that the technician_name is now ' Betty'
assert_equal 'Betty', work_order_labor.technician_name
end
Any help would be greatly appreciated.
Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson