Drying up the testing code

Hi, this is the file thermo_detector_controller_test.rb:
def test_edit
get :edit, :id => @don_dafii_order.id
assert_response :success
end
def test_send_invalid_stk
file_uploaded =
uploaded_file("#{File.expand_path(RAILS_ROOT)}/test/fixtures/img/david_beckham.jpg",
‘image/jpeg’)
post :create_stk, { :id => @don_dafii_order.id, :thermo_detector =>
{ :stk => file_uploaded }}
assert_redirected_to :action => ‘new_stk’
assert_equal ‘Dokumen yang dikirim harus berformat pdf.’,
flash[:notice]
end

and this is the file cartridge_heater_controller_test.rb:
def test_edit
get :edit, :id => @don_dafii_order.id
assert_response :success
end
def test_send_invalid_stk
file_uploaded =
uploaded_file("#{File.expand_path(RAILS_ROOT)}/test/fixtures/img/david_beckham.jpg",
‘image/jpeg’)
post :create_stk, { :id => @don_dafii_order.id, :cartridge_heater =>
{ :stk => file_uploaded }}
assert_redirected_to :action => ‘new_stk’
assert_equal ‘Dokumen yang dikirim harus berformat pdf.’,
flash[:notice]
end

How do you drying up these methods? There are duplications in model
testing code too.

Here is the file cartridge_heater_order_letter_test.rb
def test_update
assert_equal @don_dafii_order.sales_name, @cartridge.sales_name
@cartridge.sales_name = ‘James B.’
assert @cartridge.save, @cartridge.errors.full_messages.join("; ")
@cartridge.reload
assert_equal ‘James B.’, @cartridge.sales_name
end

Here is the file thermo_detector_order_letter_test.rb
def test_update
assert_equal @don_dafii_order.sales_name,
@thermo_detector.sales_name
@thermo_detector.sales_name = ‘James B.’
assert @thermo_detector.save,
@thermo_detector.errors.full_messages.join("; ")
@thermo_detector.reload
assert_equal ‘James B.’, @thermo_detector.sales_name
end

Thank you.