Commit 25c57637807bac79037c4d791979951bf13ed056
1 parent
9c574464
Exists in
master
and in
4 other branches
Add functional in user section
Showing
7 changed files
with
59 additions
and
1 deletions
Show diff stats
app/controllers/groups_controller.rb
| ... | ... | @@ -53,9 +53,18 @@ class GroupsController < ApplicationController |
| 53 | 53 | |
| 54 | 54 | if @project |
| 55 | 55 | @team_member = @project.users_projects.new |
| 56 | + else | |
| 57 | + @team_member = UsersProject.new | |
| 56 | 58 | end |
| 57 | 59 | end |
| 58 | 60 | |
| 61 | + def team_members | |
| 62 | + @group.projects.each do |p| | |
| 63 | + p.add_users_ids_to_team(params[:user_ids], params[:project_access]) | |
| 64 | + end | |
| 65 | + redirect_to people_group_path(@group), notice: 'Users was successfully added.' | |
| 66 | + end | |
| 67 | + | |
| 59 | 68 | protected |
| 60 | 69 | |
| 61 | 70 | def group | ... | ... |
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | += form_for @team_member, as: :team_member, url: team_members_group_path(@group, @team_member) do |f| | |
| 2 | + %fieldset | |
| 3 | + %legend= "New Team member(s) for projects in #{@group.name}" | |
| 4 | + | |
| 5 | + %h6 1. Choose people you want in the team | |
| 6 | + .clearfix | |
| 7 | + = f.label :user_ids, "People" | |
| 8 | + .input= select_tag(:user_ids, options_from_collection_for_select(User.active, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) | |
| 9 | + | |
| 10 | + %h6 2. Set access level for them | |
| 11 | + .clearfix | |
| 12 | + = f.label :project_access, "Project Access" | |
| 13 | + .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select chosen" | |
| 14 | + | |
| 15 | + .form-actions | |
| 16 | + = hidden_field_tag :redirect_to, people_group_path(@group) | |
| 17 | + = f.submit 'Add', class: "btn save-btn" | |
| 18 | + | ... | ... |
app/views/groups/people.html.haml
config/routes.rb
features/group/group.feature
| ... | ... | @@ -17,3 +17,10 @@ Feature: Groups |
| 17 | 17 | Given project from group has merge requests assigned to me |
| 18 | 18 | When I visit group merge requests page |
| 19 | 19 | Then I should see merge requests from this group assigned to me |
| 20 | + | |
| 21 | + Scenario: I should add user to projects in Group | |
| 22 | + Given I have new user "John" | |
| 23 | + When I visit group page | |
| 24 | + When I visit group people page | |
| 25 | + When I select user "John" from list with role "Reporter" | |
| 26 | + Then I should see user "John" in team list | ... | ... |
features/steps/group/group.rb
| ... | ... | @@ -32,6 +32,25 @@ class Groups < Spinach::FeatureSteps |
| 32 | 32 | end |
| 33 | 33 | end |
| 34 | 34 | |
| 35 | + Given 'I have new user "John"' do | |
| 36 | + create(:user, name: "John") | |
| 37 | + end | |
| 38 | + | |
| 39 | + When 'I select user "John" from list with role "Reporter"' do | |
| 40 | + user = User.find_by_name("John") | |
| 41 | + within "#new_team_member" do | |
| 42 | + select user.name, :from => "user_ids" | |
| 43 | + select "Reporter", :from => "project_access" | |
| 44 | + end | |
| 45 | + click_button "Add" | |
| 46 | + end | |
| 47 | + | |
| 48 | + Then 'I should see user "John" in team list' do | |
| 49 | + user = User.find_by_name("John") | |
| 50 | + projects_with_access = find(".ui-box .well-list li") | |
| 51 | + projects_with_access.should have_content("John") | |
| 52 | + end | |
| 53 | + | |
| 35 | 54 | Given 'project from group has issues assigned to me' do |
| 36 | 55 | create :issue, |
| 37 | 56 | project: project, | ... | ... |
features/steps/shared/paths.rb
| ... | ... | @@ -21,6 +21,10 @@ module SharedPaths |
| 21 | 21 | visit merge_requests_group_path(current_group) |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | + When 'I visit group people page' do | |
| 25 | + visit people_group_path(current_group) | |
| 26 | + end | |
| 27 | + | |
| 24 | 28 | # ---------------------------------------- |
| 25 | 29 | # Dashboard |
| 26 | 30 | # ---------------------------------------- | ... | ... |