diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-20 20:55:42 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-20 20:55:42 -0700 |
| commit | fe019088a9f63945c4556b2dae3a2f8a3b774a38 (patch) | |
| tree | fb45d4fb5057ba77adc8a40bdcf59a449272b42a | |
| parent | 75d7617a7d44e49fd173dfbe4d98faec1538c9e7 (diff) | |
use temporary storage class.
| -rw-r--r-- | app/controllers/my/avatars_controller.rb | 16 | ||||
| -rw-r--r-- | spec/features/add_to_favorites_spec.rb | 1 |
2 files changed, 1 insertions, 16 deletions
diff --git a/app/controllers/my/avatars_controller.rb b/app/controllers/my/avatars_controller.rb index b60eda71..eea96a61 100644 --- a/app/controllers/my/avatars_controller.rb +++ b/app/controllers/my/avatars_controller.rb @@ -6,22 +6,8 @@ module My def create image = params[:photo][:image] - ProcessAvatarJob.perform_later(current_user, move_to_temporary_storage(image)) + ProcessAvatarJob.perform_later(current_user, TemporaryStorage.new.store(image)) redirect_to new_my_avatar_path, notice: t(:avatar_uploaded) end - - private - - def move_to_temporary_storage(image) - "#{create_tmp_dir}/#{image.original_filename}".tap do |new_path| - FileUtils.mv(image.path, new_path) - end - end - - def create_tmp_dir - Rails.root.join("tmp/uploads/#{SecureRandom.uuid}").tap do |directory| - system "mkdir -p #{directory}" - end - end end end diff --git a/spec/features/add_to_favorites_spec.rb b/spec/features/add_to_favorites_spec.rb index 1c777286..42f7bb31 100644 --- a/spec/features/add_to_favorites_spec.rb +++ b/spec/features/add_to_favorites_spec.rb @@ -13,7 +13,6 @@ describe "adding a cake to your favorites" do click_button("Sign In") visit root_path click_link(creation.name[0...12]) - puts page.html click_link_or_button("add-to-favorites-button") end |
