Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Photoed
- extend ActiveSupport::Concern
- included do
- respond_to :js
- before_action :set_order, only: %i[create destroy]
- before_action :set_photo, only: :destroy
- end
- def create
- @photo = @order.photos.create(photo_params)
- respond_with(@photo)
- end
- def destroy
- respond_with(@photo.destroy)
- end
- private
- def set_photo
- @photo = Photo.find(params[:id])
- end
- def photo_params
- params.require(:photo).permit(:file)
- end
- end
- class PhotosController < ApplicationController
- include Ordered
- include Photoed
- end
- scenario 'upload photos', js: true do
- as_guest(order) do
- visit new_order_path
- multiple_input = find('#multiple_file_input', visible: false)
- multiple_input.attach_file(FactoryHelpers.fixtures_pathes(2))
- expect(page).to have_content('Загружено 2')
- expect(page).to have_content('Удалить')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement