diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a152884d..0916164f 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -141,7 +141,7 @@ class AdminController < ApplicationController private def is_post - unless (request.post? || ENV["RAILS_ENV"] == "test") + unless (request.post? || Rails.env.test?) headers['Allow'] = 'POST' render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error') return false diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index 9585a278..e9ec6ae4 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -111,7 +111,7 @@ class FileController < ApplicationController private def is_post - unless (request.post? || ENV["RAILS_ENV"] == "test") + unless (request.post? || Rails.env.test?) headers['Allow'] = 'POST' render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error') return false diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index c4cebfc5..fa9fe080 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -280,7 +280,7 @@ EOL def save render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil? - unless (request.post? || ENV["RAILS_ENV"] == "test") + unless (request.post? || Rails.env.test?) headers['Allow'] = 'POST' render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error') return diff --git a/app/models/wiki_file.rb b/app/models/wiki_file.rb index 5e9a5d21..2c8caab5 100644 --- a/app/models/wiki_file.rb +++ b/app/models/wiki_file.rb @@ -9,7 +9,7 @@ class WikiFile < ActiveRecord::Base validates_length_of :description, :maximum=>255 def self.find_by_file_name(file_name) - find(:first, :conditions => ['file_name = ?', file_name]) + first(:conditions => ['file_name = ?', file_name]) end SANE_FILE_NAME = /^[a-zA-Z0-9\-_\. ]*$/ diff --git a/vendor/plugins/manage_fixtures/tasks/fixtures.rake b/lib/tasks/fixtures.rake similarity index 86% rename from vendor/plugins/manage_fixtures/tasks/fixtures.rake rename to lib/tasks/fixtures.rake index f19dd869..47fece32 100644 --- a/vendor/plugins/manage_fixtures/tasks/fixtures.rake +++ b/lib/tasks/fixtures.rake @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'lib', 'manage_fixtures.rb') +require Rails.root.join('vendor', 'plugins', 'manage_fixtures', 'lib', 'manage_fixtures.rb') desc "use rake db:fixtures:export_using_query SQL=\"select * from foo where id='bar'\" FIXTURE_NAME=foo" namespace :db do @@ -33,7 +33,7 @@ namespace :db do ActiveRecord::Base.establish_connection (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| i = "000" - File.open("#{RAILS_ROOT}/dump/fixtures/#{table_name}.yml", 'w' ) do |file| + File.open(Rails.root.join('dump', 'fixtures', table_name + '.yml'), 'w' ) do |file| write_yaml_fixtures_to_file(sql % table_name, table_name) end end @@ -73,8 +73,9 @@ namespace :db do namespace :fixtures do task :import_all => :environment do ActiveRecord::Base.establish_connection - Dir.glob(File.join(RAILS_ROOT,'dump','fixtures',"*.yml")).each do |f| - table_name = f.gsub(File.join(RAILS_ROOT,'dump','fixtures', ''), '').gsub('.yml', '') + Dir.glob(Rails.root.join('dump','fixtures',"*.yml")).each do |f| + table_name = f.gsub( Regexp.escape(Rails.root.join('dump','fixtures').to_s + File::SEPARATOR), '').gsub('.yml', '') + puts "Importing #{table_name}" import_table_fixture(table_name) end end