Commit 6f71ffff authored by blackst0ne's avatar blackst0ne Committed by Rémy Coutable

Replace the `groups_management.feature` spinach test with an rspec analog

parent 29f3fc91
---
title: Replace the `groups_management.feature` spinach test with an rspec analog
merge_request: 5516
author: '@blackst0ne'
type: other
require "spec_helper"
describe "User manages members" do
set(:group) { create(:group) }
set(:project) { create(:project, namespace: group) }
set(:user) { create(:user) }
before do
sign_in(user)
end
shared_examples "when group membership is unlocked" do
before do
group.update_attributes(membership_lock: false)
visit(project_project_members_path(project))
end
it { expect(page).to have_link("Import members").and have_selector(".project-access-select") }
end
shared_examples "when group membership is locked" do
before do
group.update_attributes(membership_lock: true)
visit(project_project_members_path(project))
end
it { expect(page).to have_no_button("Add members").and have_no_link("Import members") }
end
context "as project master" do
before do
project.add_master(user)
end
it_behaves_like "when group membership is unlocked"
it_behaves_like "when group membership is locked"
end
context "as group owner" do
before do
group.add_owner(user)
end
it_behaves_like "when group membership is unlocked"
it_behaves_like "when group membership is locked"
end
end
Feature: Groups Management
Background:
Given "Pete Peters" is owner of group "Sourcing"
And "Open" is in group "Sourcing"
And "Mary Jane" has master access for project "Open"
Scenario: Project master can add members before lock
Given I sign in as "Mary Jane"
And I go to "Open" project members page
Then I can control user membership
When Group membership lock is enabled
And I reload "Open" project members page
Then I cannot control user membership from project page
And I logout
@javascript
Scenario: Group owner lock membership controls
Given I sign in as "Pete Peters"
And I go to group settings page
And I enable membership lock
And I go to project settings
Then I cannot control user membership from project page
And I logout
class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedGroup
include SharedUser
include Select2Helper
step '"Open" is in group "Sourcing"' do
@group = Group.find_by(name: "Sourcing")
@project ||= create(:project, name: "Open", namespace: @group)
end
step '"Mary Jane" has master access for project "Open"' do
@user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
@project = Project.find_by(name: "Open")
@project.add_master(@user)
end
step "Group membership lock is enabled" do
@group = Group.find_by(name: "Sourcing")
@group.update_attributes(membership_lock: true)
end
step 'I go to "Open" project members page' do
click_link 'Sourcing / Open'
page.within('.nav-sidebar') do
first(:link, text: 'Settings').click
end
click_link 'Members'
end
step 'I can control user membership' do
expect(page).to have_link 'Import members'
expect(page).to have_selector '.project-access-select'
end
step 'I reload "Open" project members page' do
visit root_path
click_link 'Sourcing / Open'
page.within('.nav-sidebar') do
first(:link, text: 'Settings').click
end
click_link 'Members'
end
step 'I go to group settings page' do
visit dashboard_groups_path
click_link 'Sourcing'
page.within '.nav-sidebar' do
first(:link, text: 'Settings').click
end
page.within '.sidebar-top-level-items > .active' do
click_link 'General'
end
end
step 'I enable membership lock' do
check 'group_membership_lock'
click_button 'Save group'
end
step 'I go to project settings' do
@project = Project.find_by(name: "Open")
page.within '.nav-sidebar' do
click_link 'Projects'
end
link = "/#{@project.full_path}/project_members"
find(:xpath, "//a[@href=\"#{link}\"]").click
end
step 'I cannot control user membership from project page' do
expect(page).not_to have_button 'Add members'
expect(page).not_to have_link 'Import members'
end
end
......@@ -25,10 +25,6 @@ module SharedGroup
is_member_of("Mary Jane", "Guest", Gitlab::Access::GUEST)
end
step '"Pete Peters" is owner of group "Sourcing"' do
is_member_of("Pete Peters", "Sourcing", Gitlab::Access::OWNER)
end
step 'I should see group "TestGroup"' do
expect(page).to have_content "TestGroup"
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