From bf4b4384590c271d1dfadf874d185c2f6130ad0e Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 6 May 2015 14:33:39 -0700 Subject: Fix bug where avatar filenames were not actually deleted from the database during removal. This would result in a 404 error in certain views. The `save` call was being rolled back due to an error in the validation step. Relax the validation step so that this works. Closes #1570 --- spec/controllers/profiles/avatars_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spec/controllers/profiles/avatars_controller_spec.rb (limited to 'spec/controllers/profiles') diff --git a/spec/controllers/profiles/avatars_controller_spec.rb b/spec/controllers/profiles/avatars_controller_spec.rb new file mode 100644 index 00000000000..ad5855df0a4 --- /dev/null +++ b/spec/controllers/profiles/avatars_controller_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe Profiles::AvatarsController do + let(:user) { create(:user, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png")) } + + before do + sign_in(user) + controller.instance_variable_set(:@user, user) + end + + it 'destroy should remove avatar from DB' do + delete :destroy + @user = assigns(:user) + expect(@user.avatar.present?).to be_falsey + expect(@user).to be_valid + end +end -- cgit v1.2.1