Commit fe019088

mo khan <mo@mokhan.ca>
2015-01-21 03:55:42
use temporary storage class.
1 parent 75d7617
Changed files (2)
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
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