diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-17 12:52:51 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-17 12:52:51 -0700 |
| commit | 44ffb735056d225c784da087af8cf3eb72ebfeb9 (patch) | |
| tree | c34479d674166b5b3ed2789c61ac77b3c426e41e | |
| parent | 3f34a83426adf7ee4dfd1b0b75514651818daef5 (diff) | |
inline publish method.
| -rw-r--r-- | app/controllers/my/avatars_controller.rb | 7 | ||||
| -rw-r--r-- | spec/controllers/my/avatars_controller_spec.rb | 8 |
2 files changed, 6 insertions, 9 deletions
diff --git a/app/controllers/my/avatars_controller.rb b/app/controllers/my/avatars_controller.rb index c88ba638..4c297bdd 100644 --- a/app/controllers/my/avatars_controller.rb +++ b/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) diff --git a/spec/controllers/my/avatars_controller_spec.rb b/spec/controllers/my/avatars_controller_spec.rb index f8418009..96ff82ce 100644 --- a/spec/controllers/my/avatars_controller_spec.rb +++ b/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 |
