2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Edit group settings' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group, path: 'foo') }
|
2017-04-21 21:05:19 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2017-04-21 21:05:19 +00:00
|
|
|
group.add_owner(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when the group path is changed' do
|
|
|
|
let(:new_group_path) { 'bar' }
|
|
|
|
let(:old_group_full_path) { "/#{group.path}" }
|
|
|
|
let(:new_group_full_path) { "/#{new_group_path}" }
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the group is accessible via the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_group_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_group_full_path)
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(find('h1.home-panel-title')).to have_content(group.name)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the old group path redirects to the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_group_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_group_full_path)
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(find('h1.home-panel-title')).to have_content(group.name)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a subgroup' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let!(:subgroup) { create(:group, parent: group, path: 'subgroup') }
|
|
|
|
let(:old_subgroup_full_path) { "/#{group.path}/#{subgroup.path}" }
|
|
|
|
let(:new_subgroup_full_path) { "/#{new_group_path}/#{subgroup.path}" }
|
2017-04-21 21:05:19 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the subgroup is accessible via the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_subgroup_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_subgroup_full_path)
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(find('h1.home-panel-title')).to have_content(subgroup.name)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the old subgroup path redirects to the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_subgroup_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_subgroup_full_path)
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(find('h1.home-panel-title')).to have_content(subgroup.name)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a project' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let!(:project) { create(:project, group: group) }
|
|
|
|
let(:old_project_full_path) { "/#{group.path}/#{project.path}" }
|
|
|
|
let(:new_project_full_path) { "/#{new_group_path}/#{project.path}" }
|
2017-06-14 18:18:56 +00:00
|
|
|
|
|
|
|
before(:context) do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
|
|
|
|
2017-08-10 22:31:42 +00:00
|
|
|
after do
|
2017-06-14 18:18:56 +00:00
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
2017-04-21 21:05:19 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the project is accessible via the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_project_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_project_full_path)
|
2017-08-17 08:51:19 +00:00
|
|
|
expect(find('.breadcrumbs')).to have_content(project.path)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the old project path redirects to the new path' do
|
2017-04-21 21:05:19 +00:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_project_full_path
|
2019-12-04 12:07:12 +00:00
|
|
|
|
2017-04-21 21:05:19 +00:00
|
|
|
expect(current_path).to eq(new_project_full_path)
|
2017-08-17 08:51:19 +00:00
|
|
|
expect(find('.breadcrumbs')).to have_content(project.path)
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 08:29:05 +00:00
|
|
|
|
2019-04-05 18:49:46 +00:00
|
|
|
describe 'project creation level menu' do
|
|
|
|
it 'shows the selection menu' do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_content('Allowed to create projects')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-26 04:59:10 +00:00
|
|
|
describe 'subgroup creation level menu' do
|
|
|
|
it 'shows the selection menu' do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_content('Allowed to create subgroups')
|
|
|
|
end
|
|
|
|
end
|
2019-06-28 20:31:47 +00:00
|
|
|
|
2018-03-17 08:29:05 +00:00
|
|
|
describe 'edit group avatar' do
|
|
|
|
before do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
attach_file(:group_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
|
|
|
|
|
2019-12-04 12:07:12 +00:00
|
|
|
expect { save_general_group }.to change { group.reload.avatar? }.to(true)
|
2018-03-17 08:29:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'uploads new group avatar' do
|
|
|
|
expect(group.avatar).to be_instance_of AvatarUploader
|
|
|
|
expect(group.avatar.url).to eq "/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
|
|
|
|
expect(page).to have_link('Remove avatar')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes group avatar' do
|
|
|
|
expect { click_link 'Remove avatar' }.to change { group.reload.avatar? }.to(false)
|
|
|
|
expect(page).not_to have_link('Remove avatar')
|
|
|
|
end
|
|
|
|
end
|
2017-04-21 21:05:19 +00:00
|
|
|
|
2018-10-06 18:05:14 +00:00
|
|
|
describe 'edit group path' do
|
|
|
|
it 'has a root URL label for top-level group' do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
expect(find(:css, '.group-root-path').text).to eq(root_url)
|
|
|
|
end
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
it 'has a parent group URL label for a subgroup group' do
|
2018-10-06 18:05:14 +00:00
|
|
|
subgroup = create(:group, parent: group)
|
|
|
|
|
|
|
|
visit edit_group_path(subgroup)
|
|
|
|
|
|
|
|
expect(find(:css, '.group-root-path').text).to eq(group_url(subgroup.parent) + '/')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-04 12:07:12 +00:00
|
|
|
context 'disable email notifications' do
|
|
|
|
it 'is visible' do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_selector('#group_emails_disabled', visible: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'accepts the changed state' do
|
|
|
|
visit edit_group_path(group)
|
|
|
|
check 'group_emails_disabled'
|
|
|
|
|
|
|
|
expect { save_permissions_group }.to change { updated_emails_disabled? }.to(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-28 15:02:04 +00:00
|
|
|
def update_path(new_group_path)
|
|
|
|
visit edit_group_path(group)
|
|
|
|
|
|
|
|
page.within('.gs-advanced') do
|
|
|
|
fill_in 'group_path', with: new_group_path
|
2020-07-30 18:09:39 +00:00
|
|
|
click_button 'Change group URL'
|
2018-05-28 15:02:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-04 12:07:12 +00:00
|
|
|
def save_general_group
|
2018-05-28 15:02:04 +00:00
|
|
|
page.within('.gs-general') do
|
2018-10-15 13:36:19 +00:00
|
|
|
click_button 'Save changes'
|
2018-05-28 15:02:04 +00:00
|
|
|
end
|
|
|
|
end
|
2019-12-04 12:07:12 +00:00
|
|
|
|
|
|
|
def save_permissions_group
|
|
|
|
page.within('.gs-permissions') do
|
|
|
|
click_button 'Save changes'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_emails_disabled?
|
2021-04-08 15:09:06 +00:00
|
|
|
group.reload.clear_memoization(:emails_disabled_memoized)
|
2019-12-04 12:07:12 +00:00
|
|
|
group.emails_disabled?
|
|
|
|
end
|
2017-04-21 21:05:19 +00:00
|
|
|
end
|