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 @@ | @@ -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,7 +68,7 @@ class ProjectsController < ApplicationController | ||
| 68 | 68 | ||
| 69 | def show | 69 | def show |
| 70 | return render "projects/empty" unless @project.repo_exists? && @project.has_commits? | 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 | @activities = @project.cached_updates(limit) | 72 | @activities = @project.cached_updates(limit) |
| 73 | end | 73 | end |
| 74 | 74 |
app/controllers/repositories_controller.rb
| @@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController | @@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController | ||
| 9 | layout "project" | 9 | layout "project" |
| 10 | 10 | ||
| 11 | def show | 11 | def show |
| 12 | - @activities = @project.fresh_commits(20) | 12 | + @activities = @project.fresh_commits(10) |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | def branches | 15 | def branches |
app/models/user.rb
| @@ -82,5 +82,6 @@ end | @@ -82,5 +82,6 @@ end | ||
| 82 | # linkedin :string(255) default(""), not null | 82 | # linkedin :string(255) default(""), not null |
| 83 | # twitter :string(255) default(""), not null | 83 | # twitter :string(255) default(""), not null |
| 84 | # authentication_token :string(255) | 84 | # authentication_token :string(255) |
| 85 | +# dark_scheme :boolean default(FALSE), not null | ||
| 85 | # | 86 | # |
| 86 | 87 |
app/models/web_hook.rb
| @@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base | @@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base | ||
| 18 | # There was a problem calling this web hook, let's forget about it. | 18 | # There was a problem calling this web hook, let's forget about it. |
| 19 | end | 19 | end |
| 20 | end | 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 @@ | @@ -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
| 1 | class PostReceive | 1 | class PostReceive |
| 2 | + @queue = :post_receive | ||
| 3 | + | ||
| 2 | def self.perform(reponame, oldrev, newrev, ref) | 4 | def self.perform(reponame, oldrev, newrev, ref) |
| 3 | project = Project.find_by_path(reponame) | 5 | project = Project.find_by_path(reponame) |
| 4 | return false if project.nil? | 6 | return false if project.nil? |
config/routes.rb
| 1 | Gitlab::Application.routes.draw do | 1 | Gitlab::Application.routes.draw do |
| 2 | 2 | ||
| 3 | # Optionally, enable Resque here | 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 | get 'tags'=> 'tags#index' | 7 | get 'tags'=> 'tags#index' |
| 8 | get 'tags/:tag' => 'projects#index' | 8 | get 'tags/:tag' => 'projects#index' |
| @@ -83,6 +83,8 @@ Gitlab::Application.routes.draw do | @@ -83,6 +83,8 @@ Gitlab::Application.routes.draw do | ||
| 83 | get :commits | 83 | get :commits |
| 84 | end | 84 | end |
| 85 | end | 85 | end |
| 86 | + | ||
| 87 | + resources :hooks, :only => [:index, :new, :create, :destroy, :show] | ||
| 86 | resources :snippets | 88 | resources :snippets |
| 87 | resources :commits | 89 | resources :commits |
| 88 | resources :team_members | 90 | resources :team_members |
spec/models/user_spec.rb
| @@ -65,5 +65,6 @@ end | @@ -65,5 +65,6 @@ end | ||
| 65 | # linkedin :string(255) default(""), not null | 65 | # linkedin :string(255) default(""), not null |
| 66 | # twitter :string(255) default(""), not null | 66 | # twitter :string(255) default(""), not null |
| 67 | # authentication_token :string(255) | 67 | # authentication_token :string(255) |
| 68 | +# dark_scheme :boolean default(FALSE), not null | ||
| 68 | # | 69 | # |
| 69 | 70 |
spec/models/web_hook_spec.rb
| @@ -52,3 +52,14 @@ describe WebHook do | @@ -52,3 +52,14 @@ describe WebHook do | ||
| 52 | end | 52 | end |
| 53 | end | 53 | end |
| 54 | end | 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 | + |