From 7b75f3cfd34820ecdf0eddb7703bdba1e4c23f9f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 15 Mar 2012 23:32:00 +0200 Subject: [PATCH] show who merged request --- app/models/merge_request.rb | 4 ++++ app/models/project.rb | 3 ++- app/views/merge_requests/show.html.haml | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 6782d738..da74baa2 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -68,6 +68,10 @@ class MergeRequest < ActiveRecord::Base commits.first end + def merge_event + self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Merged).last + end + # Return the number of +1 comments (upvotes) def upvotes notes.select(&:upvote?).size diff --git a/app/models/project.rb b/app/models/project.rb index 28f03297..08a12d7d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -99,7 +99,8 @@ class Project < ActiveRecord::Base Event.create( :project => self, :action => Event::Merged, - :data => {:merge_request_id => merge_request.id}, + :target_id => merge_request.id, + :target_type => "MergeRequest", :author_id => user.id ) end diff --git a/app/views/merge_requests/show.html.haml b/app/views/merge_requests/show.html.haml index 3db24774..44291cf4 100644 --- a/app/views/merge_requests/show.html.haml +++ b/app/views/merge_requests/show.html.haml @@ -28,6 +28,16 @@ %hr - if @merge_request.closed .alert-message.error Closed + - if @merge_request.merged + - event = @merge_request.merge_event + %div + %p + %strong #{event.author_name} + merged this request + %span.cgray + = time_ago_in_words(event.created_at) + ago. + %br - else .alert-message.success = link_to "#", :class => "info_link", :title => "How To Merge" do