Create event on dashboard when branch removed via UI

This commit is contained in:
Dmitriy Zaporozhets 2013-07-16 22:43:14 +03:00
parent d207a31fc9
commit a165a0b23f
2 changed files with 18 additions and 1 deletions

View File

@ -14,7 +14,11 @@ class Projects::BranchesController < Projects::ApplicationController
end
def destroy
@project.repository.rm_branch(params[:id])
branch = @project.repository.branches.find { |branch| branch.name == params[:id] }
if branch && @project.repository.rm_branch(branch.name)
Event.create_rm_branch(@project, current_user, branch)
end
respond_to do |format|
format.html { redirect_to project_branches_path }

View File

@ -54,6 +54,19 @@ class Event < ActiveRecord::Base
Event::COMMENTED
end
end
def create_rm_branch(project, user, branch)
Event.create(
project: project,
action: Event::PUSHED,
data: {
ref: branch.name,
before: branch.commit.id,
after: '00000000'
},
author_id: user.id
)
end
end
def proper?