Commit 2dae0e18e09132c0db32c8646d8d11b30cfcb83f
1 parent
8d7aaf0e
Exists in
master
and in
4 other branches
web hooks scaffold started
Showing
10 changed files
with
85 additions
and
4 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +class HooksController < ApplicationController | |
| 2 | + before_filter :authenticate_user! | |
| 3 | + before_filter :project | |
| 4 | + layout "project" | |
| 5 | + | |
| 6 | + # Authorize | |
| 7 | + before_filter :add_project_abilities | |
| 8 | + before_filter :authorize_read_project! | |
| 9 | + before_filter :authorize_admin_project!, :only => [:new, :create, :destroy] | |
| 10 | + | |
| 11 | + respond_to :html | |
| 12 | + | |
| 13 | + def index | |
| 14 | + @hooks = @project.web_hooks | |
| 15 | + end | |
| 16 | + | |
| 17 | + def new | |
| 18 | + @hook = @project.web_hooks.new | |
| 19 | + end | |
| 20 | + | |
| 21 | + def create | |
| 22 | + @hook = @project.web_hooks.new(params[:hook]) | |
| 23 | + @hook.author = current_user | |
| 24 | + @hook.save | |
| 25 | + | |
| 26 | + if @hook.valid? | |
| 27 | + redirect_to [@project, @hook] | |
| 28 | + else | |
| 29 | + respond_with(@hook) | |
| 30 | + end | |
| 31 | + end | |
| 32 | + | |
| 33 | + def show | |
| 34 | + @hook = @project.web_hooks.find(params[:id]) | |
| 35 | + end | |
| 36 | + | |
| 37 | + def destroy | |
| 38 | + @hook = @project.web_hooks.find(params[:id]) | |
| 39 | + @hook.destroy | |
| 40 | + | |
| 41 | + redirect_to project_hooks_path(@project) | |
| 42 | + end | |
| 43 | +end | ... | ... |
app/controllers/projects_controller.rb
| ... | ... | @@ -68,7 +68,7 @@ class ProjectsController < ApplicationController |
| 68 | 68 | |
| 69 | 69 | def show |
| 70 | 70 | return render "projects/empty" unless @project.repo_exists? && @project.has_commits? |
| 71 | - limit = (params[:limit] || 20).to_i | |
| 71 | + limit = (params[:limit] || 10).to_i | |
| 72 | 72 | @activities = @project.cached_updates(limit) |
| 73 | 73 | end |
| 74 | 74 | ... | ... |
app/controllers/repositories_controller.rb
app/models/user.rb
app/models/web_hook.rb
| ... | ... | @@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base |
| 18 | 18 | # There was a problem calling this web hook, let's forget about it. |
| 19 | 19 | end |
| 20 | 20 | end |
| 21 | +# == Schema Information | |
| 22 | +# | |
| 23 | +# Table name: web_hooks | |
| 24 | +# | |
| 25 | +# id :integer not null, primary key | |
| 26 | +# url :string(255) | |
| 27 | +# project_id :integer | |
| 28 | +# created_at :datetime | |
| 29 | +# updated_at :datetime | |
| 30 | +# | |
| 31 | + | ... | ... |
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | += render "repositories/head" | |
| 2 | +- unless @hooks.empty? | |
| 3 | + %div.update-data.ui-box.ui-box-small | |
| 4 | + .data | |
| 5 | + - @hooks.each do |hook| | |
| 6 | + %a.update-item{:href => project_hooks_path(@project, hook)} | |
| 7 | + %span.update-title{:style => "margin-bottom:0px;"} | |
| 8 | + = hook.url | |
| 9 | +- else | |
| 10 | + %h3 No hooks | ... | ... |
app/workers/post_receive.rb
config/routes.rb
| 1 | 1 | Gitlab::Application.routes.draw do |
| 2 | 2 | |
| 3 | 3 | # Optionally, enable Resque here |
| 4 | - # require 'resque/server' | |
| 5 | - # mount Resque::Server.new, at: '/info/resque' | |
| 4 | + require 'resque/server' | |
| 5 | + mount Resque::Server.new, at: '/info/resque' | |
| 6 | 6 | |
| 7 | 7 | get 'tags'=> 'tags#index' |
| 8 | 8 | get 'tags/:tag' => 'projects#index' |
| ... | ... | @@ -83,6 +83,8 @@ Gitlab::Application.routes.draw do |
| 83 | 83 | get :commits |
| 84 | 84 | end |
| 85 | 85 | end |
| 86 | + | |
| 87 | + resources :hooks, :only => [:index, :new, :create, :destroy, :show] | |
| 86 | 88 | resources :snippets |
| 87 | 89 | resources :commits |
| 88 | 90 | resources :team_members | ... | ... |
spec/models/user_spec.rb
spec/models/web_hook_spec.rb
| ... | ... | @@ -52,3 +52,14 @@ describe WebHook do |
| 52 | 52 | end |
| 53 | 53 | end |
| 54 | 54 | end |
| 55 | +# == Schema Information | |
| 56 | +# | |
| 57 | +# Table name: web_hooks | |
| 58 | +# | |
| 59 | +# id :integer not null, primary key | |
| 60 | +# url :string(255) | |
| 61 | +# project_id :integer | |
| 62 | +# created_at :datetime | |
| 63 | +# updated_at :datetime | |
| 64 | +# | |
| 65 | + | ... | ... |