[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 :read, Issue, :project => {:visibility => 'open'}
can :search, BuildList can :search, BuildList
can :read, BuildList, :project => {:visibility => 'open'} 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 :read, Advisory
can(:advisories, Platform) {APP_CONFIG['anonymous_access']} can(:advisories, Platform) {APP_CONFIG['anonymous_access']}
# Core callbacks # Core callbacks

View File

@ -182,6 +182,7 @@ Rosa::Application.routes.draw do
get '/sections' => 'projects#sections', :as => :sections_project get '/sections' => 'projects#sections', :as => :sections_project
post '/sections' => 'projects#sections' post '/sections' => 'projects#sections'
delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project
constraints :treeish => /[^\/]+/ do
# Tree # Tree
get '/' => "git/trees#show", :as => :project get '/' => "git/trees#show", :as => :project
get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false
@ -209,6 +210,7 @@ Rosa::Application.routes.draw do
get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/ get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
end end
end end
end
scope ':uname' do # project owner profile scope ':uname' do # project owner profile
constraints OwnerConstraint.new(User) do constraints OwnerConstraint.new(User) do

View File

@ -306,6 +306,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do
t.integer "build_count", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false
end 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| create_table "register_requests", :force => true do |t|
t.string "name" t.string "name"
t.string "email" t.string "email"

View File

@ -20,12 +20,13 @@ Capistrano::Configuration.instance(:must_exist).load do
end end
def stop_workers def stop_workers
ps = 'ps aux | grep resque | grep -v grep' # ps = 'ps aux | grep resque | grep -v grep'
run "#{ps} && kill -QUIT `#{ps} | awk '{ print $2 }'` || echo 'Workers already stopped!'" # 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 end
def start_workers 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 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

@ -23,4 +23,12 @@ describe ProductBuildList do
it { should allow_mass_assignment_of(:status) } it { should allow_mass_assignment_of(:status) }
it { should allow_mass_assignment_of(:base_url) } 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 end

View File

@ -36,8 +36,9 @@ describe Projects::Git::TreesController do
it "routes to #show" 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").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/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/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/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 end
# TODO write more specs also with slash in branch name! # TODO write more specs also with slash in branch name!