Commit 695becc4cb017d76329efb55aae7ddb9a208895b
Committed by
Dmitriy Zaporozhets
1 parent
82499a4c
Exists in
master
and in
4 other branches
Add teams into Public sections
Showing
14 changed files
with
706 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,113 @@ |
| 1 | +class TeamsController < ApplicationController | |
| 2 | + respond_to :html | |
| 3 | + layout 'user_team', only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] | |
| 4 | + | |
| 5 | + before_filter :user_team, only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] | |
| 6 | + before_filter :projects, only: [:show, :edit, :update, :destroy, :issues, :merge_requests, :search] | |
| 7 | + | |
| 8 | + # Authorize | |
| 9 | + before_filter :authorize_manage_user_team!, only: [:edit, :update] | |
| 10 | + before_filter :authorize_admin_user_team!, only: [:destroy] | |
| 11 | + | |
| 12 | + def index | |
| 13 | + @teams = UserTeam.all | |
| 14 | + end | |
| 15 | + | |
| 16 | + def show | |
| 17 | + @events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0) | |
| 18 | + | |
| 19 | + respond_to do |format| | |
| 20 | + format.html | |
| 21 | + format.js | |
| 22 | + format.atom { render layout: false } | |
| 23 | + end | |
| 24 | + end | |
| 25 | + | |
| 26 | + def edit | |
| 27 | + | |
| 28 | + end | |
| 29 | + | |
| 30 | + def update | |
| 31 | + if user_team.update_attributes(params[:user_team]) | |
| 32 | + redirect_to team_path(user_team) | |
| 33 | + else | |
| 34 | + render action: :edit | |
| 35 | + end | |
| 36 | + end | |
| 37 | + | |
| 38 | + def destroy | |
| 39 | + user_team.destroy | |
| 40 | + redirect_to teams_path | |
| 41 | + end | |
| 42 | + | |
| 43 | + def new | |
| 44 | + @team = UserTeam.new | |
| 45 | + end | |
| 46 | + | |
| 47 | + def create | |
| 48 | + @team = UserTeam.new(params[:user_team]) | |
| 49 | + @team.owner = current_user unless params[:owner] | |
| 50 | + @team.path = @team.name.dup.parameterize if @team.name | |
| 51 | + | |
| 52 | + if @team.save | |
| 53 | + redirect_to team_path(@team) | |
| 54 | + else | |
| 55 | + render action: :new | |
| 56 | + end | |
| 57 | + end | |
| 58 | + | |
| 59 | + # Get authored or assigned open merge requests | |
| 60 | + def merge_requests | |
| 61 | + @merge_requests = MergeRequest.of_user_team(@user_team) | |
| 62 | + @merge_requests = FilterContext.new(@merge_requests, params).execute | |
| 63 | + @merge_requests = @merge_requests.recent.page(params[:page]).per(20) | |
| 64 | + end | |
| 65 | + | |
| 66 | + # Get only assigned issues | |
| 67 | + def issues | |
| 68 | + @issues = Issue.of_user_team(@user_team) | |
| 69 | + @issues = FilterContext.new(@issues, params).execute | |
| 70 | + @issues = @issues.recent.page(params[:page]).per(20) | |
| 71 | + @issues = @issues.includes(:author, :project) | |
| 72 | + | |
| 73 | + respond_to do |format| | |
| 74 | + format.html | |
| 75 | + format.atom { render layout: false } | |
| 76 | + end | |
| 77 | + end | |
| 78 | + | |
| 79 | + def search | |
| 80 | + result = SearchContext.new(project_ids, params).execute | |
| 81 | + | |
| 82 | + @projects = result[:projects] | |
| 83 | + @merge_requests = result[:merge_requests] | |
| 84 | + @issues = result[:issues] | |
| 85 | + @wiki_pages = result[:wiki_pages] | |
| 86 | + end | |
| 87 | + | |
| 88 | + protected | |
| 89 | + | |
| 90 | + def user_team | |
| 91 | + @user_team ||= UserTeam.find_by_path(params[:id]) | |
| 92 | + end | |
| 93 | + | |
| 94 | + def projects | |
| 95 | + @projects ||= user_team.projects.sorted_by_activity | |
| 96 | + end | |
| 97 | + | |
| 98 | + def project_ids | |
| 99 | + projects.map(&:id) | |
| 100 | + end | |
| 101 | + | |
| 102 | + def authorize_manage_user_team! | |
| 103 | + unless user_team.present? or can?(current_user, :manage_user_team, user_team) | |
| 104 | + return render_404 | |
| 105 | + end | |
| 106 | + end | |
| 107 | + | |
| 108 | + def authorize_admin_user_team! | |
| 109 | + unless user_team.owner == current_user || current_user.admin? | |
| 110 | + return render_404 | |
| 111 | + end | |
| 112 | + end | |
| 113 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | += form_tag team_filter_path(entity), method: 'get' do | |
| 2 | + %fieldset.dashboard-search-filter | |
| 3 | + = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'search-text-input' } | |
| 4 | + = button_tag type: 'submit', class: 'btn' do | |
| 5 | + %i.icon-search | |
| 6 | + | |
| 7 | + %fieldset | |
| 8 | + %legend Status: | |
| 9 | + %ul.nav.nav-pills.nav-stacked | |
| 10 | + %li{class: ("active" if !params[:status])} | |
| 11 | + = link_to team_filter_path(entity, status: nil) do | |
| 12 | + Open | |
| 13 | + %li{class: ("active" if params[:status] == 'closed')} | |
| 14 | + = link_to team_filter_path(entity, status: 'closed') do | |
| 15 | + Closed | |
| 16 | + %li{class: ("active" if params[:status] == 'all')} | |
| 17 | + = link_to team_filter_path(entity, status: 'all') do | |
| 18 | + All | |
| 19 | + | |
| 20 | + %fieldset | |
| 21 | + %legend Projects: | |
| 22 | + %ul.nav.nav-pills.nav-stacked | |
| 23 | + - @projects.each do |project| | |
| 24 | + - unless entities_per_project(project, entity).zero? | |
| 25 | + %li{class: ("active" if params[:project_id] == project.id.to_s)} | |
| 26 | + = link_to team_filter_path(entity, project_id: project.id) do | |
| 27 | + = project.name_with_namespace | |
| 28 | + %small.right= entities_per_project(project, entity) | |
| 29 | + | |
| 30 | + %fieldset | |
| 31 | + %hr | |
| 32 | + = link_to "Reset", team_filter_path(entity), class: 'btn right' | |
| 33 | + | ... | ... |
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +.projects_box | |
| 2 | + %h5.title | |
| 3 | + Projects | |
| 4 | + %small | |
| 5 | + (#{projects.count}) | |
| 6 | + - if can? current_user, :manage_group, @group | |
| 7 | + %span.right | |
| 8 | + = link_to new_project_path(namespace_id: @group.id), class: "btn very_small info" do | |
| 9 | + %i.icon-plus | |
| 10 | + New Project | |
| 11 | + %ul.well-list | |
| 12 | + - if projects.blank? | |
| 13 | + %p.nothing_here_message This groups has no projects yet | |
| 14 | + - projects.each do |project| | |
| 15 | + %li | |
| 16 | + = link_to project_path(project), class: dom_class(project) do | |
| 17 | + %strong.well-title= truncate(project.name, length: 25) | |
| 18 | + %span.arrow | |
| 19 | + → | |
| 20 | + %span.last_activity | |
| 21 | + %strong Last activity: | |
| 22 | + %span= project_last_activity(project) | ... | ... |
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +%ul.nav.nav-tabs | |
| 2 | + = nav_link(path: 'teams#show') do | |
| 3 | + = link_to team_path(@user_team), class: "activities-tab tab" do | |
| 4 | + %i.icon-home | |
| 5 | + Show | |
| 6 | + = nav_link(controller: [:members]) do | |
| 7 | + = link_to team_members_path(@user_team), class: "team-tab tab" do | |
| 8 | + %i.icon-user | |
| 9 | + Members | |
| 10 | + = nav_link(controller: [:projects]) do | |
| 11 | + = link_to team_projects_path(@user_team), class: "team-tab tab" do | |
| 12 | + %i.icon-briefcase | |
| 13 | + Projects | |
| 14 | + | |
| 15 | + - if can? current_user, :manage_user_team, @user_team | |
| 16 | + = nav_link(path: 'teams#edit', html_options: {class: 'right'}) do | |
| 17 | + = link_to edit_team_path(@user_team), class: "stat-tab tab " do | |
| 18 | + %i.icon-edit | |
| 19 | + Edit | ... | ... |
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | += render "team_head" | |
| 2 | + | |
| 3 | +%h3.page_title= "Edit Team #{@user_team.name}" | |
| 4 | +%hr | |
| 5 | += form_for @user_team, url: teams_path do |f| | |
| 6 | + - if @user_team.errors.any? | |
| 7 | + .alert-message.block-message.error | |
| 8 | + %span= @user_team.errors.full_messages.first | |
| 9 | + .clearfix | |
| 10 | + = f.label :name do | |
| 11 | + Team name is | |
| 12 | + .input | |
| 13 | + = f.text_field :name, placeholder: "Ex. OpenSource", class: "xxlarge left" | |
| 14 | + | |
| 15 | + .clearfix | |
| 16 | + = f.label :path do | |
| 17 | + Team path is | |
| 18 | + .input | |
| 19 | + = f.text_field :path, placeholder: "opensource", class: "xxlarge left" | |
| 20 | + .clearfix | |
| 21 | + .input.span3.center | |
| 22 | + = f.submit 'Save team changes', class: "btn primary" | |
| 23 | + .input.span3.center | |
| 24 | + = link_to 'Delete team', team_path(@user_team), method: :delete, confirm: "You are shure?", class: "btn danger" | |
| 25 | + %hr | |
| 26 | + .padded | |
| 27 | + %ul | |
| 28 | + %li Team is kind of directory for several projects | |
| 29 | + %li All created teams are private | |
| 30 | + %li People within a team see only projects they have access to | |
| 31 | + %li All projects of team will be stored in team directory | |
| 32 | + %li You will be able to move existing projects into team | ... | ... |
| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | +%h3.page_title | |
| 2 | + Teams | |
| 3 | + %small | |
| 4 | + list of all teams | |
| 5 | + | |
| 6 | + = link_to 'New Team', new_team_path, class: "btn small right" | |
| 7 | + %br | |
| 8 | + | |
| 9 | += form_tag search_teams_path, method: :get, class: 'form-inline' do | |
| 10 | + = text_field_tag :name, params[:name], class: "xlarge" | |
| 11 | + = submit_tag "Search", class: "btn submit primary" | |
| 12 | + | |
| 13 | +%table.teams_list | |
| 14 | + %thead | |
| 15 | + %tr | |
| 16 | + %th | |
| 17 | + Name | |
| 18 | + %i.icon-sort-down | |
| 19 | + %th Path | |
| 20 | + %th Projects | |
| 21 | + %th Members | |
| 22 | + %th Owner | |
| 23 | + %th | |
| 24 | + | |
| 25 | + - @teams.each do |team| | |
| 26 | + %tr | |
| 27 | + %td | |
| 28 | + %strong= link_to team.name, team_path(team) | |
| 29 | + %td= team.path | |
| 30 | + %td= link_to team.projects.count, team_projects_path(team) | |
| 31 | + %td= link_to team.members.count, team_members_path(team) | |
| 32 | + %td= link_to team.owner.name, team_member_path(team, team.owner) | |
| 33 | + %td | |
| 34 | + - if current_user.can?(:manage_user_team, team) | |
| 35 | + - if team.owner == current_user | |
| 36 | + = link_to "Destroy", team_path(team), method: :delete, confirm: "You are shure?", class: "danger btn small right" | |
| 37 | + = link_to "Edit", edit_team_path(team), class: "btn small right" | ... | ... |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | += render "team_head" | |
| 2 | + | |
| 3 | +%h3.page_title | |
| 4 | + Issues | |
| 5 | + %small (in Team projects assigned to Team members) | |
| 6 | + %small.right #{@issues.total_count} issues | |
| 7 | + | |
| 8 | +%hr | |
| 9 | +.row | |
| 10 | + .span3 | |
| 11 | + = render 'filter', entity: 'issue' | |
| 12 | + .span9 | |
| 13 | + - if @issues.any? | |
| 14 | + - @issues.group_by(&:project).each do |group| | |
| 15 | + %div.ui-box | |
| 16 | + - @project = group[0] | |
| 17 | + %h5.title | |
| 18 | + = link_to_project @project | |
| 19 | + %ul.well-list.issues_table | |
| 20 | + - group[1].each do |issue| | |
| 21 | + = render(partial: 'issues/show', locals: {issue: issue}) | |
| 22 | + %hr | |
| 23 | + = paginate @issues, theme: "gitlab" | |
| 24 | + - else | |
| 25 | + %p.nothing_here_message Nothing to show here | ... | ... |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +%h3.page_title | |
| 2 | + Merge Requests | |
| 3 | + %small (authored by or assigned to Team members) | |
| 4 | + %small.right #{@merge_requests.total_count} merge requests | |
| 5 | + | |
| 6 | +%hr | |
| 7 | +.row | |
| 8 | + .span3 | |
| 9 | + = render 'filter', entity: 'merge_request' | |
| 10 | + .span9 | |
| 11 | + - if @merge_requests.any? | |
| 12 | + - @merge_requests.group_by(&:project).each do |group| | |
| 13 | + .ui-box | |
| 14 | + - @project = group[0] | |
| 15 | + %h5.title | |
| 16 | + = link_to_project @project | |
| 17 | + %ul.well-list | |
| 18 | + - group[1].each do |merge_request| | |
| 19 | + = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) | |
| 20 | + %hr | |
| 21 | + = paginate @merge_requests, theme: "gitlab" | |
| 22 | + | |
| 23 | + - else | |
| 24 | + %h3.nothing_here_message Nothing to show here | ... | ... |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +%h3.page_title New Team | |
| 2 | +%hr | |
| 3 | += form_for @team, url: teams_path do |f| | |
| 4 | + - if @team.errors.any? | |
| 5 | + .alert-message.block-message.error | |
| 6 | + %span= @team.errors.full_messages.first | |
| 7 | + .clearfix | |
| 8 | + = f.label :name do | |
| 9 | + Team name is | |
| 10 | + .input | |
| 11 | + = f.text_field :name, placeholder: "Ex. OpenSource", class: "xxlarge left" | |
| 12 | + | |
| 13 | + = f.submit 'Create team', class: "btn primary" | |
| 14 | + %hr | |
| 15 | + .padded | |
| 16 | + %ul | |
| 17 | + %li Team is kind of directory for several projects | |
| 18 | + %li All created teams are private | |
| 19 | + %li People within a team see only projects they have access to | |
| 20 | + %li All projects of team will be stored in team directory | |
| 21 | + %li You will be able to move existing projects into team | ... | ... |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | += render "team_head" | |
| 2 | + | |
| 3 | += form_tag search_team_path(@user_team), method: :get, class: 'form-inline' do |f| | |
| 4 | + .padded | |
| 5 | + = label_tag :search do | |
| 6 | + %strong Looking for | |
| 7 | + .input | |
| 8 | + = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" | |
| 9 | + = submit_tag 'Search', class: "btn primary wide" | |
| 10 | +- if params[:search].present? | |
| 11 | + = render 'search/result' | ... | ... |
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | += render "team_head" | |
| 2 | + | |
| 3 | +.projects | |
| 4 | + .activities.span8 | |
| 5 | + = link_to dashboard_path, class: 'btn very_small' do | |
| 6 | + ← To dashboard | |
| 7 | + | |
| 8 | + %span.cgray Events and projects are filtered in scope of team | |
| 9 | + %hr | |
| 10 | + - if @events.any? | |
| 11 | + .content_list | |
| 12 | + - else | |
| 13 | + %p.nothing_here_message Projects activity will be displayed here | |
| 14 | + .loading.hide | |
| 15 | + .side.span4 | |
| 16 | + = render "projects", projects: @projects | |
| 17 | + %div | |
| 18 | + %span.rss-icon | |
| 19 | + = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do | |
| 20 | + = image_tag "rss_ui.png", title: "feed" | |
| 21 | + %strong News Feed | |
| 22 | + | |
| 23 | + %hr | |
| 24 | + .gitlab-promo | |
| 25 | + = link_to "Homepage", "http://gitlabhq.com" | |
| 26 | + = link_to "Blog", "http://blog.gitlabhq.com" | |
| 27 | + = link_to "@gitlabhq", "https://twitter.com/gitlabhq" | |
| 28 | + | |
| 29 | +:javascript | |
| 30 | + $(function(){ Pager.init(20, true); }); | ... | ... |
config/routes.rb
| ... | ... | @@ -130,6 +130,20 @@ Gitlab::Application.routes.draw do |
| 130 | 130 | end |
| 131 | 131 | end |
| 132 | 132 | |
| 133 | + resources :teams do | |
| 134 | + member do | |
| 135 | + get :issues | |
| 136 | + get :merge_requests | |
| 137 | + get :search | |
| 138 | + post :delegate_projects | |
| 139 | + delete :relegate_project | |
| 140 | + put :update_access | |
| 141 | + end | |
| 142 | + collection do | |
| 143 | + get :search | |
| 144 | + end | |
| 145 | + end | |
| 146 | + | |
| 133 | 147 | resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] |
| 134 | 148 | |
| 135 | 149 | devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations } | ... | ... |
| ... | ... | @@ -0,0 +1,250 @@ |
| 1 | +class Userteams < Spinach::FeatureSteps | |
| 2 | + include SharedAuthentication | |
| 3 | + include SharedPaths | |
| 4 | + include SharedProject | |
| 5 | + | |
| 6 | + When 'I do not have teams with me' do | |
| 7 | + UserTeam.with_member(current_user).destroy_all | |
| 8 | + end | |
| 9 | + | |
| 10 | + Then 'I should see dashboard page without teams info block' do | |
| 11 | + page.has_no_css?(".teams_box").must_equal true | |
| 12 | + end | |
| 13 | + | |
| 14 | + When 'I have teams with my membership' do | |
| 15 | + team = create :user_team | |
| 16 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | |
| 17 | + end | |
| 18 | + | |
| 19 | + Then 'I should see dashboard page with teams information block' do | |
| 20 | + page.should have_css(".teams_box") | |
| 21 | + end | |
| 22 | + | |
| 23 | + When 'exist user teams' do | |
| 24 | + team = create :user_team | |
| 25 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | |
| 26 | + end | |
| 27 | + | |
| 28 | + And 'I click on "All teams" link' do | |
| 29 | + click_link("All Teams") | |
| 30 | + end | |
| 31 | + | |
| 32 | + Then 'I should see "All teams" page' do | |
| 33 | + current_path.should == teams_path | |
| 34 | + end | |
| 35 | + | |
| 36 | + And 'I should see exist teams in teams list' do | |
| 37 | + team = UserTeam.last | |
| 38 | + find_in_list(".teams_list tr", team).must_equal true | |
| 39 | + end | |
| 40 | + | |
| 41 | + When 'I click to "New team" link' do | |
| 42 | + click_link("New Team") | |
| 43 | + end | |
| 44 | + | |
| 45 | + And 'I submit form with new team info' do | |
| 46 | + fill_in 'name', with: 'gitlab' | |
| 47 | + click_button 'Create team' | |
| 48 | + end | |
| 49 | + | |
| 50 | + Then 'I should be redirected to new team page' do | |
| 51 | + team = UserTeam.last | |
| 52 | + current_path.should == team_path(team) | |
| 53 | + end | |
| 54 | + | |
| 55 | + When 'I have teams with projects and members' do | |
| 56 | + team = create :user_team | |
| 57 | + @project = create :project | |
| 58 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | |
| 59 | + team.assign_to_project(@project, UserTeam.access_roles["Master"]) | |
| 60 | + @event = create(:closed_issue_event, project: @project) | |
| 61 | + end | |
| 62 | + | |
| 63 | + When 'I visit team page' do | |
| 64 | + visit team_path(UserTeam.last) | |
| 65 | + end | |
| 66 | + | |
| 67 | + Then 'I should see projects list' do | |
| 68 | + page.should have_css(".projects_box") | |
| 69 | + projects_box = find(".projects_box") | |
| 70 | + projects_box.should have_content(@project.name) | |
| 71 | + end | |
| 72 | + | |
| 73 | + And 'project from team has issues assigned to me' do | |
| 74 | + team = UserTeam.last | |
| 75 | + team.projects.each do |project| | |
| 76 | + project.issues << create(:issue, assignee: current_user) | |
| 77 | + end | |
| 78 | + end | |
| 79 | + | |
| 80 | + When 'I visit team issues page' do | |
| 81 | + team = UserTeam.last | |
| 82 | + visit issues_team_path(team) | |
| 83 | + end | |
| 84 | + | |
| 85 | + Then 'I should see issues from this team assigned to me' do | |
| 86 | + team = UserTeam.last | |
| 87 | + team.projects.each do |project| | |
| 88 | + project.issues.assigned(current_user).each do |issue| | |
| 89 | + page.should have_content issue.title | |
| 90 | + end | |
| 91 | + end | |
| 92 | + end | |
| 93 | + | |
| 94 | + Given 'I have team with projects and members' do | |
| 95 | + team = create :user_team | |
| 96 | + project = create :project | |
| 97 | + user = create :user | |
| 98 | + team.add_member(current_user, UserTeam.access_roles["Master"], true) | |
| 99 | + team.add_member(user, UserTeam.access_roles["Developer"], false) | |
| 100 | + team.assign_to_project(project, UserTeam.access_roles["Master"]) | |
| 101 | + end | |
| 102 | + | |
| 103 | + Given 'project from team has issues assigned to teams members' do | |
| 104 | + team = UserTeam.last | |
| 105 | + team.projects.each do |project| | |
| 106 | + team.members.each do |member| | |
| 107 | + project.issues << create(:issue, assignee: member) | |
| 108 | + end | |
| 109 | + end | |
| 110 | + end | |
| 111 | + | |
| 112 | + Then 'I should see issues from this team assigned to teams members' do | |
| 113 | + team = UserTeam.last | |
| 114 | + team.projects.each do |project| | |
| 115 | + team.members.each do |member| | |
| 116 | + project.issues.assigned(member).each do |issue| | |
| 117 | + page.should have_content issue.title | |
| 118 | + end | |
| 119 | + end | |
| 120 | + end | |
| 121 | + end | |
| 122 | + | |
| 123 | + Given 'project from team has merge requests assigned to me' do | |
| 124 | + team = UserTeam.last | |
| 125 | + team.projects.each do |project| | |
| 126 | + team.members.each do |member| | |
| 127 | + 3.times { project.merge_requests << create(:merge_request, assignee: member) } | |
| 128 | + end | |
| 129 | + end | |
| 130 | + end | |
| 131 | + | |
| 132 | + When 'I visit team merge requests page' do | |
| 133 | + team = UserTeam.last | |
| 134 | + visit merge_requests_team_path(team) | |
| 135 | + end | |
| 136 | + | |
| 137 | + Then 'I should see merge requests from this team assigned to me' do | |
| 138 | + team = UserTeam.last | |
| 139 | + team.projects.each do |project| | |
| 140 | + team.members.each do |member| | |
| 141 | + project.issues.assigned(member).each do |merge_request| | |
| 142 | + page.should have_content merge_request.title | |
| 143 | + end | |
| 144 | + end | |
| 145 | + end | |
| 146 | + end | |
| 147 | + | |
| 148 | + Given 'project from team has merge requests assigned to team members' do | |
| 149 | + team = UserTeam.last | |
| 150 | + team.projects.each do |project| | |
| 151 | + team.members.each do |member| | |
| 152 | + 3.times { project.merge_requests << create(:merge_request, assignee: member) } | |
| 153 | + end | |
| 154 | + end | |
| 155 | + end | |
| 156 | + | |
| 157 | + Then 'I should see merge requests from this team assigned to me' do | |
| 158 | + team = UserTeam.last | |
| 159 | + team.projects.each do |project| | |
| 160 | + team.members.each do |member| | |
| 161 | + project.issues.assigned(member).each do |merge_request| | |
| 162 | + page.should have_content merge_request.title | |
| 163 | + end | |
| 164 | + end | |
| 165 | + end | |
| 166 | + end | |
| 167 | + | |
| 168 | + Given 'I have new user "John"' do | |
| 169 | + create :user, name: "John" | |
| 170 | + end | |
| 171 | + | |
| 172 | + When 'I visit team people page' do | |
| 173 | + team = UserTeam.last | |
| 174 | + visit team_members_path(team) | |
| 175 | + end | |
| 176 | + | |
| 177 | + And 'I select user "John" from list with role "Reporter"' do | |
| 178 | + pending 'step not implemented' | |
| 179 | + end | |
| 180 | + | |
| 181 | + Then 'I should see user "John" in team list' do | |
| 182 | + user = User.find_by_name("John") | |
| 183 | + team_members_list = find(".team-table") | |
| 184 | + team_members_list.should have_content user.name | |
| 185 | + end | |
| 186 | + | |
| 187 | + And 'I have my own project without teams' do | |
| 188 | + project = create :project, creator: current_user | |
| 189 | + end | |
| 190 | + | |
| 191 | + And 'I visit my team page' do | |
| 192 | + team = UserTeam.last | |
| 193 | + visit team_path(team) | |
| 194 | + end | |
| 195 | + | |
| 196 | + When 'I click on link "Projects"' do | |
| 197 | + click_link "Projects" | |
| 198 | + end | |
| 199 | + | |
| 200 | + Then 'I should see form with my own project in avaliable projects list' do | |
| 201 | + project = current_user.projects.first | |
| 202 | + projects_select = find("#project_ids") | |
| 203 | + projects_select.should have_content(project.name) | |
| 204 | + end | |
| 205 | + | |
| 206 | + When 'I submit form with selected project and max access' do | |
| 207 | + project = current_user.projects.first | |
| 208 | + within "#team_projects" do | |
| 209 | + select project.name, :from => "project_ids" | |
| 210 | + select "Reporter", :from => "greatest_project_access" | |
| 211 | + end | |
| 212 | + click_button "Add" | |
| 213 | + end | |
| 214 | + | |
| 215 | + Then 'I should see my own project in team projects list' do | |
| 216 | + project = current_user.projects.first | |
| 217 | + projects = all("table .project") | |
| 218 | + projects.each do |project_row| | |
| 219 | + project_row.should have_content(project.name) | |
| 220 | + end | |
| 221 | + end | |
| 222 | + | |
| 223 | + When 'I click link "New Team Member"' do | |
| 224 | + click_link "New Team Member" | |
| 225 | + end | |
| 226 | + | |
| 227 | + protected | |
| 228 | + | |
| 229 | + def current_team | |
| 230 | + @user_team ||= Team.first | |
| 231 | + end | |
| 232 | + | |
| 233 | + def project | |
| 234 | + current_team.projects.first | |
| 235 | + end | |
| 236 | + | |
| 237 | + def assigned_to_user key, user | |
| 238 | + project.send(key).where(assignee_id: user) | |
| 239 | + end | |
| 240 | + | |
| 241 | + def find_in_list(selector, item) | |
| 242 | + members_list = all(selector) | |
| 243 | + entered = false | |
| 244 | + members_list.each do |member_item| | |
| 245 | + entered = true if member_item.has_content?(item.name) | |
| 246 | + end | |
| 247 | + entered | |
| 248 | + end | |
| 249 | + | |
| 250 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | +Feature: UserTeams | |
| 2 | + Background: | |
| 3 | + Given I sign in as a user | |
| 4 | + And I own project "Shop" | |
| 5 | + And project "Shop" has push event | |
| 6 | + | |
| 7 | + Scenario: No teams, no dashboard info block | |
| 8 | + When I do not have teams with me | |
| 9 | + And I visit dashboard page | |
| 10 | + Then I should see dashboard page without teams info block | |
| 11 | + | |
| 12 | + Scenario: I should see teams info block | |
| 13 | + When I have teams with my membership | |
| 14 | + And I visit dashboard page | |
| 15 | + Then I should see dashboard page with teams information block | |
| 16 | + | |
| 17 | + Scenario: I should see all teams list | |
| 18 | + When exist user teams | |
| 19 | + And I visit dashboard page | |
| 20 | + And I click on "All teams" link | |
| 21 | + Then I should see "All teams" page | |
| 22 | + And I should see exist teams in teams list | |
| 23 | + | |
| 24 | + Scenario: I should can create new team | |
| 25 | + When I have teams with my membership | |
| 26 | + And I visit dashboard page | |
| 27 | + When I click to "New team" link | |
| 28 | + And I submit form with new team info | |
| 29 | + Then I should be redirected to new team page | |
| 30 | + | |
| 31 | + Scenario: I should see team dashboard list | |
| 32 | + When I have teams with projects and members | |
| 33 | + When I visit team page | |
| 34 | + Then I should see projects list | |
| 35 | + | |
| 36 | + Scenario: I should see team issues list | |
| 37 | + Given I have team with projects and members | |
| 38 | + And project from team has issues assigned to me | |
| 39 | + When I visit team issues page | |
| 40 | + Then I should see issues from this team assigned to me | |
| 41 | + | |
| 42 | + Scenario: I should see teams members issues list | |
| 43 | + Given I have team with projects and members | |
| 44 | + Given project from team has issues assigned to teams members | |
| 45 | + When I visit team issues page | |
| 46 | + Then I should see issues from this team assigned to teams members | |
| 47 | + | |
| 48 | + Scenario: I should see team merge requests list | |
| 49 | + Given I have team with projects and members | |
| 50 | + Given project from team has merge requests assigned to me | |
| 51 | + When I visit team merge requests page | |
| 52 | + Then I should see merge requests from this team assigned to me | |
| 53 | + | |
| 54 | + Scenario: I should see teams members merge requests list | |
| 55 | + Given I have team with projects and members | |
| 56 | + Given project from team has merge requests assigned to team members | |
| 57 | + When I visit team merge requests page | |
| 58 | + Then I should see merge requests from this team assigned to me | |
| 59 | + | |
| 60 | + Scenario: I should add user to projects in Team | |
| 61 | + Given I have team with projects and members | |
| 62 | + Given I have new user "John" | |
| 63 | + When I visit team people page | |
| 64 | + When I click link "New Team Member" | |
| 65 | + And I select user "John" from list with role "Reporter" | |
| 66 | + Then I should see user "John" in team list | |
| 67 | + | |
| 68 | + Scenario: I should assign my team to my own project | |
| 69 | + Given I have team with projects and members | |
| 70 | + And I have my own project without teams | |
| 71 | + And I visit my team page | |
| 72 | + When I click on link "Projects" | |
| 73 | + Then I should see form with my own project in avaliable projects list | |
| 74 | + When I submit form with selected project and max access | |
| 75 | + Then I should see my own project in team projects list | ... | ... |