BigW Consortium Gitlab

Commit 28cb4313 by Dmitriy Zaporozhets

Hooks UI improved, Request tests added

parent 7b7547aa
source "http://rubygems.org" source "http://rubygems.org"
gem "rails", "3.2.1" gem "rails", "3.2.3"
gem "sqlite3" gem "sqlite3"
gem "mysql2" gem "mysql2"
...@@ -39,7 +39,7 @@ gem 'modularity' ...@@ -39,7 +39,7 @@ gem 'modularity'
group :assets do group :assets do
gem "sass-rails", "3.2.3" gem "sass-rails", "3.2.3"
gem "coffee-rails", "3.2.1" gem "coffee-rails", "3.2.2"
gem "uglifier", "1.0.3" gem "uglifier", "1.0.3"
end end
......
...@@ -41,31 +41,31 @@ GEM ...@@ -41,31 +41,31 @@ GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
ZenTest (4.5.0) ZenTest (4.5.0)
actionmailer (3.2.1) actionmailer (3.2.3)
actionpack (= 3.2.1) actionpack (= 3.2.3)
mail (~> 2.4.0) mail (~> 2.4.4)
actionpack (3.2.1) actionpack (3.2.3)
activemodel (= 3.2.1) activemodel (= 3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
builder (~> 3.0.0) builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
journey (~> 1.0.1) journey (~> 1.0.1)
rack (~> 1.4.0) rack (~> 1.4.0)
rack-cache (~> 1.1) rack-cache (~> 1.2)
rack-test (~> 0.6.1) rack-test (~> 0.6.1)
sprockets (~> 2.1.2) sprockets (~> 2.1.2)
activemodel (3.2.1) activemodel (3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
builder (~> 3.0.0) builder (~> 3.0.0)
activerecord (3.2.1) activerecord (3.2.3)
activemodel (= 3.2.1) activemodel (= 3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
arel (~> 3.0.0) arel (~> 3.0.2)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activeresource (3.2.1) activeresource (3.2.3)
activemodel (= 3.2.1) activemodel (= 3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
activesupport (3.2.1) activesupport (3.2.3)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
acts-as-taggable-on (2.1.1) acts-as-taggable-on (2.1.1)
...@@ -73,7 +73,7 @@ GEM ...@@ -73,7 +73,7 @@ GEM
acts_as_list (0.1.4) acts_as_list (0.1.4)
addressable (2.2.6) addressable (2.2.6)
ansi (1.4.2) ansi (1.4.2)
arel (3.0.0) arel (3.0.2)
autotest (4.4.6) autotest (4.4.6)
ZenTest (>= 4.4.1) ZenTest (>= 4.4.1)
autotest-rails (4.1.1) autotest-rails (4.1.1)
...@@ -96,13 +96,13 @@ GEM ...@@ -96,13 +96,13 @@ GEM
childprocess (0.3.1) childprocess (0.3.1)
ffi (~> 1.0.6) ffi (~> 1.0.6)
coderay (1.0.5) coderay (1.0.5)
coffee-rails (3.2.1) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (~> 3.2.0.beta) railties (~> 3.2.0)
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.2.0) coffee-script-source (1.3.1)
colored (1.2) colored (1.2)
crack (0.3.1) crack (0.3.1)
daemons (1.1.8) daemons (1.1.8)
...@@ -138,11 +138,11 @@ GEM ...@@ -138,11 +138,11 @@ GEM
multi_json multi_json
multi_xml multi_xml
i18n (0.6.0) i18n (0.6.0)
journey (1.0.1) journey (1.0.3)
jquery-rails (2.0.0) jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0) railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.6.5) json (1.6.6)
kaminari (0.13.0) kaminari (0.13.0)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
...@@ -153,7 +153,7 @@ GEM ...@@ -153,7 +153,7 @@ GEM
letter_opener (0.0.2) letter_opener (0.0.2)
launchy launchy
libv8 (3.3.10.4) libv8 (3.3.10.4)
mail (2.4.1) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
...@@ -184,7 +184,7 @@ GEM ...@@ -184,7 +184,7 @@ GEM
rubypython (~> 0.5.3) rubypython (~> 0.5.3)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
rack (1.4.1) rack (1.4.1)
rack-cache (1.1) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-protection (1.2.0) rack-protection (1.2.0)
rack rack
...@@ -192,19 +192,19 @@ GEM ...@@ -192,19 +192,19 @@ GEM
rack rack
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rails (3.2.1) rails (3.2.3)
actionmailer (= 3.2.1) actionmailer (= 3.2.3)
actionpack (= 3.2.1) actionpack (= 3.2.3)
activerecord (= 3.2.1) activerecord (= 3.2.3)
activeresource (= 3.2.1) activeresource (= 3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.2.1) railties (= 3.2.3)
rails-footnotes (3.7.5) rails-footnotes (3.7.5)
rails (>= 3.0.0) rails (>= 3.0.0)
railties (3.2.1) railties (3.2.3)
actionpack (= 3.2.1) actionpack (= 3.2.3)
activesupport (= 3.2.1) activesupport (= 3.2.3)
rack-ssl (~> 1.3.2) rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
...@@ -288,7 +288,7 @@ GEM ...@@ -288,7 +288,7 @@ GEM
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
turn (0.9.2) turn (0.9.2)
ansi ansi
tzinfo (0.3.31) tzinfo (0.3.33)
uglifier (1.0.3) uglifier (1.0.3)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (>= 1.0.2) multi_json (>= 1.0.2)
...@@ -320,7 +320,7 @@ DEPENDENCIES ...@@ -320,7 +320,7 @@ DEPENDENCIES
capybara capybara
carrierwave carrierwave
charlock_holmes charlock_holmes
coffee-rails (= 3.2.1) coffee-rails (= 3.2.2)
colored colored
database_cleaner database_cleaner
devise devise
...@@ -343,7 +343,7 @@ DEPENDENCIES ...@@ -343,7 +343,7 @@ DEPENDENCIES
omniauth-ldap omniauth-ldap
pry pry
pygments.rb (= 0.2.11) pygments.rb (= 0.2.11)
rails (= 3.2.1) rails (= 3.2.3)
rails-footnotes rails-footnotes
rake rake
redcarpet (~> 2.1.1) redcarpet (~> 2.1.1)
......
...@@ -465,3 +465,8 @@ table.admin-table { ...@@ -465,3 +465,8 @@ table.admin-table {
background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf);
} }
} }
.field_with_errors {
display:inline;
}
...@@ -32,9 +32,3 @@ ...@@ -32,9 +32,3 @@
} }
} }
} }
.new_project {
.field_with_errors {
display:inline;
}
}
...@@ -11,11 +11,8 @@ class HooksController < ApplicationController ...@@ -11,11 +11,8 @@ class HooksController < ApplicationController
respond_to :html respond_to :html
def index def index
@hooks = @project.web_hooks @hooks = @project.web_hooks.all
end @hook = WebHook.new
def new
@hook = @project.web_hooks.new
end end
def create def create
...@@ -23,25 +20,22 @@ class HooksController < ApplicationController ...@@ -23,25 +20,22 @@ class HooksController < ApplicationController
@hook.save @hook.save
if @hook.valid? if @hook.valid?
redirect_to project_hook_path(@project, @hook) redirect_to project_hooks_path(@project)
else else
render :new @hooks = @project.web_hooks.all
render :index
end end
end end
def test def test
@hook = @project.web_hooks.find(params[:id]) @hook = @project.web_hooks.find(params[:id])
commits = @project.commits(@project.default_branch, nil, 3) commits = @project.commits(@project.default_branch, nil, 3)
data = @project.web_hook_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user.keys.first.identifier) data = @project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user)
@hook.execute(data) @hook.execute(data)
redirect_to :back redirect_to :back
end end
def show
@hook = @project.web_hooks.find(params[:id])
end
def destroy def destroy
@hook = @project.web_hooks.find(params[:id]) @hook = @project.web_hooks.find(params[:id])
@hook.destroy @hook.destroy
......
= render "projects/project_head" = render "projects/project_head"
- if can? current_user, :admin_project, @project - if can? current_user, :admin_project, @project
.alert-message.block-message .alert.alert-info
Post receive hooks for binding events when someone push to repository. %span
= link_to new_project_hook_path(@project), :class => "btn small", :title => "New Web Hook" do Post receive hooks for binding events when someone push to repository.
Add Post Receive Hook %br
Read more about web hooks
%strong #{link_to "here", help_web_hooks_path, :class => "vlink"}
%p Read more about web hooks #{link_to "here", help_web_hooks_path, :class => "vlink"} = form_for [@project, @hook], :as => :hook, :url => project_hooks_path(@project) do |f|
-if @hook.errors.any?
.alert-message.block-message.error
- @hook.errors.full_messages.each do |msg|
%p= msg
.clearfix
= f.label :url, "URL:"
.input
= f.text_field :url, :class => "text_field xxlarge"
&nbsp;
= f.submit "Add Web Hook", :class => "btn primary"
%hr
-if @hooks.any? -if @hooks.any?
%table %h3
Hooks
%small (#{@hooks.count})
%br
%table.admin-table
%tr
%th URL
%th Method
%th
- @hooks.each do |hook| - @hooks.each do |hook|
%tr %tr
%td %td
= link_to project_hook_path(@project, hook) do = link_to project_hook_path(@project, hook) do
= hook.url %strong= hook.url
= link_to 'Test Hook', test_project_hook_path(@project, hook), :class => "btn small right"
%td POST
%td %td
= link_to 'Remove', project_hook_path(@project, hook), :confirm => 'Are you sure?', :method => :delete, :class => "danger btn small right" = link_to 'Remove', project_hook_path(@project, hook), :confirm => 'Are you sure?', :method => :delete, :class => "danger btn small right"
= render "repositories/head"
= form_for [@project, @hook], :as => :hook, :url => project_hooks_path(@project) do |f|
-if @hook.errors.any?
%ul
- @hook.errors.full_messages.each do |msg|
%li= msg
.clearfix
= f.label :url, "URL:"
.input= f.text_field :url, :class => "text_field"
.actions
= f.submit "Save", :class => "btn"
= render "repositories/head"
%pre= @hook.url
- if can? current_user, :admin_project, @project
.actions
= link_to 'Test Hook', test_project_hook_path(@project, @hook), :class => "btn"
= link_to 'Remove', project_hook_path(@project, @hook), :confirm => 'Are you sure?', :method => :delete, :class => "danger btn"
...@@ -111,7 +111,7 @@ Gitlab::Application.routes.draw do ...@@ -111,7 +111,7 @@ Gitlab::Application.routes.draw do
end end
resources :snippets resources :snippets
resources :hooks, :only => [:index, :new, :create, :destroy, :show] do resources :hooks, :only => [:index, :create, :destroy] do
member do member do
get :test get :test
end end
......
require 'spec_helper'
describe "Hooks" do
before do
login_as :user
@project = Factory :project
@project.add_access(@user, :read, :admin)
end
describe "GET index" do
it "should be available" do
@hook = Factory :web_hook, :project => @project
visit project_hooks_path(@project)
page.should have_content "Hooks"
page.should have_content @hook.url
end
end
describe "New Hook" do
before do
@url = Faker::Internet.url
visit project_hooks_path(@project)
fill_in "hook_url", :with => @url
expect { click_button "Add Web Hook" }.to change(WebHook, :count).by(1)
end
it "should open new team member popup" do
page.current_path.should == project_hooks_path(@project)
page.should have_content(@url)
end
end
describe "Test" do
before do
@hook = Factory :web_hook, :project => @project
visit project_hooks_path(@project)
click_link "Test Hook"
end
it { page.current_path.should == project_hooks_path(@project) }
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment