summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kumanyaev <me@zzet.org>2012-12-26 02:52:49 +0400
committerAndrey Kumanyaev <me@zzet.org>2012-12-26 19:52:15 +0400
commit25c57637807bac79037c4d791979951bf13ed056 (patch)
tree131a592a32b3e580bdc2859c9aef7ea486f2af40
parent9c574464a6051536ee83a93e8270a7dd9d85da33 (diff)
downloadgitlab-ce-25c57637807bac79037c4d791979951bf13ed056.tar.gz
Add functional in user section
-rw-r--r--app/controllers/groups_controller.rb9
-rw-r--r--app/views/groups/_new_group_member.html.haml18
-rw-r--r--app/views/groups/people.html.haml2
-rw-r--r--config/routes.rb1
-rw-r--r--features/group/group.feature7
-rw-r--r--features/steps/group/group.rb19
-rw-r--r--features/steps/shared/paths.rb4
7 files changed, 59 insertions, 1 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index c82edb4c168..1b16d706c1e 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -53,9 +53,18 @@ class GroupsController < ApplicationController
if @project
@team_member = @project.users_projects.new
+ else
+ @team_member = UsersProject.new
end
end
+ def team_members
+ @group.projects.each do |p|
+ p.add_users_ids_to_team(params[:user_ids], params[:project_access])
+ end
+ redirect_to people_group_path(@group), notice: 'Users was successfully added.'
+ end
+
protected
def group
diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml
new file mode 100644
index 00000000000..b4fc07d2ae9
--- /dev/null
+++ b/app/views/groups/_new_group_member.html.haml
@@ -0,0 +1,18 @@
+= form_for @team_member, as: :team_member, url: team_members_group_path(@group, @team_member) do |f|
+ %fieldset
+ %legend= "New Team member(s) for projects in #{@group.name}"
+
+ %h6 1. Choose people you want in the team
+ .clearfix
+ = f.label :user_ids, "People"
+ .input= select_tag(:user_ids, options_from_collection_for_select(User.active, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true})
+
+ %h6 2. Set access level for them
+ .clearfix
+ = f.label :project_access, "Project Access"
+ .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen"
+
+ .form-actions
+ = hidden_field_tag :redirect_to, people_group_path(@group)
+ = f.submit 'Add', class: "btn save-btn"
+
diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml
index be3dd7a4d78..6965f835629 100644
--- a/app/views/groups/people.html.haml
+++ b/app/views/groups/people.html.haml
@@ -17,4 +17,4 @@
%span.cgray= user.email
- if @group.owner == user
%span.btn.btn-small.disabled.right Group Owner
-
+ = render "new_group_member"
diff --git a/config/routes.rb b/config/routes.rb
index 659d1a04b55..90ae2514e63 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -103,6 +103,7 @@ Gitlab::Application.routes.draw do
get :merge_requests
get :search
get :people
+ put :team_members
end
end
diff --git a/features/group/group.feature b/features/group/group.feature
index 07308112270..4b8483bd361 100644
--- a/features/group/group.feature
+++ b/features/group/group.feature
@@ -17,3 +17,10 @@ Feature: Groups
Given project from group has merge requests assigned to me
When I visit group merge requests page
Then I should see merge requests from this group assigned to me
+
+ Scenario: I should add user to projects in Group
+ Given I have new user "John"
+ When I visit group page
+ When I visit group people page
+ When I select user "John" from list with role "Reporter"
+ Then I should see user "John" in team list
diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb
index 4de260ec33e..03693852072 100644
--- a/features/steps/group/group.rb
+++ b/features/steps/group/group.rb
@@ -32,6 +32,25 @@ class Groups < Spinach::FeatureSteps
end
end
+ Given 'I have new user "John"' do
+ create(:user, name: "John")
+ end
+
+ When 'I select user "John" from list with role "Reporter"' do
+ user = User.find_by_name("John")
+ within "#new_team_member" do
+ select user.name, :from => "user_ids"
+ select "Reporter", :from => "project_access"
+ end
+ click_button "Add"
+ end
+
+ Then 'I should see user "John" in team list' do
+ user = User.find_by_name("John")
+ projects_with_access = find(".ui-box .well-list li")
+ projects_with_access.should have_content("John")
+ end
+
Given 'project from group has issues assigned to me' do
create :issue,
project: project,
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index a12576288df..bd43ba6b3dc 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -21,6 +21,10 @@ module SharedPaths
visit merge_requests_group_path(current_group)
end
+ When 'I visit group people page' do
+ visit people_group_path(current_group)
+ end
+
# ----------------------------------------
# Dashboard
# ----------------------------------------