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