diff --git a/Gemfile b/Gemfile index 3f5a1838ca3c3fe264b8e4734a130d219217a7d1..e207f9f1d9e4717f4cebc308aab038601b3f7ed0 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 81d6236ae6d7285a5710ab8e5a40f35fbc07e663..282c117bc41514e348c217e8ee089afecfe336fc 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 64f8a62d9dbd80906b0150f554b8a676f28b7036..441f031dd5e9a67f5e97414830340736f91a87af 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 713cdc67df05e1ce517f4a70089ae8729e8e1f65..b96f7de93b8811fd5a79ab2c2c0045e584a9cf9b 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 72da6f98947b8d9f627c65ae807ef4c0f28e5a51..9627aba9771086b408a94186636299ecbb088eff 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 @@ def create @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 672d2bb0565c7cdbc638458f954f4c029d2e9e24..d81cce763d6a61543ead557d77d563d425326d78 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" + + = 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 f2a5ef534f4ecc110c7e8f7706dfc3916360b9ec..0000000000000000000000000000000000000000 --- 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 5ec4d5d8758eb22bffedd2af48d1b1a3a5f6fc0c..0000000000000000000000000000000000000000 --- 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 681bffc9506a6453f2c4bfa4f002c96603bdc22b..1b8f6d3c07776451eb5e32733da4c9c8f79d2c67 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,7 +111,7 @@ 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 0000000000000000000000000000000000000000..a6d18e4c50388869a2a6419e3c3a104962b46439 --- /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