2017-04-21 17:05:19 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Edit group settings' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group, path: 'foo') }
|
2017-04-21 17:05:19 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-04-21 17:05:19 -04:00
|
|
|
group.add_owner(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-04-21 17:05:19 -04: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 02:32:05 -04:00
|
|
|
it 'the group is accessible via the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_group_full_path
|
|
|
|
expect(current_path).to eq(new_group_full_path)
|
2017-06-22 14:07:41 -04:00
|
|
|
expect(find('h1.group-title')).to have_content(group.name)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the old group path redirects to the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_group_full_path
|
|
|
|
expect(current_path).to eq(new_group_full_path)
|
2017-06-22 14:07:41 -04:00
|
|
|
expect(find('h1.group-title')).to have_content(group.name)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a subgroup' do
|
2018-07-05 02:32:05 -04: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 17:05:19 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the subgroup is accessible via the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_subgroup_full_path
|
|
|
|
expect(current_path).to eq(new_subgroup_full_path)
|
2017-06-22 14:07:41 -04:00
|
|
|
expect(find('h1.group-title')).to have_content(subgroup.name)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the old subgroup path redirects to the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_subgroup_full_path
|
|
|
|
expect(current_path).to eq(new_subgroup_full_path)
|
2017-06-22 14:07:41 -04:00
|
|
|
expect(find('h1.group-title')).to have_content(subgroup.name)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a project' do
|
2018-07-05 02:32:05 -04: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 14:18:56 -04:00
|
|
|
|
|
|
|
before(:context) do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
|
|
|
|
2017-08-10 18:31:42 -04:00
|
|
|
after do
|
2017-06-14 14:18:56 -04:00
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
2017-04-21 17:05:19 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the project is accessible via the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit new_project_full_path
|
|
|
|
expect(current_path).to eq(new_project_full_path)
|
2017-08-17 04:51:19 -04:00
|
|
|
expect(find('.breadcrumbs')).to have_content(project.path)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the old project path redirects to the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_path(new_group_path)
|
|
|
|
visit old_project_full_path
|
|
|
|
expect(current_path).to eq(new_project_full_path)
|
2017-08-17 04:51:19 -04:00
|
|
|
expect(find('.breadcrumbs')).to have_content(project.path)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 04:29:05 -04: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'))
|
|
|
|
|
2018-05-28 11:02:04 -04:00
|
|
|
expect { save_group }.to change { group.reload.avatar? }.to(true)
|
2018-03-17 04:29:05 -04: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 17:05:19 -04:00
|
|
|
|
2018-05-28 11:02:04 -04: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
|
|
|
|
click_button 'Change group path'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def save_group
|
|
|
|
page.within('.gs-general') do
|
|
|
|
click_button 'Save group'
|
|
|
|
end
|
|
|
|
end
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|