diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-20 14:36:21 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-04-20 14:36:21 +0000 |
commit | d39bcf8c7ed2f6391952a8aec984c9d13752a059 (patch) | |
tree | 97732b431fbc80b0afbb2c05da5167ca3f27730a /spec | |
parent | cc9e92a07646a2e8a193d58c1c24e837195d5a98 (diff) | |
parent | 5f087604826229af1dbd79a9a549d5e7da9c2908 (diff) | |
download | gitlab-ce-d39bcf8c7ed2f6391952a8aec984c9d13752a059.tar.gz |
Merge branch 'dz-refactor-create-members' into 'master'
Refactor code that creates and destroys project/group members
See merge request !10735
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/project_members_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/groups/members/list_spec.rb | 54 | ||||
-rw-r--r-- | spec/features/projects/members/list_spec.rb | 90 |
3 files changed, 144 insertions, 4 deletions
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 416eaa0037e..a4b4392d7cc 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -55,7 +55,7 @@ describe Projects::ProjectMembersController do user_ids: '', access_level: Gitlab::Access::GUEST - expect(response).to set_flash.to 'No users or groups specified.' + expect(response).to set_flash.to 'No users specified.' expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project)) end end @@ -225,7 +225,7 @@ describe Projects::ProjectMembersController do id: member expect(response).to redirect_to( - namespace_project_project_members_path(project.namespace, project) + namespace_project_settings_members_path(project.namespace, project) ) expect(project.members).to include member 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 |