Commit 9f87b34f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Combine group leave feature specs in one file

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f0886918
require 'spec_helper'
feature 'Groups > Members > Last owner cannot leave group', feature: true do
let(:owner) { create(:user) }
let(:group) { create(:group) }
background do
group.add_owner(owner)
gitlab_sign_in(owner)
visit group_path(group)
end
scenario 'user does not see a "Leave group" link' do
expect(page).not_to have_content 'Leave group'
end
end
require 'spec_helper'
feature 'Groups > Members > Leave group', feature: true do
let(:user) { create(:user) }
let(:other_user) { create(:user) }
let(:group) { create(:group) }
background do
gitlab_sign_in(user)
end
scenario 'guest leaves the group' do
group.add_guest(user)
group.add_owner(other_user)
visit group_path(group)
click_link 'Leave group'
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.members).not_to include(user)
end
scenario 'guest leaves the group as last member' do
group.add_guest(user)
visit group_path(group)
click_link 'Leave group'
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.members).not_to include(user)
end
scenario 'owner leaves the group if they is not the last owner' do
group.add_owner(user)
group.add_owner(other_user)
visit group_path(group)
click_link 'Leave group'
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.members).not_to include(user)
end
scenario 'owner can not leave the group if they is a last owner' do
group.add_owner(user)
visit group_path(group)
expect(page).not_to have_content 'Leave group'
visit group_group_members_path(group)
expect(find(:css, '.project-members-page li', text: user.name)).not_to have_selector(:css, 'a.btn-remove')
end
def left_group_message(group)
"You left the \"#{group.name}\""
end
end
require 'spec_helper'
feature 'Groups > Members > Member leaves group', feature: true do
let(:user) { create(:user) }
let(:owner) { create(:user) }
let(:group) { create(:group, :public) }
background do
group.add_owner(owner)
group.add_developer(user)
gitlab_sign_in(user)
visit group_path(group)
end
scenario 'user leaves group' do
click_link 'Leave group'
expect(current_path).to eq(dashboard_groups_path)
expect(group.users.exists?(user.id)).to be_falsey
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment