Merge branch 'feature/ejabberd_pep' into live
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
commit
ae7291d4f1
@ -36,6 +36,7 @@ class SettingsController < ApplicationController
|
||||
if @user.avatar_new.present?
|
||||
if store_user_avatar
|
||||
LdapManager::UpdateAvatar.call(user: @user)
|
||||
XmppSetAvatarJob.perform_later(user: @user)
|
||||
else
|
||||
@validation_errors = @user.errors
|
||||
render :show, status: :unprocessable_entity and return
|
||||
|
@ -5,11 +5,12 @@ class XmppSetAvatarJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user:, overwrite: false)
|
||||
return if Rails.env.development?
|
||||
@user = user
|
||||
|
||||
unless overwrite
|
||||
current_avatar = get_current_avatar
|
||||
Rails.logger.debug { "User #{user.cn} already has an avatar set. Nothing to do." }
|
||||
Rails.logger.info { "User #{user.cn} already has an avatar set" }
|
||||
return if current_avatar.present?
|
||||
end
|
||||
|
||||
@ -56,6 +57,10 @@ class XmppSetAvatarJob < ApplicationJob
|
||||
end
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
# See https://xmpp.org/extensions/xep-0084.html
|
||||
>>>>>>> feature/ejabberd_pep
|
||||
def build_xep0084_stanzas
|
||||
img_data = process_avatar
|
||||
sha1_hash = Digest::SHA1.hexdigest(img_data)
|
||||
|
@ -46,6 +46,8 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
|
||||
feature "Update avatar" do
|
||||
scenario "fails with validation error for wrong content type" do
|
||||
expect(LdapManager::UpdateAvatar).not_to receive(:call)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", "#{Rails.root}/spec/fixtures/files/bitcoin.pdf"
|
||||
click_button "Save"
|
||||
@ -57,8 +59,7 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
end
|
||||
|
||||
scenario "fails with validation error for file size too large" do
|
||||
expect_any_instance_of(LdapManager::UpdateAvatar)
|
||||
.not_to receive(:replace_attribute).and_return(true)
|
||||
expect(LdapManager::UpdateAvatar).not_to receive(:call)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", "#{Rails.root}/spec/fixtures/files/fsociety-irc.png"
|
||||
@ -73,8 +74,12 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
scenario 'works with valid JPG file' do
|
||||
file_path = "#{Rails.root}/spec/fixtures/files/taipei.jpg"
|
||||
|
||||
expect_any_instance_of(LdapManager::UpdateAvatar)
|
||||
.to receive(:replace_attribute).and_return(true)
|
||||
expect(LdapManager::UpdateAvatar)
|
||||
.to receive(:call).with(user: user)
|
||||
.and_return(true)
|
||||
expect(XmppSetAvatarJob)
|
||||
.to receive(:perform_later).with(user: user)
|
||||
.and_return(true)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", file_path
|
||||
@ -89,8 +94,12 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
scenario 'works with valid PNG file' do
|
||||
file_path = "#{Rails.root}/spec/fixtures/files/bender.png"
|
||||
|
||||
expect_any_instance_of(LdapManager::UpdateAvatar)
|
||||
.to receive(:replace_attribute).and_return(true)
|
||||
expect(LdapManager::UpdateAvatar)
|
||||
.to receive(:call).with(user: user)
|
||||
.and_return(true)
|
||||
expect(XmppSetAvatarJob)
|
||||
.to receive(:perform_later).with(user: user)
|
||||
.and_return(true)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", file_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user