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