summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-04-26 20:43:12 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-04-26 20:43:12 +0300
commit28cb43135ce7691a7b0022cb8fcb719d0e46c810 (patch)
tree28544a9855c3331d3bd1e5184c5b0dd4cc6cbaff
parent7b7547aa00e3c26637247812a1a5adf169ac4a55 (diff)
downloadgitlab-ce-28cb43135ce7691a7b0022cb8fcb719d0e46c810.tar.gz
Hooks UI improved, Request tests added
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock76
-rw-r--r--app/assets/stylesheets/gitlab_bootstrap.scss5
-rw-r--r--app/assets/stylesheets/sections/projects.scss6
-rw-r--r--app/controllers/hooks_controller.rb18
-rw-r--r--app/views/hooks/index.html.haml38
-rw-r--r--app/views/hooks/new.html.haml12
-rw-r--r--app/views/hooks/show.html.haml7
-rw-r--r--config/routes.rb2
-rw-r--r--spec/requests/hooks_spec.rb42
10 files changed, 125 insertions, 85 deletions
diff --git a/Gemfile b/Gemfile
index 3f5a1838ca3..e207f9f1d9e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
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
diff --git a/Gemfile.lock b/Gemfile.lock
index 81d6236ae6d..282c117bc41 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/app/assets/stylesheets/gitlab_bootstrap.scss b/app/assets/stylesheets/gitlab_bootstrap.scss
index 64f8a62d9db..441f031dd5e 100644
--- a/app/assets/stylesheets/gitlab_bootstrap.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap.scss
@@ -465,3 +465,8 @@ table.admin-table {
background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf);
}
}
+
+.field_with_errors {
+ display:inline;
+}
+
diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss
index 713cdc67df0..b96f7de93b8 100644
--- a/app/assets/stylesheets/sections/projects.scss
+++ b/app/assets/stylesheets/sections/projects.scss
@@ -32,9 +32,3 @@
}
}
}
-
-.new_project {
- .field_with_errors {
- display:inline;
- }
-}
diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb
index 72da6f98947..9627aba9771 100644
--- a/app/controllers/hooks_controller.rb
+++ b/app/controllers/hooks_controller.rb
@@ -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
diff --git a/app/views/hooks/index.html.haml b/app/views/hooks/index.html.haml
index 672d2bb0565..d81cce763d6 100644
--- a/app/views/hooks/index.html.haml
+++ b/app/views/hooks/index.html.haml
@@ -1,19 +1,43 @@
= render "projects/project_head"
- if can? current_user, :admin_project, @project
- .alert-message.block-message
- 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
+ .alert.alert-info
+ %span
+ Post receive hooks for binding events when someone push to repository.
+ %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"
+
diff --git a/app/views/hooks/new.html.haml b/app/views/hooks/new.html.haml
deleted file mode 100644
index f2a5ef534f4..00000000000
--- a/app/views/hooks/new.html.haml
+++ /dev/null
@@ -1,12 +0,0 @@
-= 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"
-
diff --git a/app/views/hooks/show.html.haml b/app/views/hooks/show.html.haml
deleted file mode 100644
index 5ec4d5d8758..00000000000
--- a/app/views/hooks/show.html.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-= 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"
diff --git a/config/routes.rb b/config/routes.rb
index 681bffc9506..1b8f6d3c077 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/spec/requests/hooks_spec.rb b/spec/requests/hooks_spec.rb
new file mode 100644
index 00000000000..a6d18e4c503
--- /dev/null
+++ b/spec/requests/hooks_spec.rb
@@ -0,0 +1,42 @@
+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