summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-04-17 21:03:30 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-04-17 21:03:30 +0300
commit5f087604826229af1dbd79a9a549d5e7da9c2908 (patch)
treeb9c14160ae487d6450cdf22e8990284e4dde3c01
parent395fca1493f6a4f8a40941faf43f47f5bf45f5a5 (diff)
downloadgitlab-ce-5f087604826229af1dbd79a9a549d5e7da9c2908.tar.gz
Move some project/group members spinach tests to rspecdz-refactor-create-members
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--features/group/members.feature34
-rw-r--r--features/project/team_management.feature20
-rw-r--r--features/steps/group/members.rb65
-rw-r--r--features/steps/project/team_management.rb77
-rw-r--r--spec/features/groups/members/list_spec.rb54
-rw-r--r--spec/features/projects/members/list_spec.rb90
6 files changed, 146 insertions, 194 deletions
diff --git a/features/group/members.feature b/features/group/members.feature
index 1f9514bac39..e539f6a1273 100644
--- a/features/group/members.feature
+++ b/features/group/members.feature
@@ -4,40 +4,6 @@ Feature: Group Members
And "John Doe" is owner of group "Owned"
And "John Doe" is guest of group "Guest"
- @javascript
- Scenario: I should add user to group "Owned"
- Given User "Mary Jane" exists
- When I visit group "Owned" members page
- And I select user "Mary Jane" from list with role "Reporter"
- Then I should see user "Mary Jane" in team list
-
- @javascript
- Scenario: Add user to group
- Given gitlab user "Mike"
- When I visit group "Owned" members page
- When I select "Mike" as "Reporter"
- Then I should see "Mike" in team list as "Reporter"
-
- @javascript
- Scenario: Ignore add user to group when is already Owner
- Given gitlab user "Mike"
- When I visit group "Owned" members page
- When I select "Mike" as "Reporter"
- Then I should see "Mike" in team list as "Owner"
-
- @javascript
- Scenario: Invite user to group
- When I visit group "Owned" members page
- When I select "sjobs@apple.com" as "Reporter"
- Then I should see "sjobs@apple.com" in team list as invited "Reporter"
-
- @javascript
- Scenario: Edit group member permissions
- Given "Mary Jane" is guest of group "Owned"
- And I visit group "Owned" members page
- When I change the "Mary Jane" role to "Developer"
- Then I should see "Mary Jane" as "Developer"
-
# Leave
@javascript
diff --git a/features/project/team_management.feature b/features/project/team_management.feature
index 5888662fc3f..aed41924cd9 100644
--- a/features/project/team_management.feature
+++ b/features/project/team_management.feature
@@ -7,26 +7,6 @@ Feature: Project Team Management
And "Dmitriy" is "Shop" developer
And I visit project "Shop" team page
- Scenario: See all team members
- Then I should be able to see myself in team
- And I should see "Dmitriy" in team list
-
- @javascript
- Scenario: Add user to project
- When I select "Mike" as "Reporter"
- Then I should see "Mike" in team list as "Reporter"
-
- @javascript
- Scenario: Invite user to project
- When I select "sjobs@apple.com" as "Reporter"
- Then I should see "sjobs@apple.com" in team list as invited "Reporter"
-
- @javascript
- Scenario: Update user access
- Given I should see "Dmitriy" in team list as "Developer"
- And I change "Dmitriy" role to "Reporter"
- And I should see "Dmitriy" in team list as "Reporter"
-
Scenario: Cancel team member
Given I click cancel link for "Dmitriy"
Then I visit project "Shop" team page
diff --git a/features/steps/group/members.rb b/features/steps/group/members.rb
index adaf375453c..a2e29a72cff 100644
--- a/features/steps/group/members.rb
+++ b/features/steps/group/members.rb
@@ -4,71 +4,6 @@ class Spinach::Features::GroupMembers < Spinach::FeatureSteps
include SharedPaths
include SharedGroup
include SharedUser
- include Select2Helper
-
- step 'I select "Mike" as "Reporter"' do
- user = User.find_by(name: "Mike")
-
- page.within ".users-group-form" do
- select2(user.id, from: "#user_ids", multiple: true)
- select "Reporter", from: "access_level"
- end
-
- click_button "Add to group"
- end
-
- step 'I select "Mike" as "Master"' do
- user = User.find_by(name: "Mike")
-
- page.within ".users-group-form" do
- select2(user.id, from: "#user_ids", multiple: true)
- select "Master", from: "access_level"
- end
-
- click_button "Add to group"
- end
-
- step 'I should see "Mike" in team list as "Reporter"' do
- page.within '.content-list' do
- expect(page).to have_content('Mike')
- expect(page).to have_content('Reporter')
- end
- end
-
- step 'I should see "Mike" in team list as "Owner"' do
- page.within '.content-list' do
- expect(page).to have_content('Mike')
- expect(page).to have_content('Owner')
- end
- end
-
- step 'I select "sjobs@apple.com" as "Reporter"' do
- page.within ".users-group-form" do
- select2("sjobs@apple.com", from: "#user_ids", multiple: true)
- select "Reporter", from: "access_level"
- end
-
- click_button "Add to group"
- end
-
- step 'I should see "sjobs@apple.com" in team list as invited "Reporter"' do
- page.within '.content-list' do
- expect(page).to have_content('sjobs@apple.com')
- expect(page).to have_content('Invited')
- expect(page).to have_content('Reporter')
- end
- end
-
- step 'I select user "Mary Jane" from list with role "Reporter"' do
- user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
-
- page.within ".users-group-form" do
- select2(user.id, from: "#user_ids", multiple: true)
- select "Reporter", from: "access_level"
- end
-
- click_button "Add to group"
- end
step 'I should see user "John Doe" in team list' do
expect(group_members_list).to have_content("John Doe")
diff --git a/features/steps/project/team_management.rb b/features/steps/project/team_management.rb
index 6986c7ede56..ff4c9deee2a 100644
--- a/features/steps/project/team_management.rb
+++ b/features/steps/project/team_management.rb
@@ -4,25 +4,10 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
include SharedPaths
include Select2Helper
- step 'I should be able to see myself in team' do
- expect(page).to have_content(@user.name)
- expect(page).to have_content(@user.username)
- end
-
- step 'I should see "Dmitriy" in team list' do
+ step 'I should not see "Dmitriy" in team list' do
user = User.find_by(name: "Dmitriy")
- expect(page).to have_content(user.name)
- expect(page).to have_content(user.username)
- end
-
- step 'I select "Mike" as "Reporter"' do
- user = User.find_by(name: "Mike")
-
- page.within ".users-project-form" do
- select2(user.id, from: "#user_ids", multiple: true)
- select "Reporter", from: "access_level"
- end
- click_button "Add to project"
+ expect(page).not_to have_content(user.name)
+ expect(page).not_to have_content(user.username)
end
step 'I should see "Mike" in team list as "Reporter"' do
@@ -34,60 +19,6 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
end
end
- step 'I select "sjobs@apple.com" as "Reporter"' do
- page.within ".users-project-form" do
- find('#user_ids', visible: false).set('sjobs@apple.com')
- select "Reporter", from: "access_level"
- end
- click_button "Add to project"
- end
-
- step 'I should see "sjobs@apple.com" in team list as invited "Reporter"' do
- project_member = project.project_members.find_by(invite_email: 'sjobs@apple.com')
- page.within "#project_member_#{project_member.id}" do
- expect(page).to have_content('sjobs@apple.com')
- expect(page).to have_content('Invited')
- expect(page).to have_content('Reporter')
- end
- end
-
- step 'I should see "Dmitriy" in team list as "Developer"' do
- user = User.find_by(name: 'Dmitriy')
- project_member = project.project_members.find_by(user_id: user.id)
- page.within "#project_member_#{project_member.id}" do
- expect(page).to have_content('Dmitriy')
- expect(page).to have_content('Developer')
- end
- end
-
- step 'I change "Dmitriy" role to "Reporter"' do
- project = Project.find_by(name: "Shop")
- user = User.find_by(name: 'Dmitriy')
- project_member = project.project_members.find_by(user_id: user.id)
- page.within "#project_member_#{project_member.id}" do
- click_button project_member.human_access
-
- page.within '.dropdown-menu' do
- click_link 'Reporter'
- end
- end
- end
-
- step 'I should see "Dmitriy" in team list as "Reporter"' do
- user = User.find_by(name: 'Dmitriy')
- project_member = project.project_members.find_by(user_id: user.id)
- page.within "#project_member_#{project_member.id}" do
- expect(page).to have_content('Dmitriy')
- expect(page).to have_content('Reporter')
- end
- end
-
- step 'I should not see "Dmitriy" in team list' do
- user = User.find_by(name: "Dmitriy")
- expect(page).not_to have_content(user.name)
- expect(page).not_to have_content(user.username)
- end
-
step 'gitlab user "Mike"' do
create(:user, name: "Mike")
end
@@ -113,7 +44,7 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
project.team << [user, :reporter]
end
- step 'I click link "Import team from another project"' do
+ step 'I click link "Import team from another project"' do
page.within '.users-project-form' do
click_link "Import"
end
diff --git a/spec/features/groups/members/list_spec.rb b/spec/features/groups/members/list_spec.rb
index 14c193f7450..543879bd21d 100644
--- a/spec/features/groups/members/list_spec.rb
+++ b/spec/features/groups/members/list_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
feature 'Groups members list', feature: true do
+ include Select2Helper
+
let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') }
let(:group) { create(:group) }
@@ -30,7 +32,7 @@ feature 'Groups members list', feature: true do
expect(second_row).to be_blank
end
- it 'updates user to owner level', :js do
+ scenario 'update user to owner level', :js do
group.add_owner(user1)
group.add_developer(user2)
@@ -38,13 +40,52 @@ feature 'Groups members list', feature: true do
page.within(second_row) do
click_button('Developer')
-
click_link('Owner')
expect(page).to have_button('Owner')
end
end
+ scenario 'add user to group', :js do
+ group.add_owner(user1)
+
+ visit group_group_members_path(group)
+
+ add_user(user2.id, 'Reporter')
+
+ page.within(second_row) do
+ expect(page).to have_content(user2.name)
+ expect(page).to have_button('Reporter')
+ end
+ end
+
+ scenario 'add yourself to group when already an owner', :js do
+ group.add_owner(user1)
+
+ visit group_group_members_path(group)
+
+ add_user(user1.id, 'Reporter')
+
+ page.within(first_row) do
+ expect(page).to have_content(user1.name)
+ expect(page).to have_content('Owner')
+ end
+ end
+
+ scenario 'invite user to group', :js do
+ group.add_owner(user1)
+
+ visit group_group_members_path(group)
+
+ add_user('test@example.com', 'Reporter')
+
+ page.within(second_row) do
+ expect(page).to have_content('test@example.com')
+ expect(page).to have_content('Invited')
+ expect(page).to have_button('Reporter')
+ end
+ end
+
def first_row
page.all('ul.content-list > li')[0]
end
@@ -52,4 +93,13 @@ feature 'Groups members list', feature: true do
def second_row
page.all('ul.content-list > li')[1]
end
+
+ def add_user(id, role)
+ page.within ".users-group-form" do
+ select2(id, from: "#user_ids", multiple: true)
+ select(role, from: "access_level")
+ end
+
+ click_button "Add to group"
+ end
end
diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb
new file mode 100644
index 00000000000..deea34214fb
--- /dev/null
+++ b/spec/features/projects/members/list_spec.rb
@@ -0,0 +1,90 @@
+require 'spec_helper'
+
+feature 'Project members list', feature: true do
+ include Select2Helper
+
+ let(:user1) { create(:user, name: 'John Doe') }
+ let(:user2) { create(:user, name: 'Mary Jane') }
+ let(:group) { create(:group) }
+ let(:project) { create(:project, namespace: group) }
+
+ background do
+ login_as(user1)
+ group.add_owner(user1)
+ end
+
+ scenario 'show members from project and group' do
+ project.add_developer(user2)
+
+ visit_members_page
+
+ expect(first_row.text).to include(user1.name)
+ expect(second_row.text).to include(user2.name)
+ end
+
+ scenario 'show user once if member of both group and project' do
+ project.add_developer(user1)
+
+ visit_members_page
+
+ expect(first_row.text).to include(user1.name)
+ expect(second_row).to be_blank
+ end
+
+ scenario 'update user acess level', :js do
+ project.add_developer(user2)
+
+ visit_members_page
+
+ page.within(second_row) do
+ click_button('Developer')
+ click_link('Reporter')
+
+ expect(page).to have_button('Reporter')
+ end
+ end
+
+ scenario 'add user to project', :js do
+ visit_members_page
+
+ add_user(user2.id, 'Reporter')
+
+ page.within(second_row) do
+ expect(page).to have_content(user2.name)
+ expect(page).to have_button('Reporter')
+ end
+ end
+
+ scenario 'invite user to project', :js do
+ visit_members_page
+
+ add_user('test@example.com', 'Reporter')
+
+ page.within(second_row) do
+ expect(page).to have_content('test@example.com')
+ expect(page).to have_content('Invited')
+ expect(page).to have_button('Reporter')
+ end
+ end
+
+ def first_row
+ page.all('ul.content-list > li')[0]
+ end
+
+ def second_row
+ page.all('ul.content-list > li')[1]
+ end
+
+ def add_user(id, role)
+ page.within ".users-project-form" do
+ select2(id, from: "#user_ids", multiple: true)
+ select(role, from: "access_level")
+ end
+
+ click_button "Add to project"
+ end
+
+ def visit_members_page
+ visit namespace_project_settings_members_path(project.namespace, project)
+ end
+end