Skip to content

Commit

Permalink
Create event on dashboard when branch removed via UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Jul 16, 2013
1 parent d207a31 commit a165a0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/projects/branches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ def create
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 }
Expand Down
13 changes: 13 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ def determine_action(record)
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?
Expand Down

0 comments on commit a165a0b

Please sign in to comment.