Guest User

Untitled

a guest
Mar 16th, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #udelam si uzivatele
  2. def create_user(options = {})
  3. post :signup, :user => { :login => 'quire', :email => 'quire@example.com',
  4. :password => 'quire', :password_confirmation => 'quire' }.merge(options), :attachment => {:uploaded_data => ''}
  5. end
  6. #anebo uzivatele s fotkou
  7. def create_user_with_photo(options = {})
  8. post :signup, :user => { :login => 'quire', :email => 'quire@example.com',
  9. :password => 'quire', :password_confirmation => 'quire' }.merge(options), :attachment => {:uploaded_data =>File.new("#{RAILS_ROOT}/test/fixtures/test_image.jpg")}
  10. end
  11.  
  12. # a tady testuju, jestli ma tenhle uzivatel fakt pridanej nejakej soubor
  13. def test_should_save_photo_on_signup
  14. assert_no_difference User, :count do
  15. create_user_with_photo
  16. assert_response :success
  17. assert_not_nil assigns(:user).attachment
  18. end
  19. end
  20.  
  21. #controller
  22. @user.attachment = Attachment.new(params[:attachment]) if params[:attachment][:uploaded_data].is_a?(File)
  23. @user.save!
Add Comment
Please, Sign In to add comment