Guest User

Untitled

a guest
Apr 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. require File.dirname(__FILE__) + '/../test_helper'
  2.  
  3. class AddressControllerTest < ActionController::TestCase
  4. # Replace this with your real tests.
  5. def test_truth
  6. assert true
  7. end
  8.  
  9. [:view, :edit].each do |action|
  10. define_method "test_#{action}_get" do
  11. make_fake_addresses
  12.  
  13. addr = create_address
  14.  
  15. with_privileged_user "address", action.to_s do |user|
  16. assert_db_unchanged do
  17. get action, {:id => addr}, {:user_id => user}
  18. assert_response :success
  19. assert_models_match addr, assigns(:address)
  20. end
  21. end
  22. end
  23. end
  24.  
  25. protected
  26.  
  27. def make_fake_addresses
  28. addr = []
  29. (rand(10)+1).times { addr << create_address }
  30. addr
  31. end
  32. end
Add Comment
Please, Sign In to add comment