Commit e4b1f38c authored by Ariejan de Vroom's avatar Ariejan de Vroom

Added merge request dashboard, showing all merge requests assigned to

you across projects.
parent 1a3af33f
class UserMergeRequestsController < ApplicationController
before_filter :authenticate_user!
layout "user"
def index
@merge_requests = current_user.assigned_merge_requests
end
end
module UserMergeRequestsHelper
end
...@@ -25,6 +25,15 @@ class User < ActiveRecord::Base ...@@ -25,6 +25,15 @@ class User < ActiveRecord::Base
:foreign_key => :assignee_id, :foreign_key => :assignee_id,
:dependent => :destroy :dependent => :destroy
has_many :merge_requests,
:foreign_key => :author_id,
:dependent => :destroy
has_many :assigned_merge_requests,
:class_name => "MergeRequest",
:foreign_key => :assignee_id,
:dependent => :destroy
before_create :ensure_authentication_token before_create :ensure_authentication_token
alias_attribute :private_token, :authentication_token alias_attribute :private_token, :authentication_token
scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) } scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) }
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
Issues Issues
- unless current_user.assigned_issues.empty? - unless current_user.assigned_issues.empty?
%span{ :class => "number" }= current_user.assigned_issues.count %span{ :class => "number" }= current_user.assigned_issues.count
= link_to merge_requests_path, :class => current_page?(:controller => "user_merge_requests", :action => "index") ? "current" : nil do
Merge Requests
- unless current_user.assigned_merge_requests.empty?
%span{ :class => "number" }= current_user.assigned_merge_requests.count
.project-content .project-content
= yield = yield
......
%a.update-item{:href => project_merge_request_path(@project, merge_request)} %a.update-item{:href => project_merge_request_path(merge_request.project, merge_request)}
= image_tag gravatar_icon(merge_request.author_email), :class => "left", :width => 40 = image_tag gravatar_icon(merge_request.author_email), :class => "left", :width => 40
%span.update-title %span.update-title
= merge_request.title = merge_request.title
%span.update-author %span.update-author
- if not @project.present?
%strong= merge_request.project.name
= '-'
%strong= merge_request.author_name %strong= merge_request.author_name
authored authored
= time_ago_in_words(merge_request.created_at) = time_ago_in_words(merge_request.created_at)
......
- if @merge_requests.opened.count > 0
%div{ :class => "update-data ui-box ui-box-small ui-box-big" }
%h3
%span.tag.open Open
.data
= render @merge_requests.opened
.clear
%br
...@@ -24,6 +24,7 @@ Gitlab::Application.routes.draw do ...@@ -24,6 +24,7 @@ Gitlab::Application.routes.draw do
get "profile", :to => "profile#show" get "profile", :to => "profile#show"
get "dashboard", :to => "dashboard#index" get "dashboard", :to => "dashboard#index"
get "issues", :to => "user_issues#index", :as => "issues" get "issues", :to => "user_issues#index", :as => "issues"
get "merge_requests", :to => "user_merge_requests#index", :as => "merge_requests"
#get "profile/:id", :to => "profile#show" #get "profile/:id", :to => "profile#show"
......
...@@ -6,6 +6,8 @@ describe User do ...@@ -6,6 +6,8 @@ describe User do
it { should have_many(:users_projects) } it { should have_many(:users_projects) }
it { should have_many(:issues) } it { should have_many(:issues) }
it { should have_many(:assigned_issues) } it { should have_many(:assigned_issues) }
it { should have_many(:merge_requests) }
it { should have_many(:assigned_merge_requests) }
end end
describe "Respond to" do describe "Respond to" do
......
require 'spec_helper'
describe "User MergeRequests" do
describe "GET /issues" do
before do
login_as :user
@project1 = Factory :project,
:path => "project1",
:code => "TEST1"
@project2 = Factory :project,
:path => "project2",
:code => "TEST2"
@project1.add_access(@user, :read, :write)
@project2.add_access(@user, :read, :write)
@merge_request1 = Factory :merge_request,
:author => @user,
:assignee => @user,
:project => @project1
@merge_request2 = Factory :merge_request,
:author => @user,
:assignee => @user,
:project => @project2
visit merge_requests_path
end
subject { page }
it { should have_content(@merge_request1.title) }
it { should have_content(@merge_request1.project.name) }
it { should have_content(@merge_request1.target_branch) }
it { should have_content(@merge_request1.source_branch) }
it { should have_content(@merge_request1.assignee.name) }
it { should have_content(@merge_request2.title) }
it { should have_content(@merge_request2.project.name) }
it { should have_content(@merge_request2.target_branch) }
it { should have_content(@merge_request2.source_branch) }
it { should have_content(@merge_request2.assignee.name) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment