diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index a1f824c..f3d316c 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -45,10 +45,11 @@ describe UsersController, type: :controller do end context 'successful' do - it 'should update attributes' do + it 'should update privacy' do new_private = !(@user.private) put :update, id: @user, user: { private: new_private } expect(@user.reload.private).to be new_private + expect(flash[:success]).to be_present end it 'should update dagschotel' do @@ -56,6 +57,25 @@ describe UsersController, type: :controller do put :update, id: @user, user: { dagschotel_id: product.id } expect(@user.reload.dagschotel).to eq(product) end + + it 'should accept real images' do + file = fixture_file_upload('files/real-image.png', 'image/png') + put :update, id: @user, user: { avatar: file } + expect(flash[:success]).to be_present + end + end + + context 'danger zone' do + it 'should warn for NOPs' do + put :update, id: @user, user: {} + expect(flash[:notice]).to be_present + end + + it 'should not accept unreal images' do + file = fixture_file_upload('files/unreal-image.svg', 'image/svg+xml') + put :update, id: @user, user: { avatar: file } + expect(flash[:error]).to be_present + end end end diff --git a/spec/fixtures/files/real-image.png b/spec/fixtures/files/real-image.png new file mode 100644 index 0000000..ae84994 Binary files /dev/null and b/spec/fixtures/files/real-image.png differ diff --git a/spec/fixtures/files/unreal-image.svg b/spec/fixtures/files/unreal-image.svg new file mode 100644 index 0000000..a920dc7 --- /dev/null +++ b/spec/fixtures/files/unreal-image.svg @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + +