kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
53 lines
1.3 KiB
7 years ago
|
require 'spec_helper'
|
||
|
require_relative './shared_avatar_examples'
|
||
|
|
||
|
describe 'User avatar management', type: :feature, js: true do
|
||
|
include Rails.application.routes.url_helpers
|
||
|
|
||
7 years ago
|
let(:user) { FactoryBot.create :admin }
|
||
7 years ago
|
let(:avatar_management_path) { edit_user_path(target_user, tab: 'avatar') }
|
||
|
|
||
|
before do
|
||
|
login_as user
|
||
|
end
|
||
|
|
||
|
context 'when user is admin' do
|
||
7 years ago
|
let(:target_user) { FactoryBot.create :user }
|
||
7 years ago
|
it_behaves_like 'avatar management'
|
||
|
end
|
||
|
|
||
|
context 'when user is self' do
|
||
7 years ago
|
let(:user) { FactoryBot.create :user }
|
||
7 years ago
|
let(:target_user) { user }
|
||
|
it 'forbids the user to access' do
|
||
|
visit avatar_management_path
|
||
|
expect(page).to have_selector('h2', text: '403')
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'when user is another user' do
|
||
7 years ago
|
let(:target_user) { FactoryBot.create :user }
|
||
|
let(:user) { FactoryBot.create :user }
|
||
7 years ago
|
|
||
|
it 'forbids the user to access' do
|
||
|
visit avatar_management_path
|
||
|
expect(page).to have_selector('h2', text: '403')
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe 'none enabled' do
|
||
7 years ago
|
let(:target_user) { FactoryBot.create :user }
|
||
7 years ago
|
|
||
|
before do
|
||
|
allow(Setting)
|
||
|
.to receive(:plugin_openproject_avatars)
|
||
|
.and_return({})
|
||
|
end
|
||
|
|
||
|
it 'does not render the user edit tab' do
|
||
|
visit edit_user_path(user)
|
||
|
expect(page).to have_no_selector '#tab-avatar'
|
||
|
end
|
||
|
end
|
||
|
end
|