Commit 44ffb735

mo khan <mo@mokhan.ca>
2015-01-17 19:52:51
inline publish method.
1 parent 3f34a83
Changed files (2)
app
spec
app/controllers/my/avatars_controller.rb
@@ -10,16 +10,13 @@ module My
     end
 
     def create
-      publish(params[:photo][:image])
+      image = params[:photo][:image]
+      ProcessAvatarJob.perform_later(current_user, move_to_temporary_storage(image))
       redirect_to new_my_avatar_path, notice: t(:avatar_uploaded)
     end
 
     private
 
-    def publish(image)
-      ProcessAvatarJob.perform_later(current_user, move_to_temporary_storage(image))
-    end
-
     def move_to_temporary_storage(image)
       "#{create_tmp_dir}/#{image.original_filename}".tap do |new_path|
         FileUtils.mv(image.path, new_path)
spec/controllers/my/avatars_controller_spec.rb
@@ -12,17 +12,17 @@ describe My::AvatarsController do
 
         before { post :create, photo: { image: image } }
 
-        it "should save the new avatar" do
+        it "saves the new avatar" do
           user.reload
           expect(user.avatar).to_not be_nil
           expect(user.avatar.image).to_not be_blank
         end
 
-        it "should redirect to the avatar page" do
+        it "redirects to the avatar page" do
           expect(response).to redirect_to(new_my_avatar_path)
         end
 
-        it "should display a flash notice" do
+        it "displays a flash notice" do
           expect(flash[:notice]).to_not be_nil
         end
       end
@@ -31,7 +31,7 @@ describe My::AvatarsController do
     describe "#new" do
       before { get :new, id: user.id }
 
-      it "should display the current avatar" do
+      it "displays the current avatar" do
         expect(assigns(:avatar)).to_not be_nil
       end
     end