debian-mirror-gitlab/spec/features/groups/group_settings_spec.rb

107 lines
3.4 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
feature 'Edit group settings' do
2017-08-17 22:00:37 +05:30
given(:user) { create(:user) }
given(:group) { create(:group, path: 'foo') }
background do
group.add_owner(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
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}" }
scenario 'the group is accessible via the new path' do
update_path(new_group_path)
visit new_group_full_path
expect(current_path).to eq(new_group_full_path)
2017-09-10 17:25:29 +05:30
expect(find('h1.group-title')).to have_content(group.name)
2017-08-17 22:00:37 +05:30
end
scenario 'the old group path redirects to the new path' do
update_path(new_group_path)
visit old_group_full_path
expect(current_path).to eq(new_group_full_path)
2017-09-10 17:25:29 +05:30
expect(find('h1.group-title')).to have_content(group.name)
2017-08-17 22:00:37 +05:30
end
context 'with a subgroup' do
given!(:subgroup) { create(:group, parent: group, path: 'subgroup') }
given(:old_subgroup_full_path) { "/#{group.path}/#{subgroup.path}" }
given(:new_subgroup_full_path) { "/#{new_group_path}/#{subgroup.path}" }
scenario 'the subgroup is accessible via the new path' do
update_path(new_group_path)
visit new_subgroup_full_path
expect(current_path).to eq(new_subgroup_full_path)
2017-09-10 17:25:29 +05:30
expect(find('h1.group-title')).to have_content(subgroup.name)
2017-08-17 22:00:37 +05:30
end
scenario 'the old subgroup path redirects to the new path' do
update_path(new_group_path)
visit old_subgroup_full_path
expect(current_path).to eq(new_subgroup_full_path)
2017-09-10 17:25:29 +05:30
expect(find('h1.group-title')).to have_content(subgroup.name)
2017-08-17 22:00:37 +05:30
end
end
context 'with a project' do
2017-09-10 17:25:29 +05:30
given!(:project) { create(:project, group: group) }
2017-08-17 22:00:37 +05:30
given(:old_project_full_path) { "/#{group.path}/#{project.path}" }
given(:new_project_full_path) { "/#{new_group_path}/#{project.path}" }
2017-09-10 17:25:29 +05:30
before(:context) do
TestEnv.clean_test_path
end
2018-03-17 18:26:18 +05:30
after do
2017-09-10 17:25:29 +05:30
TestEnv.clean_test_path
end
2017-08-17 22:00:37 +05:30
scenario 'the project is accessible via the new path' do
update_path(new_group_path)
visit new_project_full_path
expect(current_path).to eq(new_project_full_path)
2018-03-17 18:26:18 +05:30
expect(find('.breadcrumbs')).to have_content(project.path)
2017-08-17 22:00:37 +05:30
end
scenario 'the old project path redirects to the new path' do
update_path(new_group_path)
visit old_project_full_path
expect(current_path).to eq(new_project_full_path)
2018-03-17 18:26:18 +05:30
expect(find('.breadcrumbs')).to have_content(project.path)
2017-08-17 22:00:37 +05:30
end
end
end
2018-05-09 12:01:36 +05:30
describe 'edit group avatar' do
before do
visit edit_group_path(group)
attach_file(:group_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
expect { click_button 'Save group' }.to change { group.reload.avatar? }.to(true)
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-08-17 22:00:37 +05:30
end
def update_path(new_group_path)
visit edit_group_path(group)
fill_in 'group_path', with: new_group_path
click_button 'Save group'
end