Chris@1295: # Redmine - project management software Chris@1295: # Copyright (C) 2006-2012 Jean-Philippe Lang Chris@1295: # Chris@1295: # This program is free software; you can redistribute it and/or Chris@1295: # modify it under the terms of the GNU General Public License Chris@1295: # as published by the Free Software Foundation; either version 2 Chris@1295: # of the License, or (at your option) any later version. Chris@1295: # Chris@1295: # This program is distributed in the hope that it will be useful, Chris@1295: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1295: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1295: # GNU General Public License for more details. Chris@1295: # Chris@1295: # You should have received a copy of the GNU General Public License Chris@1295: # along with this program; if not, write to the Free Software Chris@1295: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@1295: Chris@1295: namespace :redmine do Chris@1295: namespace :attachments do Chris@1295: desc 'Removes uploaded files left unattached after one day.' Chris@1295: task :prune => :environment do Chris@1295: Attachment.prune Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: namespace :tokens do Chris@1295: desc 'Removes expired tokens.' Chris@1295: task :prune => :environment do Chris@1295: Token.destroy_expired Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: namespace :watchers do Chris@1295: desc 'Removes watchers from what they can no longer view.' Chris@1295: task :prune => :environment do Chris@1295: Watcher.prune Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: desc 'Fetch changesets from the repositories' Chris@1295: task :fetch_changesets => :environment do Chris@1295: Repository.fetch_changesets Chris@1295: end Chris@1295: Chris@1295: desc 'Migrates and copies plugins assets.' Chris@1295: task :plugins do Chris@1295: Rake::Task["redmine:plugins:migrate"].invoke Chris@1295: Rake::Task["redmine:plugins:assets"].invoke Chris@1295: end Chris@1295: Chris@1295: namespace :plugins do Chris@1295: desc 'Migrates installed plugins.' Chris@1295: task :migrate => :environment do Chris@1295: name = ENV['NAME'] Chris@1295: version = nil Chris@1295: version_string = ENV['VERSION'] Chris@1295: if version_string Chris@1295: if version_string =~ /^\d+$/ Chris@1295: version = version_string.to_i Chris@1295: if name.nil? Chris@1295: abort "The VERSION argument requires a plugin NAME." Chris@1295: end Chris@1295: else Chris@1295: abort "Invalid VERSION #{version_string} given." Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: begin Chris@1295: Redmine::Plugin.migrate(name, version) Chris@1295: rescue Redmine::PluginNotFound Chris@1295: abort "Plugin #{name} was not found." Chris@1295: end Chris@1295: Chris@1295: Rake::Task["db:schema:dump"].invoke Chris@1295: end Chris@1295: Chris@1295: desc 'Copies plugins assets into the public directory.' Chris@1295: task :assets => :environment do Chris@1295: name = ENV['NAME'] Chris@1295: Chris@1295: begin Chris@1295: Redmine::Plugin.mirror_assets(name) Chris@1295: rescue Redmine::PluginNotFound Chris@1295: abort "Plugin #{name} was not found." Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: desc 'Runs the plugins tests.' Chris@1295: task :test do Chris@1295: Rake::Task["redmine:plugins:test:units"].invoke Chris@1295: Rake::Task["redmine:plugins:test:functionals"].invoke Chris@1295: Rake::Task["redmine:plugins:test:integration"].invoke Chris@1295: end Chris@1295: Chris@1295: namespace :test do Chris@1295: desc 'Runs the plugins unit tests.' Chris@1295: Rake::TestTask.new :units => "db:test:prepare" do |t| Chris@1295: t.libs << "test" Chris@1295: t.verbose = true Chris@1295: t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/unit/**/*_test.rb" Chris@1295: end Chris@1295: Chris@1295: desc 'Runs the plugins functional tests.' Chris@1295: Rake::TestTask.new :functionals => "db:test:prepare" do |t| Chris@1295: t.libs << "test" Chris@1295: t.verbose = true Chris@1295: t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/functional/**/*_test.rb" Chris@1295: end Chris@1295: Chris@1295: desc 'Runs the plugins integration tests.' Chris@1295: Rake::TestTask.new :integration => "db:test:prepare" do |t| Chris@1295: t.libs << "test" Chris@1295: t.verbose = true Chris@1295: t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/integration/**/*_test.rb" Chris@1295: end Chris@1295: end Chris@1295: end Chris@1295: end Chris@1295: Chris@1295: # Load plugins' rake tasks Chris@1295: Dir[File.join(Rails.root, "plugins/*/lib/tasks/**/*.rake")].sort.each { |ext| load ext }