Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. module Photoed
  2. extend ActiveSupport::Concern
  3.  
  4. included do
  5. respond_to :js
  6.  
  7. before_action :set_order, only: %i[create destroy]
  8. before_action :set_photo, only: :destroy
  9. end
  10.  
  11. def create
  12. @photo = @order.photos.create(photo_params)
  13. respond_with(@photo)
  14. end
  15.  
  16. def destroy
  17. respond_with(@photo.destroy)
  18. end
  19.  
  20. private
  21.  
  22. def set_photo
  23. @photo = Photo.find(params[:id])
  24. end
  25.  
  26. def photo_params
  27. params.require(:photo).permit(:file)
  28. end
  29. end
  30.  
  31. class PhotosController < ApplicationController
  32.  
  33. include Ordered
  34. include Photoed
  35. end
  36.  
  37. scenario 'upload photos', js: true do
  38. as_guest(order) do
  39. visit new_order_path
  40.  
  41. multiple_input = find('#multiple_file_input', visible: false)
  42. multiple_input.attach_file(FactoryHelpers.fixtures_pathes(2))
  43.  
  44. expect(page).to have_content('Загружено 2')
  45. expect(page).to have_content('Удалить')
  46. end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement