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