Commit 28cb4313 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Hooks UI improved, Request tests added

parent 7b7547aa
source "http://rubygems.org"
gem "rails", "3.2.1"
gem "rails", "3.2.3"
gem "sqlite3"
gem "mysql2"
......@@ -39,7 +39,7 @@ gem 'modularity'
group :assets do
gem "sass-rails", "3.2.3"
gem "coffee-rails", "3.2.1"
gem "coffee-rails", "3.2.2"
gem "uglifier", "1.0.3"
end
......
......@@ -41,31 +41,31 @@ GEM
remote: http://rubygems.org/
specs:
ZenTest (4.5.0)
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
actionmailer (3.2.3)
actionpack (= 3.2.3)
mail (~> 2.4.4)
actionpack (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
activemodel (3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
activerecord (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
activeresource (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
acts-as-taggable-on (2.1.1)
......@@ -73,7 +73,7 @@ GEM
acts_as_list (0.1.4)
addressable (2.2.6)
ansi (1.4.2)
arel (3.0.0)
arel (3.0.2)
autotest (4.4.6)
ZenTest (>= 4.4.1)
autotest-rails (4.1.1)
......@@ -96,13 +96,13 @@ GEM
childprocess (0.3.1)
ffi (~> 1.0.6)
coderay (1.0.5)
coffee-rails (3.2.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0.beta)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
coffee-script-source (1.3.1)
colored (1.2)
crack (0.3.1)
daemons (1.1.8)
......@@ -138,11 +138,11 @@ GEM
multi_json
multi_xml
i18n (0.6.0)
journey (1.0.1)
journey (1.0.3)
jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
json (1.6.6)
kaminari (0.13.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
......@@ -153,7 +153,7 @@ GEM
letter_opener (0.0.2)
launchy
libv8 (3.3.10.4)
mail (2.4.1)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
......@@ -184,7 +184,7 @@ GEM
rubypython (~> 0.5.3)
pyu-ruby-sasl (0.0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack-cache (1.2)
rack (>= 0.4)
rack-protection (1.2.0)
rack
......@@ -192,19 +192,19 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
rails (3.2.3)
actionmailer (= 3.2.3)
actionpack (= 3.2.3)
activerecord (= 3.2.3)
activeresource (= 3.2.3)
activesupport (= 3.2.3)
bundler (~> 1.0)
railties (= 3.2.1)
railties (= 3.2.3)
rails-footnotes (3.7.5)
rails (>= 3.0.0)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
railties (3.2.3)
actionpack (= 3.2.3)
activesupport (= 3.2.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
......@@ -288,7 +288,7 @@ GEM
polyglot (>= 0.3.1)
turn (0.9.2)
ansi
tzinfo (0.3.31)
tzinfo (0.3.33)
uglifier (1.0.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
......@@ -320,7 +320,7 @@ DEPENDENCIES
capybara
carrierwave
charlock_holmes
coffee-rails (= 3.2.1)
coffee-rails (= 3.2.2)
colored
database_cleaner
devise
......@@ -343,7 +343,7 @@ DEPENDENCIES
omniauth-ldap
pry
pygments.rb (= 0.2.11)
rails (= 3.2.1)
rails (= 3.2.3)
rails-footnotes
rake
redcarpet (~> 2.1.1)
......
......@@ -465,3 +465,8 @@ table.admin-table {
background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf);
}
}
.field_with_errors {
display:inline;
}
......@@ -32,9 +32,3 @@
}
}
}
.new_project {
.field_with_errors {
display:inline;
}
}
......@@ -11,11 +11,8 @@ class HooksController < ApplicationController
respond_to :html
def index
@hooks = @project.web_hooks
end
def new
@hook = @project.web_hooks.new
@hooks = @project.web_hooks.all
@hook = WebHook.new
end
def create
......@@ -23,25 +20,22 @@ class HooksController < ApplicationController
@hook.save
if @hook.valid?
redirect_to project_hook_path(@project, @hook)
redirect_to project_hooks_path(@project)
else
render :new
@hooks = @project.web_hooks.all
render :index
end
end
def test
@hook = @project.web_hooks.find(params[:id])
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)
redirect_to :back
end
def show
@hook = @project.web_hooks.find(params[:id])
end
def destroy
@hook = @project.web_hooks.find(params[:id])
@hook.destroy
......
= render "projects/project_head"
- if can? current_user, :admin_project, @project
.alert-message.block-message
.alert.alert-info
%span
Post receive hooks for binding events when someone push to repository.
= link_to new_project_hook_path(@project), :class => "btn small", :title => "New Web Hook" do
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?
%table
%h3
Hooks
%small (#{@hooks.count})
%br
%table.admin-table
%tr
%th URL
%th Method
%th
- @hooks.each do |hook|
%tr
%td
= 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
= 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
end
resources :snippets
resources :hooks, :only => [:index, :new, :create, :destroy, :show] do
resources :hooks, :only => [:index, :create, :destroy] do
member do
get :test
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