diff --git a/app/controllers/public/chat_controller.rb b/app/controllers/public/chat_controller.rb index 235b3bd..bd834cb 100644 --- a/app/controllers/public/chat_controller.rb +++ b/app/controllers/public/chat_controller.rb @@ -19,7 +19,7 @@ class ChatController < PublicController def avatar profile = environment.profiles.find_by_identifier(params[:id]) filename, mimetype = profile_icon(profile, :minor, true) - data = File.read(File.join(Rails.root, 'public', filename)) + data = File.read(Rails.root.join('public', filename)) render :text => data, :layout => false, :content_type => mimetype expires_in 24.hours end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dccd2cd..4a03313 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -310,7 +310,7 @@ module ApplicationHelper raise ArgumentError, 'No profile actions view for this class.' if klass.nil? name = klass.name.underscore - return "blocks/profile_info_actions/" + name + '.html.erb' if File.exists?(File.join(Rails.root, 'app', 'views', 'blocks', 'profile_info_actions', name + '.html.erb')) + return "blocks/profile_info_actions/" + name + '.html.erb' if File.exists?(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', name + '.html.erb')) view_for_profile_actions(klass.superclass) end @@ -328,7 +328,7 @@ module ApplicationHelper "\n" + sources.flatten.map do |source| filename = filename_for_stylesheet(source.to_s, themed_source) - if File.exists?(File.join(Rails.root, 'public', filename)) + if File.exists?(Rails.root.join('public', filename)) "@import url(#{filename});\n" else "/* Not included: url(#{filename}) */\n" @@ -372,7 +372,7 @@ module ApplicationHelper if Rails.env == 'development' && environment.theme == 'random' @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand @random_theme - elsif Rails.env == 'development' && params[:theme] && File.exists?(File.join(Rails.root, 'public/designs/themes', params[:theme])) + elsif Rails.env == 'development' && params[:theme] && File.exists?(Rails.root.join('public/designs/themes', params[:theme])) params[:theme] else if profile && !profile.theme.nil? @@ -398,7 +398,7 @@ module ApplicationHelper # XXX Since we cannot control what people are doing in external themes, we # will keep looking for the deprecated .rhtml extension here. ['.rhtml', '.html.erb'].each do |ext| - file = File.join(Rails.root, 'public', theme_path, template + ext) + file = Rails.root.join('public', theme_path, template + ext) if File.exists?(file) return render :file => file, :use_full_path => false end @@ -408,7 +408,7 @@ module ApplicationHelper def theme_favicon return '/designs/themes/' + current_theme + '/favicon.ico' if profile.nil? || profile.theme.nil? - if File.exists?(File.join(Rails.root, 'public', theme_path, 'favicon.ico')) + if File.exists?(Rails.root.join('public', theme_path, 'favicon.ico')) '/designs/themes/' + profile.theme + '/favicon.ico' else favicon = profile.articles.find_by_path('favicon.ico') @@ -478,7 +478,7 @@ module ApplicationHelper end def default_or_themed_icon(icon) - if File.exists?(File.join(Rails.root, 'public', theme_path, icon)) + if File.exists?(Rails.root.join('public', theme_path, icon)) theme_path + icon else icon @@ -503,7 +503,7 @@ module ApplicationHelper compact.uniq.map do |c| cat_name = c.gsub( /[-_\s,.;'"]+/, '_' ) cat_icon = "/images/icons-cat/#{cat_name}.png" - if ! File.exists? RAILS_ROOT.to_s() + '/public/' + cat_icon + if ! File.exists?(Rails.root.join('public', cat_icon)) cat_icon = '/images/icons-cat/undefined.png' end content_tag('span', @@ -711,7 +711,7 @@ module ApplicationHelper def theme_javascript_ng script = File.join(theme_path, 'theme.js') - if File.exists?(File.join(Rails.root, 'public', script)) + if File.exists?(Rails.root.join('public', script)) javascript_include_tag script else nil @@ -923,7 +923,7 @@ module ApplicationHelper theme_icon_themes = theme_option(:icon_theme) || [] for icon_theme in theme_icon_themes do theme_path = "/designs/icons/#{icon_theme}/style.css" - if File.exists?(File.join(Rails.root, 'public', theme_path)) + if File.exists?(Rails.root.join('public', theme_path)) icon_themes << theme_path end end @@ -1116,7 +1116,7 @@ module ApplicationHelper def render_environment_features(folder) result = '' environment.enabled_features.keys.each do |feature| - file = File.join(Rails.root, 'app/views/shared', folder.to_s, "#{feature}.html.erb") + file = Rails.root.join('app/views/shared', folder.to_s, "#{feature}.html.erb") if File.exists?(file) result << render(:file => file, :use_full_path => false) end diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index 6bfbffb..d960459 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -62,7 +62,7 @@ module ContentViewerHelper end def addthis_image_tag - if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif')) + if File.exists?(Rails.root.join('public', theme_path, 'images', 'addthis.gif')) image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '') else image_tag("/images/bt-bookmark.gif", :width => 53, :height => 16, :border => 0, :alt => '') diff --git a/app/helpers/display_helper.rb b/app/helpers/display_helper.rb index a0514d6..496e3b6 100644 --- a/app/helpers/display_helper.rb +++ b/app/helpers/display_helper.rb @@ -9,7 +9,7 @@ module DisplayHelper end def themed_path(file) - if File.exists?(File.join(Rails.root, 'public', theme_path, file)) + if File.exists?(Rails.root.join('public', theme_path, file)) File.join(theme_path, file) else file diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 85b3cb8..8c26e6f 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -69,7 +69,7 @@ module LayoutHelper theme_icon_themes = theme_option(:icon_theme) || [] for icon_theme in theme_icon_themes do theme_path = "/designs/icons/#{icon_theme}/style.css" - if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) + if File.exists?(Rails.root.join('public', theme_path)) icon_themes << theme_path end end diff --git a/app/models/article.rb b/app/models/article.rb index 1d485f0..bde00c3 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -262,7 +262,7 @@ class Article < ActiveRecord::Base def reported_version(options = {}) article = self - search_path = File.join(Rails.root, 'app', 'views', 'shared', 'reported_versions') + search_path = Rails.root.join('app', 'views', 'shared', 'reported_versions') partial_path = File.join('shared', 'reported_versions', partial_for_class_in_view_path(article.class, search_path)) lambda { render_to_string(:partial => partial_path, :locals => {:article => article}) } end diff --git a/app/models/doc_item.rb b/app/models/doc_item.rb index e27b5d2..9c68e06 100644 --- a/app/models/doc_item.rb +++ b/app/models/doc_item.rb @@ -31,7 +31,7 @@ class DocItem search_path.unshift("/designs/themes/#{theme}#{translation}") # higher priority search_path.push("/designs/themes/#{theme}#{image}") # lower priority end - search_path.find {|file| File.exist?("#{Rails.root}/public#{file}") } + search_path.find {|file| File.exist?(Rails.root.join('public', file[1..-1])) } end end diff --git a/app/models/doc_section.rb b/app/models/doc_section.rb index 43493f4..2d724e6 100644 --- a/app/models/doc_section.rb +++ b/app/models/doc_section.rb @@ -1,7 +1,7 @@ class DocSection < DocItem def self.root_dir - @root_dir ||= File.join(Rails.root, 'doc', 'noosfero') + @root_dir ||= Rails.root.join('doc', 'noosfero') end def items diff --git a/app/models/layout_template.rb b/app/models/layout_template.rb index 28d25fb..674f415 100644 --- a/app/models/layout_template.rb +++ b/app/models/layout_template.rb @@ -7,7 +7,7 @@ class LayoutTemplate end def self.all - Dir.glob(File.join(Rails.root, 'public', 'designs', 'templates', '*')).map {|item| find(File.basename(item)) } + Dir.glob(Rails.root.join('public', 'designs', 'templates', '*')).map {|item| find(File.basename(item)) } end attr_reader :id @@ -34,7 +34,7 @@ class LayoutTemplate protected def read_config - @config = YAML.load_file(File.join(Rails.root, 'public', 'designs', 'templates', id, 'config.yml')) + @config = YAML.load_file(Rails.root.join('public', 'designs', 'templates', id, 'config.yml')) end end diff --git a/app/models/slideshow_block.rb b/app/models/slideshow_block.rb index 61eadd4..7c8a907 100644 --- a/app/models/slideshow_block.rb +++ b/app/models/slideshow_block.rb @@ -20,7 +20,7 @@ class SlideshowBlock < Block def check_filename(image, size) filename = image.public_filename(size) - if File.exists?(File.join(Rails.root, 'public', filename)) + if File.exists?(Rails.root.join('public', filename)) filename else nil diff --git a/app/models/spammer_logger.rb b/app/models/spammer_logger.rb index 5ab87e4..5117bb8 100644 --- a/app/models/spammer_logger.rb +++ b/app/models/spammer_logger.rb @@ -1,5 +1,5 @@ class SpammerLogger < Logger - @logpath = File.join(Rails.root, 'log', "#{ENV['RAILS_ENV']}_spammers.log") + @logpath = Rails.root.join('log', "#{ENV['RAILS_ENV']}_spammers.log") @logger = new(@logpath) def self.log(spammer_ip, object=nil) diff --git a/app/models/theme.rb b/app/models/theme.rb index 3b33bff..fbb2e39 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -10,11 +10,11 @@ class Theme end def user_themes_dir - File.join(Rails.root, 'public', 'user_themes') + Rails.root.join('public', 'user_themes') end def system_themes_dir - File.join(Rails.root, 'public', 'designs', 'themes') + Rails.root.join('public', 'designs', 'themes') end def create(id, attributes = {}) diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 01304d5..64f69a6 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -31,7 +31,7 @@ class UploadedFile < Article end def thumbnail_path - self.image? ? self.full_filename(:display).gsub(File.join(Rails.root, 'public'), '') : nil + self.image? ? self.full_filename(:display).gsub(Rails.root.join('public'), '') : nil end def display_title diff --git a/app/views/layouts/_javascript.html.erb b/app/views/layouts/_javascript.html.erb index 8f82b2b..a9adffa 100644 --- a/app/views/layouts/_javascript.html.erb +++ b/app/views/layouts/_javascript.html.erb @@ -8,6 +8,6 @@ <% language = FastGettext.locale %> <% %w{messages methods}.each do |type| %> <% require_path = File.join('jquery-validation', 'localization', type+'_'+language) %> - <% full_path = File.join(Rails.root, 'public', 'javascripts', require_path+'.js')%> + <% full_path = Rails.root.join('public', 'javascripts', require_path+'.js')%> <%= javascript_include_tag require_path if File.exists?(full_path) %> <% end %> diff --git a/config/application.rb b/config/application.rb index 1cc6379..05aa214 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,7 +24,7 @@ module Noosfero # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - config.autoload_paths += %W( #{Rails.root}/app/sweepers ) + config.autoload_paths += %W( #{Rails.root.join('app', 'sweepers')} ) config.autoload_paths += Dir["#{config.root}/lib/**/"] config.autoload_paths += Dir["#{config.root}/app/controllers/**/"] diff --git a/config/environment.rb b/config/environment.rb index ff96097..22e8939 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -7,7 +7,7 @@ require File.expand_path('../application', __FILE__) # extra directories for controllers organization extra_controller_dirs = %w[ -].map {|item| File.join(Rails.root, item) } +].map {|item| Rails.root.join(item) } # Add new inflection rules using the following format # (all these examples are active by default): @@ -32,7 +32,7 @@ require 'noosfero' # load a local configuration if present, but not under test environment. if !['test', 'cucumber'].include?(ENV['RAILS_ENV']) - localconfigfile = File.join(Rails.root, 'config', 'local.rb') + localconfigfile = Rails.root.join('config', 'local.rb') if File.exists?(localconfigfile) require localconfigfile end diff --git a/config/environments/cucumber.rb b/config/environments/cucumber.rb index 93c057a..9d6c1bc 100644 --- a/config/environments/cucumber.rb +++ b/config/environments/cucumber.rb @@ -20,7 +20,7 @@ config.action_controller.allow_forgery_protection = false # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test -config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails')) -config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner')) -config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara')) +config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(Rails.root.join('vendor/plugins/cucumber-rails')) +config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(Rails.root.join('vendor/plugins/database_cleaner')) +config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(Rails.root.join('vendor/plugins/capybara')) diff --git a/config/initializers/01_load_config.rb b/config/initializers/01_load_config.rb index d43aad9..a808d85 100644 --- a/config/initializers/01_load_config.rb +++ b/config/initializers/01_load_config.rb @@ -1,2 +1,2 @@ -file = "#{Rails.root}/config/noosfero.yml" +file = Rails.root.join('config', 'noosfero.yml') NOOSFERO_CONF = File.exists?(file) ? YAML.load_file(file)[RAILS_ENV] || {} : {} diff --git a/config/initializers/default_icon_theme.rb b/config/initializers/default_icon_theme.rb index 1bfc372..55b7ae1 100644 --- a/config/initializers/default_icon_theme.rb +++ b/config/initializers/default_icon_theme.rb @@ -1,12 +1,12 @@ if File.writable?(Rails.root) # create the symlink to the default theme if it does not exist - default = File.join(Rails.root, 'public', 'designs', 'icons', 'default') + default = Rails.root.join('public', 'designs', 'icons', 'default') if !File.exists?(default) File.symlink('tango', default) end # create a symlink to system-wide Tango icon set if it does not exist - tango_symlink = File.join(Rails.root, 'public', 'designs', 'icons', 'tango', 'Tango') + tango_symlink = Rails.root.join('public', 'designs', 'icons', 'tango', 'Tango') if !File.exist?(tango_symlink) File.symlink('/usr/share/icons/Tango', tango_symlink) end diff --git a/config/initializers/default_theme.rb b/config/initializers/default_theme.rb index 893c071..42dcaee 100644 --- a/config/initializers/default_theme.rb +++ b/config/initializers/default_theme.rb @@ -1,6 +1,6 @@ if File.writable?(Rails.root) # create the symlink to the default theme if it does not exist - default = File.join(Rails.root, 'public', 'designs', 'themes', 'default') + default = Rails.root.join('public', 'designs', 'themes', 'default') if !File.exists?(default) File.symlink('noosfero', default) end diff --git a/lib/noosfero.rb b/lib/noosfero.rb index f19b7d0..5031233 100644 --- a/lib/noosfero.rb +++ b/lib/noosfero.rb @@ -63,7 +63,7 @@ module Noosfero private def self.controllers_in_directory(dir) - app_controller_path = Dir.glob(File.join(Rails.root, 'app', 'controllers', dir, '*_controller.rb')) + app_controller_path = Dir.glob(Rails.root.join('app', 'controllers', dir, '*_controller.rb')) app_controller_path.map do |item| item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') end diff --git a/lib/noosfero/multi_tenancy.rb b/lib/noosfero/multi_tenancy.rb index d3c49cf..dfe97c6 100644 --- a/lib/noosfero/multi_tenancy.rb +++ b/lib/noosfero/multi_tenancy.rb @@ -25,7 +25,7 @@ module Noosfero private def self.load_map - db_file = File.join(Rails.root, 'config', 'database.yml') + db_file = Rails.root.join('config', 'database.yml') db_config = YAML.load_file(db_file) map = { } db_config.each do |env, attr| @@ -36,7 +36,7 @@ module Noosfero end def self.is_hosted_environment? - db_file = File.join(Rails.root, 'config', 'database.yml') + db_file = Rails.root.join('config', 'database.yml') db_config = YAML.load_file(db_file) db_config.select{ |env, attr| Rails.env.to_s.match(/_#{env}$/) }.any? end diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 5d2a462..9b6cd9b 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -69,9 +69,9 @@ class Noosfero::Plugin def enabled @enabled ||= begin - plugins = Dir.glob(File.join(Rails.root, 'config', 'plugins', '*')) - if Rails.env.test? && !plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo')) - plugins << File.join(Rails.root, 'plugins', 'foo') + plugins = Dir.glob(Rails.root.join('config', 'plugins', '*')) + if Rails.env.test? && !plugins.include?(Rails.root.join('config', 'plugins', 'foo')) + plugins << Rails.root.join('plugins', 'foo') end plugins.select do |entry| File.directory?(entry) @@ -96,7 +96,7 @@ class Noosfero::Plugin end def root_path - File.join(Rails.root, 'plugins', public_name) + Rails.root.join('plugins', public_name) end def view_path @@ -122,7 +122,7 @@ class Noosfero::Plugin end def expanded_template(file_path, locals = {}) - views_path = "#{Rails.root}/plugins/#{self.class.public_name}/views" + views_path = Rails.root.join('plugins', "#{self.class.public_name}", 'views') ERB.new(File.read("#{views_path}/#{file_path}")).result(binding) end diff --git a/lib/noosfero/plugin/mailer_base.rb b/lib/noosfero/plugin/mailer_base.rb index efd74b1..771a6a6 100644 --- a/lib/noosfero/plugin/mailer_base.rb +++ b/lib/noosfero/plugin/mailer_base.rb @@ -1,7 +1,7 @@ class Noosfero::Plugin::MailerBase < ActionMailer::Base def self.inherited(child) - child.template_root = File.expand_path(File.join(Rails.root, 'plugins', child.plugin_name, 'views')) + child.template_root = File.expand_path(Rails.root.join('plugins', child.plugin_name, 'views')) end def self.plugin_name diff --git a/lib/noosfero/plugin/routes.rb b/lib/noosfero/plugin/routes.rb index fd98574..b7428d5 100644 --- a/lib/noosfero/plugin/routes.rb +++ b/lib/noosfero/plugin/routes.rb @@ -1,6 +1,6 @@ plugins_root = Rails.env.test? ? 'plugins' : File.join('config', 'plugins') -Dir.glob(File.join(Rails.root, plugins_root, '*', 'controllers')) do |controllers_dir| +Dir.glob(Rails.root.join(plugins_root, '*', 'controllers')) do |controllers_dir| prefixes_by_folder = {'public' => 'plugin', 'profile' => 'profile/:profile/plugin', 'myprofile' => 'myprofile/:profile/plugin', diff --git a/lib/postgresql_attachment_fu.rb b/lib/postgresql_attachment_fu.rb index 98ae7fb..dba629f 100644 --- a/lib/postgresql_attachment_fu.rb +++ b/lib/postgresql_attachment_fu.rb @@ -10,7 +10,7 @@ module PostgresqlAttachmentFu def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on? - File.join(Rails.root, file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) + Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) end end diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index 7db1a55..e75f59f 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -7,7 +7,7 @@ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks -vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +vendored_cucumber_bin = Dir[Rails.root.join('vendor', '{gems,plugins}', 'cucumber*', 'bin', 'cucumber')].first $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? begin diff --git a/lib/tasks/doc.rake b/lib/tasks/doc.rake index 0d065e6..be860d9 100644 --- a/lib/tasks/doc.rake +++ b/lib/tasks/doc.rake @@ -5,12 +5,12 @@ namespace :noosfero do end task :link_plugins_textiles do plugins_textiles.each do |file| - ln_sf File.join(Rails.root, file), 'doc/noosfero/plugins/' + ln_sf Rails.root.join(file), 'doc/noosfero/plugins/' end end task :unlink_plugins_textiles do - rm_f Dir.glob(File.join(Rails.root, 'doc/noosfero/plugins/*.textile')) - - [File.join(Rails.root, 'doc/noosfero/plugins/index.textile')] + rm_f Dir.glob(Rails.root.join('doc/noosfero/plugins/*.textile')) - + [Rails.root.join('doc/noosfero/plugins/index.textile')] end input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"} topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq diff --git a/lib/tasks/error_messages.rake b/lib/tasks/error_messages.rake index e802376..761e34c 100644 --- a/lib/tasks/error_messages.rake +++ b/lib/tasks/error_messages.rake @@ -1,4 +1,4 @@ -templates = Dir.glob(Rails.root + '/public/*.html.erb') +templates = Dir.glob(Rails.root.join('public', '*.html.erb')) targets = [] templates.each do |template| target = template.gsub(/.erb$/, '') diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index cf12e69..72d9df9 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -21,14 +21,14 @@ task :symlinkmo do langmap = { 'pt' => 'pt_BR', } - mkdir_p(File.join(Rails.root, 'locale')) - Dir.glob(File.join(Rails.root, 'locale/*')).each do |dir| + mkdir_p(Rails.root.join('locale')) + Dir.glob(Rails.root.join('locale/*')).each do |dir| lang = File.basename(dir) orig_lang = langmap[lang] || lang - mkdir_p("#{Rails.root}/locale/#{lang}/LC_MESSAGES") + mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES')) ['iso_3166'].each do |domain| origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo" - target = "#{Rails.root}/locale/#{lang}/LC_MESSAGES/#{domain}.mo" + target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo") if !File.symlink?(target) ln_s origin, target end diff --git a/lib/tasks/multitenancy.rake b/lib/tasks/multitenancy.rake index 15d2669..1e25dcb 100644 --- a/lib/tasks/multitenancy.rake +++ b/lib/tasks/multitenancy.rake @@ -2,14 +2,14 @@ namespace :multitenancy do task :create do db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } - cd File.join(Rails.root, 'config', 'environments'), :verbose => true + cd Rails.root.join('config', 'environments'), :verbose => true file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } end task :remove do db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } - cd File.join(Rails.root, 'config', 'environments'), :verbose => true + cd Rails.root.join('config', 'environments'), :verbose => true file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } end diff --git a/lib/tasks/plugins.rake b/lib/tasks/plugins.rake index 94bb6c2..53f5373 100644 --- a/lib/tasks/plugins.rake +++ b/lib/tasks/plugins.rake @@ -1,6 +1,6 @@ namespace :noosfero do namespace :plugins do - plugin_migration_dirs = Dir.glob(File.join(Rails.root, 'config', 'plugins', '*', 'db', 'migrate')) + plugin_migration_dirs = Dir.glob(Rails.root.join('config', 'plugins', '*', 'db', 'migrate')) task :migrate do plugin_migration_dirs.each do |path| ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) diff --git a/lib/tasks/po.rake b/lib/tasks/po.rake index d56164b..71ece25 100644 --- a/lib/tasks/po.rake +++ b/lib/tasks/po.rake @@ -25,7 +25,7 @@ namespace :po do puts "+----------+----------+------------+--------+--------------+" puts "| Language | Messages | Translated | Fuzzy | Untranslated |" puts "+----------+----------+------------+--------+--------------+" - Dir.glob(Rails.root + '/po/*/noosfero.po').each do |file| + Dir.glob(Rails.root.join('po', '*', 'noosfero.po')).each do |file| language = File.basename(File.dirname(file)) output = `msgfmt --output /dev/null --statistics #{file} 2>&1` translated = extract_po_stat('translated', output) diff --git a/lib/tasks/test_rcov.rake b/lib/tasks/test_rcov.rake index 39e92b8..6ec0f0a 100644 --- a/lib/tasks/test_rcov.rake +++ b/lib/tasks/test_rcov.rake @@ -22,8 +22,8 @@ namespace :test do task :rcov do |t| require 'rbconfig' - tests = Dir.glob(File.join(Rails.root, 'test', '*', '*_test.rb')) - outdir = File.join(Rails.root, 'coverage') + tests = Dir.glob(Rails.root.join('test', '*', '*_test.rb')) + outdir = Rails.root.join('coverage') test_loader = File.join(Config::CONFIG['rubylibdir'], 'rake', 'rake_test_loader.rb') system("rcov", '-o', outdir, '-T', '-x', 'rubygems/*,rcov*', '--rails', '-Ilib:test', test_loader, *tests) diff --git a/script/reset_db b/script/reset_db index 86f4067..56fea1d 100755 --- a/script/reset_db +++ b/script/reset_db @@ -1,10 +1,10 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' -system "rm #{Rails.root}/tmp/*.db" -system "rm #{Rails.root}/db/*.db" -system "rm -rf #{Rails.root}/public/articles" +system "rm #{Rails.root.join('tmp', '*.db')}" +system "rm #{Rails.root.join('db', '*.db')}" +system "rm -rf #{Rails.root.join('public', 'articles')}" system "rake db:migrate VERSION=0" system "rake db:migrate" -system "#{Rails.root}/script/anhetegua" +system "#{Rails.root.join('script', 'anhetegua')}" system "rake db:test:prepare" diff --git a/test/factories.rb b/test/factories.rb index b24c0f3..d7e22f2 100644 --- a/test/factories.rb +++ b/test/factories.rb @@ -264,7 +264,7 @@ module Noosfero::Factory # ExternalFeed ############################################### def defaults_for_external_feed - { :address => Rails.root + '/test/fixtures/files/feed.xml', :blog_id => factory_num_seq } + { :address => Rails.root.join('test', 'fixtures', 'files', 'feed.xml'), :blog_id => factory_num_seq } end def create_external_feed(attrs = {}) @@ -278,7 +278,7 @@ module Noosfero::Factory # FeedReaderBlock ############################################### def defaults_for_feed_reader_block - { :address => File.join(Rails.root, 'test/fixtures/files/feed.xml') } + { :address => Rails.root.join('test/fixtures/files/feed.xml') } end ############################################### diff --git a/test/functional/themes_controller_test.rb b/test/functional/themes_controller_test.rb index daa44ab..381a0a1 100644 --- a/test/functional/themes_controller_test.rb +++ b/test/functional/themes_controller_test.rb @@ -25,7 +25,7 @@ class ThemesControllerTest < ActionController::TestCase FileUtils.rm_rf(TMP_THEMES_DIR) end - TMP_THEMES_DIR = Rails.root + '/test/tmp/themes_controller' + TMP_THEMES_DIR = Rails.root.join("test", "tmp", "themes_controller") should 'display themes that can be applied' do env = Environment.default @@ -216,7 +216,7 @@ class ThemesControllerTest < ActionController::TestCase post :add_image, :profile => 'testinguser', :id => 'mytheme', :image => fixture_file_upload('/files/rails.png', 'image/png', :binary) assert_redirected_to :action => "edit", :id => 'mytheme' assert theme.image_files.include?('rails.png') - assert(system('diff', Rails.root + '/test/fixtures/files/rails.png', TMP_THEMES_DIR + '/mytheme/images/rails.png'), 'should put the correct uploaded file in the right place') + assert(system('diff', Rails.root.join('test', 'fixtures', 'files','rails.png'), TMP_THEMES_DIR + '/mytheme/images/rails.png'), 'should put the correct uploaded file in the right place') end should 'link to "test theme"' do diff --git a/test/integration/controller_naming_test.rb b/test/integration/controller_naming_test.rb index a248c77..dec7674 100644 --- a/test/integration/controller_naming_test.rb +++ b/test/integration/controller_naming_test.rb @@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" class ControllerNamingTest < ActionController::IntegrationTest should 'not have controllers with same name in different folders' do - controllers = Dir.glob("#{Rails.root}/app/controllers/**/*_controller.rb").map { |item| item.split(/\//).last } + controllers = Dir.glob(Rails.root.join("app", "controllers", "**", "*_controller.rb")).map { |item| item.split(/\//).last } assert_equal controllers.uniq, controllers end diff --git a/test/integration/tiny_mce_languages_test.rb b/test/integration/tiny_mce_languages_test.rb index 768e26c..c2ea65a 100644 --- a/test/integration/tiny_mce_languages_test.rb +++ b/test/integration/tiny_mce_languages_test.rb @@ -11,7 +11,7 @@ class TinyMceLanguagesTest < ActionController::IntegrationTest end def assert_exists_tinymce_language_file(file) - filename = Rails.root + "/public/javascripts/tinymce/jscripts/tiny_mce/" + file + filename = Rails.root.join("public", "javascripts", "tinymce", "jscripts", "tiny_mce", file) assert(File.exists?(filename), filename + " must exist") end diff --git a/test/noosfero_doc_test.rb b/test/noosfero_doc_test.rb index 2f577ee..b7235c0 100644 --- a/test/noosfero_doc_test.rb +++ b/test/noosfero_doc_test.rb @@ -4,7 +4,7 @@ require 'mocha' module Noosfero::DocTest unless defined?(ROOT) - ROOT = File.join(Rails.root, "test", "tmp", "doc") + ROOT = Rails.root.join("test", "tmp", "doc") end def create_doc(section, topic, language, title, body = nil) diff --git a/test/test_helper.rb b/test/test_helper.rb index 7d28977..c650dbb 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -12,7 +12,7 @@ require File.dirname(__FILE__) + '/factories' require File.dirname(__FILE__) + '/noosfero_doc_test' require File.dirname(__FILE__) + '/action_tracker_test_helper' -FileUtils.rm_rf(File.join(Rails.root, 'index', 'test')) +FileUtils.rm_rf(Rails.root.join('index', 'test')) Image.attachment_options[:path_prefix] = 'test/tmp/public/images' Thumbnail.attachment_options[:path_prefix] = 'test/tmp/public/thumbnails' @@ -54,7 +54,7 @@ class ActiveSupport::TestCase fixtures :environments, :roles def self.all_fixtures - Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item| + Dir.glob(Rails.root.join('test', 'fixtures', '*.yml')).each do |item| fixtures File.basename(item).sub(/\.yml$/, '').to_s end end @@ -145,7 +145,7 @@ class ActiveSupport::TestCase patch ? patch[1] : nil end.compact s.each do |css_ref| - if ! File.exists?( Rails.root.to_s() +'/public/'+ css_ref ) + if ! File.exists?(Rails.root.join('public', css_ref )) flunk 'CSS reference missed on HTML: "%s"' % css_ref end end @@ -154,7 +154,7 @@ class ActiveSupport::TestCase # Test image references: (doc/'img').each do |img| src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '') - if ! File.exists?( Rails.root.to_s() +'/public/'+ src ) + if ! File.exists?(Rails.root.join('public', src)) flunk 'Image reference missed on HTML: "%s"' % src end end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 5cef3ba..97a5013 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -55,10 +55,10 @@ class ApplicationHelperTest < ActiveSupport::TestCase end should 'look for superclasses on view_for_profile actions' do - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/float.rhtml").returns(false) - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/float.html.erb").returns(false) - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/numeric.rhtml").returns(false) - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/numeric.html.erb").returns(true) + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'float.rhtml')).returns(false) + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'float.html.erb')).returns(false) + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'numeric.rhtml')).returns(false) + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'numeric.html.erb')).returns(true) assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float) end @@ -70,13 +70,13 @@ class ApplicationHelperTest < ActiveSupport::TestCase end should 'generate link to stylesheet' do - File.expects(:exists?).with(File.join(Rails.root, 'public', 'stylesheets', 'something.css')).returns(true) + File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(true) expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') assert_match '@import url(/stylesheets/something.css)', stylesheet_import('something') end should 'not generate link to unexisting stylesheet' do - File.expects(:exists?).with(File.join(Rails.root, 'public', 'stylesheets', 'something.css')).returns(false) + File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(false) expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') assert_no_match %r{@import url(/stylesheets/something.css)}, stylesheet_import('something') end @@ -175,7 +175,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'render theme footer' do stubs(:theme_path).returns('/user_themes/mytheme') - footer_path = Rails.root + '/public/user_themes/mytheme/footer.rhtml' + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml') File.expects(:exists?).with(footer_path).returns(true) expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI") @@ -185,8 +185,8 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'ignore unexisting theme footer' do stubs(:theme_path).returns('/user_themes/mytheme') - footer_path = Rails.root + '/public/user_themes/mytheme/footer.rhtml' - alternate_footer_path = Rails.root + '/public/user_themes/mytheme/footer.html.erb' + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml') + alternate_footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.html.erb') File.expects(:exists?).with(footer_path).returns(false) File.expects(:exists?).with(alternate_footer_path).returns(false) @@ -197,7 +197,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'render theme site title' do stubs(:theme_path).returns('/user_themes/mytheme') - site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.rhtml' + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml') File.expects(:exists?).with(site_title_path).returns(true) expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title") @@ -207,8 +207,8 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'ignore unexisting theme site title' do stubs(:theme_path).returns('/user_themes/mytheme') - site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.rhtml' - alternate_site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.html.erb' + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml') + alternate_site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.html.erb') File.expects(:exists?).with(site_title_path).returns(false) File.expects(:exists?).with(alternate_site_title_path).returns(false) @@ -571,7 +571,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'use favicon from profile theme if the profile has theme' do stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) - File.expects(:exists?).with(File.join(Rails.root, 'public', '/designs/themes/profile-theme', 'favicon.ico')).returns(true) + File.expects(:exists?).with(Rails.root.join('public', '/designs/themes/profile-theme', 'favicon.ico')).returns(true) assert_equal '/designs/themes/profile-theme/favicon.ico', theme_favicon end @@ -579,7 +579,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/favicon.ico', 'image/x-ico'), :profile => profile) - File.expects(:exists?).with(File.join(Rails.root, 'public', theme_path, 'favicon.ico')).returns(false) + File.expects(:exists?).with(Rails.root.join('public', theme_path, 'favicon.ico')).returns(false) assert_match /favicon.ico/, theme_favicon end @@ -587,7 +587,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase should 'use favicon from environment if the profile theme and profile articles do not have' do stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) - File.expects(:exists?).with(File.join(Rails.root, 'public', theme_path, 'favicon.ico')).returns(false) + File.expects(:exists?).with(Rails.root.join('public', theme_path, 'favicon.ico')).returns(false) assert_equal '/designs/themes/new-theme/favicon.ico', theme_favicon end @@ -597,7 +597,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase stubs(:environment).returns(env) @controller = ApplicationController.new - path = File.join(Rails.root, 'app', 'views') + path = Rails.root.join('app', 'views') @controller.stubs(:view_paths).returns([path]) file = path + '/shared/usermenu/xmpp_chat.rhtml' diff --git a/test/unit/colorbox_helper_test.rb b/test/unit/colorbox_helper_test.rb index c42d830..0f260aa 100644 --- a/test/unit/colorbox_helper_test.rb +++ b/test/unit/colorbox_helper_test.rb @@ -5,8 +5,8 @@ class ColorboxHelperTest < ActiveSupport::TestCase include ColorboxHelper should 'provide the needed files' do - assert File.exists?(File.join(Rails.root, 'public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found' - assert File.exists?(File.join(Rails.root, 'public', 'javascripts', 'colorbox.js')), 'colorbox.js expected to be in public/javascripts, but not found' + assert File.exists?(Rails.root.join('public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found' + assert File.exists?(Rails.root.join('public', 'javascripts', 'colorbox.js')), 'colorbox.js expected to be in public/javascripts, but not found' end should 'provide link to close colorbox' do diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index af4cde3..f103282 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -214,7 +214,7 @@ class CommentTest < ActiveSupport::TestCase should 'use an existing image for deleted comments' do image = Comment.new.removed_user_image - assert File.exists?(File.join(Rails.root, 'public', image)), "#{image} does not exist." + assert File.exists?(Rails.root.join('public', image)), "#{image} does not exist." end should 'have the action_tracker_target defined' do diff --git a/test/unit/doc_item_test.rb b/test/unit/doc_item_test.rb index 228a398..893bc76 100644 --- a/test/unit/doc_item_test.rb +++ b/test/unit/doc_item_test.rb @@ -27,10 +27,10 @@ class DocItemTest < ActiveSupport::TestCase should 'translate images' do doc = DocItem.new(:language => 'pt', :text => '
Look the image:
Look the image:
Look the image:
Look the image: