This commit is contained in:
@@ -2,18 +2,22 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Profile settings', type: :feature do
|
||||
let(:user) { create :user, cn: "mwahlberg" }
|
||||
let(:avatar_base64) { File.read("#{Rails.root}/spec/fixtures/files/avatar-base64.txt") }
|
||||
let(:avatar_jpeg) { File.binread("#{Rails.root}/spec/fixtures/files/taipei.jpg") }
|
||||
|
||||
before do
|
||||
Flipper.enable "avatar_upload"
|
||||
|
||||
login_as user, :scope => :user
|
||||
allow(user).to receive(:display_name).and_return("Mark")
|
||||
allow_any_instance_of(User).to receive(:dn).and_return("cn=mwahlberg,ou=kosmos.org,cn=users,dc=kosmos,dc=org")
|
||||
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, display_name: "Mark", pgp_key: nil
|
||||
})
|
||||
allow_any_instance_of(User).to receive(:avatar).and_return(avatar_base64)
|
||||
|
||||
Flipper.enable "avatar_upload"
|
||||
allow_any_instance_of(User).to receive(:dn)
|
||||
.and_return("cn=mwahlberg,ou=kosmos.org,cn=users,dc=kosmos,dc=org")
|
||||
allow_any_instance_of(User).to receive(:ldap_entry)
|
||||
.and_return({
|
||||
uid: user.cn, ou: user.ou, display_name: "Mark", pgp_key: nil
|
||||
})
|
||||
allow_any_instance_of(User).to receive(:avatar)
|
||||
.and_return(avatar_jpeg)
|
||||
end
|
||||
|
||||
feature "Update display name" do
|
||||
@@ -71,7 +75,7 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
file_path = "#{Rails.root}/spec/fixtures/files/taipei.jpg"
|
||||
|
||||
expect_any_instance_of(LdapManager::UpdateAvatar).to receive(:replace_attribute)
|
||||
.with(user.dn, :jpegPhoto, avatar_base64).and_return(true)
|
||||
.with(user.dn, :jpegPhoto, avatar_jpeg).and_return(true)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", file_path
|
||||
|
||||
Reference in New Issue
Block a user