[refs #442] Merge master into 442-mass_build

This commit is contained in:
konstantin.grabar 2012-07-03 18:41:02 +04:00
commit 6afe8c0375
7 changed files with 56 additions and 32 deletions

View File

@ -18,7 +18,7 @@ class Ability
can :read, Issue, :project => {:visibility => 'open'}
can :search, BuildList
can :read, BuildList, :project => {:visibility => 'open'}
can :read, ProductBuildList, :product => {:platform => {:visibility => 'open'}}
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
can :read, Advisory
can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
# Core callbacks

View File

@ -182,31 +182,33 @@ Rosa::Application.routes.draw do
get '/sections' => 'projects#sections', :as => :sections_project
post '/sections' => 'projects#sections'
delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project
# Tree
get '/' => "git/trees#show", :as => :project
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
# Commits
get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
# Commit comments
post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
# Commit subscribes
post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
# Editing files
get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
# Blobs
get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
# Blame
get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
# Raw
get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
# Archive
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
constraints :treeish => /[^\/]+/ do
# Tree
get '/' => "git/trees#show", :as => :project
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
# Commits
get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
# Commit comments
post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments
get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment
put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment
delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy"
# Commit subscribes
post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit
delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit
# Editing files
get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob
put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false
# Blobs
get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false
# Blame
get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false
# Raw
get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
# Archive
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
end
end
end

View File

@ -306,6 +306,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do
t.integer "build_count", :default => 0, :null => false
end
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
create_table "register_requests", :force => true do |t|
t.string "name"
t.string "email"

View File

@ -20,12 +20,13 @@ Capistrano::Configuration.instance(:must_exist).load do
end
def stop_workers
ps = 'ps aux | grep resque | grep -v grep'
run "#{ps} && kill -QUIT `#{ps} | awk '{ print $2 }'` || echo 'Workers already stopped!'"
# ps = 'ps aux | grep resque | grep -v grep'
# run "#{ps} && kill -QUIT `#{ps} | awk '{ print $2 }'` || echo 'Workers already stopped!'"
run "cd #{fetch :current_path} && #{rails_env} bundle exec rake resque:stop_workers"
end
def start_workers
run "cd #{fetch :current_path} && COUNT=#{ workers_count } QUEUE=fork_import,hook,clone_build,notification #{ rails_env } BACKGROUND=yes bundle exec rake resque:workers"
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
end
end
end

10
lib/tasks/resque.rake Normal file
View File

@ -0,0 +1,10 @@
namespace :resque do
desc 'Stop all Resque workers'
task :stop_workers => :environment do
pids = []
Resque.workers.each do |worker|
pids << worker.to_s.split(/:/).second
end
system("kill -QUIT #{pids.join(' ')}") if pids.size > 0
end
end

View File

@ -22,5 +22,13 @@ describe ProductBuildList do
it { should allow_mass_assignment_of(:status) }
it { should allow_mass_assignment_of(:base_url) }
# see app/ability.rb
# can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
it 'should generate correct sql to get product build lists' do
stub_symlink_methods
user = FactoryGirl.create(:user)
ability = Ability.new user
ProductBuildList.accessible_by(ability).count.should == 0
end
end

View File

@ -36,8 +36,9 @@ describe Projects::Git::TreesController do
it "routes to #show" do
get("/import/glib2.0-mib").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib')
get("/import/glib2.0-mib/tree/branch").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch')
get("/import/glib2.0-mib/tree/branch/some/path.to").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch', :path => 'some/path.to')
get("/import/glib2.0-mib/tree/lib2safe-0.03").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'lib2safe-0.03')
get("/import/glib2.0-mib/tree/branch-with.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'branch-with.dot', :path => 'folder_with.dot/path-with.dot')
# get("/import/glib2.0-mib/tree/ветка-с.точкой/папка_с.точкой/путь-с.точкой").should route_to("projects/git/trees#show", :owner_name => 'import', :project_name => 'glib2.0-mib', :treeish => 'ветка-с.точкой', :path => 'папка_с.точкой/путь-с.точкой')
end
# TODO write more specs also with slash in branch name!