Merge branch 'master' into feature/btcpay_configs
This commit is contained in:
@@ -54,6 +54,11 @@ RSpec.describe 'remoteStorage OAuth Dialog', type: :feature do
|
||||
context "when signed out" do
|
||||
let(:user) { create :user }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(User).to receive(:valid_ldap_authentication?)
|
||||
.with(user.password).and_return(true)
|
||||
end
|
||||
|
||||
it "prefills the username field in the signin form" do
|
||||
visit new_rs_oauth_path(useraddress: user.address,
|
||||
redirect_uri: "http://example.com",
|
||||
@@ -62,5 +67,19 @@ RSpec.describe 'remoteStorage OAuth Dialog', type: :feature do
|
||||
|
||||
expect(find("#user_cn").value).to eq(user.cn)
|
||||
end
|
||||
|
||||
it "redirects to the OAuth dialog after sign-in" do
|
||||
auth_url = new_rs_oauth_url(useraddress: user.address,
|
||||
redirect_uri: "http://example.com",
|
||||
client_id: "http://example.com",
|
||||
scope: "documents,[photos], contacts:r")
|
||||
visit auth_url
|
||||
|
||||
fill_in "User", with: user.cn
|
||||
fill_in "Password", with: user.password
|
||||
click_button "Log in"
|
||||
|
||||
expect(current_url).to eq(auth_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,20 +2,19 @@ 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") }
|
||||
|
||||
before do
|
||||
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"
|
||||
})
|
||||
allow_any_instance_of(User).to receive(:avatar).and_return(avatar_base64)
|
||||
end
|
||||
|
||||
feature "Update display name" do
|
||||
before do
|
||||
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"
|
||||
})
|
||||
end
|
||||
|
||||
scenario 'fails with validation error' do
|
||||
visit setting_path(:profile)
|
||||
fill_in 'Display name', with: "M"
|
||||
@@ -42,4 +41,59 @@ RSpec.describe 'Profile settings', type: :feature do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature "Update avatar" do
|
||||
scenario "fails with validation error for wrong content type" do
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", "#{Rails.root}/spec/fixtures/files/bitcoin.pdf"
|
||||
click_button "Save"
|
||||
|
||||
expect(current_url).to eq(setting_url(:profile))
|
||||
within ".error-msg" do
|
||||
expect(page).to have_content("must be a JPEG or PNG file")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "fails with validation error for file size too large" do
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", "#{Rails.root}/spec/fixtures/files/fsociety-irc.png"
|
||||
click_button "Save"
|
||||
|
||||
expect(current_url).to eq(setting_url(:profile))
|
||||
within ".error-msg" do
|
||||
expect(page).to have_content("file size is too large")
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
.with(user.dn, :jpegPhoto, avatar_base64).and_return(true)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", file_path
|
||||
click_button "Save"
|
||||
|
||||
expect(current_url).to eq(setting_url(:profile))
|
||||
within ".flash-msg" do
|
||||
expect(page).to have_content("Settings saved")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'works with valid PNG file' do
|
||||
file_path = "#{Rails.root}/spec/fixtures/files/bender.png"
|
||||
|
||||
expect(LdapManager::UpdateAvatar).to receive(:call).and_return(true)
|
||||
|
||||
visit setting_path(:profile)
|
||||
attach_file "Avatar", file_path
|
||||
click_button "Save"
|
||||
|
||||
expect(current_url).to eq(setting_url(:profile))
|
||||
within ".flash-msg" do
|
||||
expect(page).to have_content("Settings saved")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user