aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/user_controller.rb6
-rw-r--r--spec/controllers/user_controller_spec.rb28
2 files changed, 34 insertions, 0 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 32b6978ea..d66b4aa8e 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -460,6 +460,12 @@ class UserController < ApplicationController
return
end
if !params[:submitted_draft_profile_photo].nil?
+ if @user.banned?
+ flash[:error]= _('Banned users cannot edit their profile')
+ redirect_to set_profile_photo_path
+ return
+ end
+
# check for uploaded image
file_name = nil
file_content = nil
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index cde4c9188..443856cf3 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -3,6 +3,34 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe UserController do
+ describe :set_profile_photo do
+
+ context 'user is banned' do
+
+ before(:each) do
+ @user = FactoryGirl.create(:user, :ban_text => 'Causing trouble')
+ session[:user_id] = @user.id
+ @uploadedfile = fixture_file_upload("/files/parrot.png")
+
+ post :set_profile_photo, :id => @user.id,
+ :file => @uploadedfile,
+ :submitted_draft_profile_photo => 1,
+ :automatically_crop => 1
+ end
+
+ it 'redirects to the profile page' do
+ expect(response).to redirect_to(set_profile_photo_path)
+ end
+
+ it 'renders an error message' do
+ msg = 'Banned users cannot edit their profile'
+ expect(flash[:error]).to eq(msg)
+ end
+
+ end
+
+ end
+
describe :set_profile_about_me do
context 'user is banned' do