Added merge request dashboard, showing all merge requests assigned to

you across projects.
This commit is contained in:
Ariejan de Vroom 2011-12-08 01:07:02 +01:00
parent 1a3af33fce
commit e4b1f38c27
10 changed files with 90 additions and 2 deletions

View file

@ -0,0 +1,9 @@
class UserMergeRequestsController < ApplicationController
before_filter :authenticate_user!
layout "user"
def index
@merge_requests = current_user.assigned_merge_requests
end
end

View file

@ -0,0 +1,3 @@
module UserMergeRequestsHelper
end

View file

@ -25,6 +25,15 @@ class User < ActiveRecord::Base
:foreign_key => :assignee_id,
: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
alias_attribute :private_token, :authentication_token
scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) }

View file

@ -21,6 +21,10 @@
Issues
- unless current_user.assigned_issues.empty?
%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
= yield

View file

@ -1,8 +1,11 @@
%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
%span.update-title
= merge_request.title
%span.update-author
- if not @project.present?
%strong= merge_request.project.name
= '-'
%strong= merge_request.author_name
authored
= time_ago_in_words(merge_request.created_at)

View file

@ -0,0 +1,10 @@
- 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

View file

@ -24,6 +24,7 @@ Gitlab::Application.routes.draw do
get "profile", :to => "profile#show"
get "dashboard", :to => "dashboard#index"
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"

View file

@ -6,6 +6,8 @@ describe User do
it { should have_many(:users_projects) }
it { should have_many(:issues) }
it { should have_many(:assigned_issues) }
it { should have_many(:merge_requests) }
it { should have_many(:assigned_merge_requests) }
end
describe "Respond to" do

View file

@ -50,7 +50,7 @@ describe "MergeRequests" do
end
describe "GET /merge_requests/new" do
before do
before do
visit new_project_merge_request_path(project)
fill_in "merge_request_title", :with => "Merge Request Title"
select "master", :from => "merge_request_source_branch"

View file

@ -0,0 +1,47 @@
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