2015-04-26 12:48:37 +05:30
|
|
|
class Spinach::Features::AdminGroups < Spinach::FeatureSteps
|
2014-09-02 18:07:02 +05:30
|
|
|
include SharedAuthentication
|
2015-12-23 02:04:40 +05:30
|
|
|
include SharedGroup
|
2014-09-02 18:07:02 +05:30
|
|
|
include SharedPaths
|
|
|
|
include SharedUser
|
|
|
|
include SharedActiveTab
|
|
|
|
include Select2Helper
|
|
|
|
|
|
|
|
When 'I visit admin group page' do
|
|
|
|
visit admin_group_path(current_group)
|
|
|
|
end
|
|
|
|
|
|
|
|
When 'I click new group link' do
|
|
|
|
click_link "New Group"
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I have group with projects' do
|
2014-09-02 18:07:02 +05:30
|
|
|
@group = create(:group)
|
|
|
|
@project = create(:project, group: @group)
|
|
|
|
@event = create(:closed_issue_event, project: @project)
|
|
|
|
|
|
|
|
@project.team << [current_user, :master]
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'submit form with new group info' do
|
|
|
|
fill_in 'group_path', with: 'gitlab'
|
2014-09-02 18:07:02 +05:30
|
|
|
fill_in 'group_description', with: 'Group description'
|
|
|
|
click_button "Create group"
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should see newly created group' do
|
2015-09-11 14:41:01 +05:30
|
|
|
expect(page).to have_content "Group: gitlab"
|
|
|
|
expect(page).to have_content "Group description"
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should be redirected to group page' do
|
2015-09-11 14:41:01 +05:30
|
|
|
expect(current_path).to eq admin_group_path(Group.find_by(path: 'gitlab'))
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
When 'I select user "John Doe" from user list as "Reporter"' do
|
2015-04-26 12:48:37 +05:30
|
|
|
select2(user_john.id, from: "#user_ids", multiple: true)
|
2015-09-11 14:41:01 +05:30
|
|
|
page.within "#new_project_member" do
|
|
|
|
select "Reporter", from: "access_level"
|
|
|
|
end
|
|
|
|
click_button "Add users to group"
|
|
|
|
end
|
|
|
|
|
|
|
|
When 'I select user "johndoe@gitlab.com" from user list as "Reporter"' do
|
|
|
|
select2('johndoe@gitlab.com', from: "#user_ids", multiple: true)
|
|
|
|
page.within "#new_project_member" do
|
2015-04-26 12:48:37 +05:30
|
|
|
select "Reporter", from: "access_level"
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
click_button "Add users to group"
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'I should see "John Doe" in team list in every project as "Reporter"' do
|
2015-09-11 14:41:01 +05:30
|
|
|
page.within ".group-users-list" do
|
|
|
|
expect(page).to have_content "John Doe"
|
|
|
|
expect(page).to have_content "Reporter"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see "johndoe@gitlab.com" in team list in every project as "Reporter"' do
|
|
|
|
page.within ".group-users-list" do
|
|
|
|
expect(page).to have_content "johndoe@gitlab.com (invited)"
|
|
|
|
expect(page).to have_content "Reporter"
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should be all groups' do
|
|
|
|
Group.all.each do |group|
|
2015-09-11 14:41:01 +05:30
|
|
|
expect(page).to have_content group.name
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
step 'we have user "John Doe" in group' do
|
2015-09-11 14:41:01 +05:30
|
|
|
current_group.add_reporter(user_john)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
step 'I remove user "John Doe" from group' do
|
2015-09-11 14:41:01 +05:30
|
|
|
page.within "#user_#{user_john.id}" do
|
2015-04-26 12:48:37 +05:30
|
|
|
click_link 'Remove user from group'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should not see "John Doe" in team list' do
|
2015-09-11 14:41:01 +05:30
|
|
|
page.within ".group-users-list" do
|
|
|
|
expect(page).not_to have_content "John Doe"
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
step 'I select current user as "Developer"' do
|
|
|
|
page.within ".users-group-form" do
|
|
|
|
select2(current_user.id, from: "#user_ids", multiple: true)
|
|
|
|
select "Developer", from: "access_level"
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button "Add users to group"
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should see current user as "Developer"' do
|
|
|
|
page.within '.content-list' do
|
|
|
|
expect(page).to have_content(current_user.name)
|
|
|
|
expect(page).to have_content('Developer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I click on the "Remove User From Group" button for current user' do
|
|
|
|
find(:css, 'li', text: current_user.name).find(:css, 'a.btn-remove').click
|
|
|
|
# poltergeist always confirms popups.
|
|
|
|
end
|
|
|
|
|
|
|
|
step 'I should not see current user as "Developer"' do
|
|
|
|
page.within '.content-list' do
|
|
|
|
expect(page).not_to have_content(current_user.name)
|
|
|
|
expect(page).not_to have_content('Developer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
protected
|
|
|
|
|
|
|
|
def current_group
|
|
|
|
@group ||= Group.first
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
def user_john
|
|
|
|
@user_john ||= User.find_by(name: "John Doe")
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|