Commit 9e0087a15ab9a73c8284e0bd91bd9a007c7d75a3

Authored by Rodrigo Souto
1 parent e227e0e3

rails3: rewrite Rails.root use to fix/avoid problems

Rails.root is now a Pathname. The best use of it is with the #join
method instead of concatenation and such. I therefore am rewriting all
this calls to fix/avoid problems.
Showing 57 changed files with 133 additions and 133 deletions   Show diff stats
app/controllers/public/chat_controller.rb
@@ -19,7 +19,7 @@ class ChatController < PublicController @@ -19,7 +19,7 @@ class ChatController < PublicController
19 def avatar 19 def avatar
20 profile = environment.profiles.find_by_identifier(params[:id]) 20 profile = environment.profiles.find_by_identifier(params[:id])
21 filename, mimetype = profile_icon(profile, :minor, true) 21 filename, mimetype = profile_icon(profile, :minor, true)
22 - data = File.read(File.join(Rails.root, 'public', filename)) 22 + data = File.read(Rails.root.join('public', filename))
23 render :text => data, :layout => false, :content_type => mimetype 23 render :text => data, :layout => false, :content_type => mimetype
24 expires_in 24.hours 24 expires_in 24.hours
25 end 25 end
app/helpers/application_helper.rb
@@ -310,7 +310,7 @@ module ApplicationHelper @@ -310,7 +310,7 @@ module ApplicationHelper
310 raise ArgumentError, 'No profile actions view for this class.' if klass.nil? 310 raise ArgumentError, 'No profile actions view for this class.' if klass.nil?
311 311
312 name = klass.name.underscore 312 name = klass.name.underscore
313 - return "blocks/profile_info_actions/" + name + '.html.erb' if File.exists?(File.join(Rails.root, 'app', 'views', 'blocks', 'profile_info_actions', name + '.html.erb')) 313 + return "blocks/profile_info_actions/" + name + '.html.erb' if File.exists?(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', name + '.html.erb'))
314 314
315 view_for_profile_actions(klass.superclass) 315 view_for_profile_actions(klass.superclass)
316 end 316 end
@@ -328,7 +328,7 @@ module ApplicationHelper @@ -328,7 +328,7 @@ module ApplicationHelper
328 "\n" + 328 "\n" +
329 sources.flatten.map do |source| 329 sources.flatten.map do |source|
330 filename = filename_for_stylesheet(source.to_s, themed_source) 330 filename = filename_for_stylesheet(source.to_s, themed_source)
331 - if File.exists?(File.join(Rails.root, 'public', filename)) 331 + if File.exists?(Rails.root.join('public', filename))
332 "@import url(#{filename});\n" 332 "@import url(#{filename});\n"
333 else 333 else
334 "/* Not included: url(#{filename}) */\n" 334 "/* Not included: url(#{filename}) */\n"
@@ -372,7 +372,7 @@ module ApplicationHelper @@ -372,7 +372,7 @@ module ApplicationHelper
372 if Rails.env == 'development' && environment.theme == 'random' 372 if Rails.env == 'development' && environment.theme == 'random'
373 @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand 373 @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand
374 @random_theme 374 @random_theme
375 - elsif Rails.env == 'development' && params[:theme] && File.exists?(File.join(Rails.root, 'public/designs/themes', params[:theme])) 375 + elsif Rails.env == 'development' && params[:theme] && File.exists?(Rails.root.join('public/designs/themes', params[:theme]))
376 params[:theme] 376 params[:theme]
377 else 377 else
378 if profile && !profile.theme.nil? 378 if profile && !profile.theme.nil?
@@ -398,7 +398,7 @@ module ApplicationHelper @@ -398,7 +398,7 @@ module ApplicationHelper
398 # XXX Since we cannot control what people are doing in external themes, we 398 # XXX Since we cannot control what people are doing in external themes, we
399 # will keep looking for the deprecated .rhtml extension here. 399 # will keep looking for the deprecated .rhtml extension here.
400 ['.rhtml', '.html.erb'].each do |ext| 400 ['.rhtml', '.html.erb'].each do |ext|
401 - file = File.join(Rails.root, 'public', theme_path, template + ext) 401 + file = Rails.root.join('public', theme_path, template + ext)
402 if File.exists?(file) 402 if File.exists?(file)
403 return render :file => file, :use_full_path => false 403 return render :file => file, :use_full_path => false
404 end 404 end
@@ -408,7 +408,7 @@ module ApplicationHelper @@ -408,7 +408,7 @@ module ApplicationHelper
408 408
409 def theme_favicon 409 def theme_favicon
410 return '/designs/themes/' + current_theme + '/favicon.ico' if profile.nil? || profile.theme.nil? 410 return '/designs/themes/' + current_theme + '/favicon.ico' if profile.nil? || profile.theme.nil?
411 - if File.exists?(File.join(Rails.root, 'public', theme_path, 'favicon.ico')) 411 + if File.exists?(Rails.root.join('public', theme_path, 'favicon.ico'))
412 '/designs/themes/' + profile.theme + '/favicon.ico' 412 '/designs/themes/' + profile.theme + '/favicon.ico'
413 else 413 else
414 favicon = profile.articles.find_by_path('favicon.ico') 414 favicon = profile.articles.find_by_path('favicon.ico')
@@ -478,7 +478,7 @@ module ApplicationHelper @@ -478,7 +478,7 @@ module ApplicationHelper
478 end 478 end
479 479
480 def default_or_themed_icon(icon) 480 def default_or_themed_icon(icon)
481 - if File.exists?(File.join(Rails.root, 'public', theme_path, icon)) 481 + if File.exists?(Rails.root.join('public', theme_path, icon))
482 theme_path + icon 482 theme_path + icon
483 else 483 else
484 icon 484 icon
@@ -503,7 +503,7 @@ module ApplicationHelper @@ -503,7 +503,7 @@ module ApplicationHelper
503 compact.uniq.map do |c| 503 compact.uniq.map do |c|
504 cat_name = c.gsub( /[-_\s,.;'"]+/, '_' ) 504 cat_name = c.gsub( /[-_\s,.;'"]+/, '_' )
505 cat_icon = "/images/icons-cat/#{cat_name}.png" 505 cat_icon = "/images/icons-cat/#{cat_name}.png"
506 - if ! File.exists? RAILS_ROOT.to_s() + '/public/' + cat_icon 506 + if ! File.exists?(Rails.root.join('public', cat_icon))
507 cat_icon = '/images/icons-cat/undefined.png' 507 cat_icon = '/images/icons-cat/undefined.png'
508 end 508 end
509 content_tag('span', 509 content_tag('span',
@@ -711,7 +711,7 @@ module ApplicationHelper @@ -711,7 +711,7 @@ module ApplicationHelper
711 711
712 def theme_javascript_ng 712 def theme_javascript_ng
713 script = File.join(theme_path, 'theme.js') 713 script = File.join(theme_path, 'theme.js')
714 - if File.exists?(File.join(Rails.root, 'public', script)) 714 + if File.exists?(Rails.root.join('public', script))
715 javascript_include_tag script 715 javascript_include_tag script
716 else 716 else
717 nil 717 nil
@@ -923,7 +923,7 @@ module ApplicationHelper @@ -923,7 +923,7 @@ module ApplicationHelper
923 theme_icon_themes = theme_option(:icon_theme) || [] 923 theme_icon_themes = theme_option(:icon_theme) || []
924 for icon_theme in theme_icon_themes do 924 for icon_theme in theme_icon_themes do
925 theme_path = "/designs/icons/#{icon_theme}/style.css" 925 theme_path = "/designs/icons/#{icon_theme}/style.css"
926 - if File.exists?(File.join(Rails.root, 'public', theme_path)) 926 + if File.exists?(Rails.root.join('public', theme_path))
927 icon_themes << theme_path 927 icon_themes << theme_path
928 end 928 end
929 end 929 end
@@ -1116,7 +1116,7 @@ module ApplicationHelper @@ -1116,7 +1116,7 @@ module ApplicationHelper
1116 def render_environment_features(folder) 1116 def render_environment_features(folder)
1117 result = '' 1117 result = ''
1118 environment.enabled_features.keys.each do |feature| 1118 environment.enabled_features.keys.each do |feature|
1119 - file = File.join(Rails.root, 'app/views/shared', folder.to_s, "#{feature}.html.erb") 1119 + file = Rails.root.join('app/views/shared', folder.to_s, "#{feature}.html.erb")
1120 if File.exists?(file) 1120 if File.exists?(file)
1121 result << render(:file => file, :use_full_path => false) 1121 result << render(:file => file, :use_full_path => false)
1122 end 1122 end
app/helpers/content_viewer_helper.rb
@@ -62,7 +62,7 @@ module ContentViewerHelper @@ -62,7 +62,7 @@ module ContentViewerHelper
62 end 62 end
63 63
64 def addthis_image_tag 64 def addthis_image_tag
65 - if File.exists?(File.join(Rails.root, 'public', theme_path, 'images', 'addthis.gif')) 65 + if File.exists?(Rails.root.join('public', theme_path, 'images', 'addthis.gif'))
66 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '') 66 image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '')
67 else 67 else
68 image_tag("/images/bt-bookmark.gif", :width => 53, :height => 16, :border => 0, :alt => '') 68 image_tag("/images/bt-bookmark.gif", :width => 53, :height => 16, :border => 0, :alt => '')
app/helpers/display_helper.rb
@@ -9,7 +9,7 @@ module DisplayHelper @@ -9,7 +9,7 @@ module DisplayHelper
9 end 9 end
10 10
11 def themed_path(file) 11 def themed_path(file)
12 - if File.exists?(File.join(Rails.root, 'public', theme_path, file)) 12 + if File.exists?(Rails.root.join('public', theme_path, file))
13 File.join(theme_path, file) 13 File.join(theme_path, file)
14 else 14 else
15 file 15 file
app/helpers/layout_helper.rb
@@ -69,7 +69,7 @@ module LayoutHelper @@ -69,7 +69,7 @@ module LayoutHelper
69 theme_icon_themes = theme_option(:icon_theme) || [] 69 theme_icon_themes = theme_option(:icon_theme) || []
70 for icon_theme in theme_icon_themes do 70 for icon_theme in theme_icon_themes do
71 theme_path = "/designs/icons/#{icon_theme}/style.css" 71 theme_path = "/designs/icons/#{icon_theme}/style.css"
72 - if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) 72 + if File.exists?(Rails.root.join('public', theme_path))
73 icon_themes << theme_path 73 icon_themes << theme_path
74 end 74 end
75 end 75 end
app/models/article.rb
@@ -262,7 +262,7 @@ class Article &lt; ActiveRecord::Base @@ -262,7 +262,7 @@ class Article &lt; ActiveRecord::Base
262 262
263 def reported_version(options = {}) 263 def reported_version(options = {})
264 article = self 264 article = self
265 - search_path = File.join(Rails.root, 'app', 'views', 'shared', 'reported_versions') 265 + search_path = Rails.root.join('app', 'views', 'shared', 'reported_versions')
266 partial_path = File.join('shared', 'reported_versions', partial_for_class_in_view_path(article.class, search_path)) 266 partial_path = File.join('shared', 'reported_versions', partial_for_class_in_view_path(article.class, search_path))
267 lambda { render_to_string(:partial => partial_path, :locals => {:article => article}) } 267 lambda { render_to_string(:partial => partial_path, :locals => {:article => article}) }
268 end 268 end
app/models/doc_item.rb
@@ -31,7 +31,7 @@ class DocItem @@ -31,7 +31,7 @@ class DocItem
31 search_path.unshift("/designs/themes/#{theme}#{translation}") # higher priority 31 search_path.unshift("/designs/themes/#{theme}#{translation}") # higher priority
32 search_path.push("/designs/themes/#{theme}#{image}") # lower priority 32 search_path.push("/designs/themes/#{theme}#{image}") # lower priority
33 end 33 end
34 - search_path.find {|file| File.exist?("#{Rails.root}/public#{file}") } 34 + search_path.find {|file| File.exist?(Rails.root.join('public', file[1..-1])) }
35 end 35 end
36 36
37 end 37 end
app/models/doc_section.rb
1 class DocSection < DocItem 1 class DocSection < DocItem
2 2
3 def self.root_dir 3 def self.root_dir
4 - @root_dir ||= File.join(Rails.root, 'doc', 'noosfero') 4 + @root_dir ||= Rails.root.join('doc', 'noosfero')
5 end 5 end
6 6
7 def items 7 def items
app/models/layout_template.rb
@@ -7,7 +7,7 @@ class LayoutTemplate @@ -7,7 +7,7 @@ class LayoutTemplate
7 end 7 end
8 8
9 def self.all 9 def self.all
10 - Dir.glob(File.join(Rails.root, 'public', 'designs', 'templates', '*')).map {|item| find(File.basename(item)) } 10 + Dir.glob(Rails.root.join('public', 'designs', 'templates', '*')).map {|item| find(File.basename(item)) }
11 end 11 end
12 12
13 attr_reader :id 13 attr_reader :id
@@ -34,7 +34,7 @@ class LayoutTemplate @@ -34,7 +34,7 @@ class LayoutTemplate
34 protected 34 protected
35 35
36 def read_config 36 def read_config
37 - @config = YAML.load_file(File.join(Rails.root, 'public', 'designs', 'templates', id, 'config.yml')) 37 + @config = YAML.load_file(Rails.root.join('public', 'designs', 'templates', id, 'config.yml'))
38 end 38 end
39 39
40 end 40 end
app/models/slideshow_block.rb
@@ -20,7 +20,7 @@ class SlideshowBlock &lt; Block @@ -20,7 +20,7 @@ class SlideshowBlock &lt; Block
20 20
21 def check_filename(image, size) 21 def check_filename(image, size)
22 filename = image.public_filename(size) 22 filename = image.public_filename(size)
23 - if File.exists?(File.join(Rails.root, 'public', filename)) 23 + if File.exists?(Rails.root.join('public', filename))
24 filename 24 filename
25 else 25 else
26 nil 26 nil
app/models/spammer_logger.rb
1 class SpammerLogger < Logger 1 class SpammerLogger < Logger
2 - @logpath = File.join(Rails.root, 'log', "#{ENV['RAILS_ENV']}_spammers.log") 2 + @logpath = Rails.root.join('log', "#{ENV['RAILS_ENV']}_spammers.log")
3 @logger = new(@logpath) 3 @logger = new(@logpath)
4 4
5 def self.log(spammer_ip, object=nil) 5 def self.log(spammer_ip, object=nil)
app/models/theme.rb
@@ -10,11 +10,11 @@ class Theme @@ -10,11 +10,11 @@ class Theme
10 end 10 end
11 11
12 def user_themes_dir 12 def user_themes_dir
13 - File.join(Rails.root, 'public', 'user_themes') 13 + Rails.root.join('public', 'user_themes')
14 end 14 end
15 15
16 def system_themes_dir 16 def system_themes_dir
17 - File.join(Rails.root, 'public', 'designs', 'themes') 17 + Rails.root.join('public', 'designs', 'themes')
18 end 18 end
19 19
20 def create(id, attributes = {}) 20 def create(id, attributes = {})
app/models/uploaded_file.rb
@@ -31,7 +31,7 @@ class UploadedFile &lt; Article @@ -31,7 +31,7 @@ class UploadedFile &lt; Article
31 end 31 end
32 32
33 def thumbnail_path 33 def thumbnail_path
34 - self.image? ? self.full_filename(:display).gsub(File.join(Rails.root, 'public'), '') : nil 34 + self.image? ? self.full_filename(:display).gsub(Rails.root.join('public'), '') : nil
35 end 35 end
36 36
37 def display_title 37 def display_title
app/views/layouts/_javascript.html.erb
@@ -8,6 +8,6 @@ @@ -8,6 +8,6 @@
8 <% language = FastGettext.locale %> 8 <% language = FastGettext.locale %>
9 <% %w{messages methods}.each do |type| %> 9 <% %w{messages methods}.each do |type| %>
10 <% require_path = File.join('jquery-validation', 'localization', type+'_'+language) %> 10 <% require_path = File.join('jquery-validation', 'localization', type+'_'+language) %>
11 - <% full_path = File.join(Rails.root, 'public', 'javascripts', require_path+'.js')%> 11 + <% full_path = Rails.root.join('public', 'javascripts', require_path+'.js')%>
12 <%= javascript_include_tag require_path if File.exists?(full_path) %> 12 <%= javascript_include_tag require_path if File.exists?(full_path) %>
13 <% end %> 13 <% end %>
config/application.rb
@@ -24,7 +24,7 @@ module Noosfero @@ -24,7 +24,7 @@ module Noosfero
24 # -- all .rb files in that directory are automatically loaded. 24 # -- all .rb files in that directory are automatically loaded.
25 25
26 # Custom directories with classes and modules you want to be autoloadable. 26 # Custom directories with classes and modules you want to be autoloadable.
27 - config.autoload_paths += %W( #{Rails.root}/app/sweepers ) 27 + config.autoload_paths += %W( #{Rails.root.join('app', 'sweepers')} )
28 config.autoload_paths += Dir["#{config.root}/lib/**/"] 28 config.autoload_paths += Dir["#{config.root}/lib/**/"]
29 config.autoload_paths += Dir["#{config.root}/app/controllers/**/"] 29 config.autoload_paths += Dir["#{config.root}/app/controllers/**/"]
30 30
config/environment.rb
@@ -7,7 +7,7 @@ require File.expand_path(&#39;../application&#39;, __FILE__) @@ -7,7 +7,7 @@ require File.expand_path(&#39;../application&#39;, __FILE__)
7 7
8 # extra directories for controllers organization 8 # extra directories for controllers organization
9 extra_controller_dirs = %w[ 9 extra_controller_dirs = %w[
10 -].map {|item| File.join(Rails.root, item) } 10 +].map {|item| Rails.root.join(item) }
11 11
12 # Add new inflection rules using the following format 12 # Add new inflection rules using the following format
13 # (all these examples are active by default): 13 # (all these examples are active by default):
@@ -32,7 +32,7 @@ require &#39;noosfero&#39; @@ -32,7 +32,7 @@ require &#39;noosfero&#39;
32 32
33 # load a local configuration if present, but not under test environment. 33 # load a local configuration if present, but not under test environment.
34 if !['test', 'cucumber'].include?(ENV['RAILS_ENV']) 34 if !['test', 'cucumber'].include?(ENV['RAILS_ENV'])
35 - localconfigfile = File.join(Rails.root, 'config', 'local.rb') 35 + localconfigfile = Rails.root.join('config', 'local.rb')
36 if File.exists?(localconfigfile) 36 if File.exists?(localconfigfile)
37 require localconfigfile 37 require localconfigfile
38 end 38 end
config/environments/cucumber.rb
@@ -20,7 +20,7 @@ config.action_controller.allow_forgery_protection = false @@ -20,7 +20,7 @@ config.action_controller.allow_forgery_protection = false
20 # ActionMailer::Base.deliveries array. 20 # ActionMailer::Base.deliveries array.
21 config.action_mailer.delivery_method = :test 21 config.action_mailer.delivery_method = :test
22 22
23 -config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))  
24 -config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))  
25 -config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara')) 23 +config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(Rails.root.join('vendor/plugins/cucumber-rails'))
  24 +config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(Rails.root.join('vendor/plugins/database_cleaner'))
  25 +config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(Rails.root.join('vendor/plugins/capybara'))
26 26
config/initializers/01_load_config.rb
1 -file = "#{Rails.root}/config/noosfero.yml" 1 +file = Rails.root.join('config', 'noosfero.yml')
2 NOOSFERO_CONF = File.exists?(file) ? YAML.load_file(file)[RAILS_ENV] || {} : {} 2 NOOSFERO_CONF = File.exists?(file) ? YAML.load_file(file)[RAILS_ENV] || {} : {}
config/initializers/default_icon_theme.rb
1 if File.writable?(Rails.root) 1 if File.writable?(Rails.root)
2 # create the symlink to the default theme if it does not exist 2 # create the symlink to the default theme if it does not exist
3 - default = File.join(Rails.root, 'public', 'designs', 'icons', 'default') 3 + default = Rails.root.join('public', 'designs', 'icons', 'default')
4 if !File.exists?(default) 4 if !File.exists?(default)
5 File.symlink('tango', default) 5 File.symlink('tango', default)
6 end 6 end
7 7
8 # create a symlink to system-wide Tango icon set if it does not exist 8 # create a symlink to system-wide Tango icon set if it does not exist
9 - tango_symlink = File.join(Rails.root, 'public', 'designs', 'icons', 'tango', 'Tango') 9 + tango_symlink = Rails.root.join('public', 'designs', 'icons', 'tango', 'Tango')
10 if !File.exist?(tango_symlink) 10 if !File.exist?(tango_symlink)
11 File.symlink('/usr/share/icons/Tango', tango_symlink) 11 File.symlink('/usr/share/icons/Tango', tango_symlink)
12 end 12 end
config/initializers/default_theme.rb
1 if File.writable?(Rails.root) 1 if File.writable?(Rails.root)
2 # create the symlink to the default theme if it does not exist 2 # create the symlink to the default theme if it does not exist
3 - default = File.join(Rails.root, 'public', 'designs', 'themes', 'default') 3 + default = Rails.root.join('public', 'designs', 'themes', 'default')
4 if !File.exists?(default) 4 if !File.exists?(default)
5 File.symlink('noosfero', default) 5 File.symlink('noosfero', default)
6 end 6 end
lib/noosfero.rb
@@ -63,7 +63,7 @@ module Noosfero @@ -63,7 +63,7 @@ module Noosfero
63 private 63 private
64 64
65 def self.controllers_in_directory(dir) 65 def self.controllers_in_directory(dir)
66 - app_controller_path = Dir.glob(File.join(Rails.root, 'app', 'controllers', dir, '*_controller.rb')) 66 + app_controller_path = Dir.glob(Rails.root.join('app', 'controllers', dir, '*_controller.rb'))
67 app_controller_path.map do |item| 67 app_controller_path.map do |item|
68 item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') 68 item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1')
69 end 69 end
lib/noosfero/multi_tenancy.rb
@@ -25,7 +25,7 @@ module Noosfero @@ -25,7 +25,7 @@ module Noosfero
25 private 25 private
26 26
27 def self.load_map 27 def self.load_map
28 - db_file = File.join(Rails.root, 'config', 'database.yml') 28 + db_file = Rails.root.join('config', 'database.yml')
29 db_config = YAML.load_file(db_file) 29 db_config = YAML.load_file(db_file)
30 map = { } 30 map = { }
31 db_config.each do |env, attr| 31 db_config.each do |env, attr|
@@ -36,7 +36,7 @@ module Noosfero @@ -36,7 +36,7 @@ module Noosfero
36 end 36 end
37 37
38 def self.is_hosted_environment? 38 def self.is_hosted_environment?
39 - db_file = File.join(Rails.root, 'config', 'database.yml') 39 + db_file = Rails.root.join('config', 'database.yml')
40 db_config = YAML.load_file(db_file) 40 db_config = YAML.load_file(db_file)
41 db_config.select{ |env, attr| Rails.env.to_s.match(/_#{env}$/) }.any? 41 db_config.select{ |env, attr| Rails.env.to_s.match(/_#{env}$/) }.any?
42 end 42 end
lib/noosfero/plugin.rb
@@ -69,9 +69,9 @@ class Noosfero::Plugin @@ -69,9 +69,9 @@ class Noosfero::Plugin
69 def enabled 69 def enabled
70 @enabled ||= 70 @enabled ||=
71 begin 71 begin
72 - plugins = Dir.glob(File.join(Rails.root, 'config', 'plugins', '*'))  
73 - if Rails.env.test? && !plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo'))  
74 - plugins << File.join(Rails.root, 'plugins', 'foo') 72 + plugins = Dir.glob(Rails.root.join('config', 'plugins', '*'))
  73 + if Rails.env.test? && !plugins.include?(Rails.root.join('config', 'plugins', 'foo'))
  74 + plugins << Rails.root.join('plugins', 'foo')
75 end 75 end
76 plugins.select do |entry| 76 plugins.select do |entry|
77 File.directory?(entry) 77 File.directory?(entry)
@@ -96,7 +96,7 @@ class Noosfero::Plugin @@ -96,7 +96,7 @@ class Noosfero::Plugin
96 end 96 end
97 97
98 def root_path 98 def root_path
99 - File.join(Rails.root, 'plugins', public_name) 99 + Rails.root.join('plugins', public_name)
100 end 100 end
101 101
102 def view_path 102 def view_path
@@ -122,7 +122,7 @@ class Noosfero::Plugin @@ -122,7 +122,7 @@ class Noosfero::Plugin
122 end 122 end
123 123
124 def expanded_template(file_path, locals = {}) 124 def expanded_template(file_path, locals = {})
125 - views_path = "#{Rails.root}/plugins/#{self.class.public_name}/views" 125 + views_path = Rails.root.join('plugins', "#{self.class.public_name}", 'views')
126 ERB.new(File.read("#{views_path}/#{file_path}")).result(binding) 126 ERB.new(File.read("#{views_path}/#{file_path}")).result(binding)
127 end 127 end
128 128
lib/noosfero/plugin/mailer_base.rb
1 class Noosfero::Plugin::MailerBase < ActionMailer::Base 1 class Noosfero::Plugin::MailerBase < ActionMailer::Base
2 2
3 def self.inherited(child) 3 def self.inherited(child)
4 - child.template_root = File.expand_path(File.join(Rails.root, 'plugins', child.plugin_name, 'views')) 4 + child.template_root = File.expand_path(Rails.root.join('plugins', child.plugin_name, 'views'))
5 end 5 end
6 6
7 def self.plugin_name 7 def self.plugin_name
lib/noosfero/plugin/routes.rb
1 plugins_root = Rails.env.test? ? 'plugins' : File.join('config', 'plugins') 1 plugins_root = Rails.env.test? ? 'plugins' : File.join('config', 'plugins')
2 2
3 -Dir.glob(File.join(Rails.root, plugins_root, '*', 'controllers')) do |controllers_dir| 3 +Dir.glob(Rails.root.join(plugins_root, '*', 'controllers')) do |controllers_dir|
4 prefixes_by_folder = {'public' => 'plugin', 4 prefixes_by_folder = {'public' => 'plugin',
5 'profile' => 'profile/:profile/plugin', 5 'profile' => 'profile/:profile/plugin',
6 'myprofile' => 'myprofile/:profile/plugin', 6 'myprofile' => 'myprofile/:profile/plugin',
lib/postgresql_attachment_fu.rb
@@ -10,7 +10,7 @@ module PostgresqlAttachmentFu @@ -10,7 +10,7 @@ module PostgresqlAttachmentFu
10 def full_filename(thumbnail = nil) 10 def full_filename(thumbnail = nil)
11 file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s 11 file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
12 file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on? 12 file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on?
13 - File.join(Rails.root, file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) 13 + Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail)))
14 end 14 end
15 end 15 end
16 16
lib/tasks/cucumber.rake
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks 8 unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9 9
10 -vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first 10 +vendored_cucumber_bin = Dir[Rails.root.join('vendor', '{gems,plugins}', 'cucumber*', 'bin', 'cucumber')].first
11 $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? 11 $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12 12
13 begin 13 begin
lib/tasks/doc.rake
@@ -5,12 +5,12 @@ namespace :noosfero do @@ -5,12 +5,12 @@ namespace :noosfero do
5 end 5 end
6 task :link_plugins_textiles do 6 task :link_plugins_textiles do
7 plugins_textiles.each do |file| 7 plugins_textiles.each do |file|
8 - ln_sf File.join(Rails.root, file), 'doc/noosfero/plugins/' 8 + ln_sf Rails.root.join(file), 'doc/noosfero/plugins/'
9 end 9 end
10 end 10 end
11 task :unlink_plugins_textiles do 11 task :unlink_plugins_textiles do
12 - rm_f Dir.glob(File.join(Rails.root, 'doc/noosfero/plugins/*.textile')) -  
13 - [File.join(Rails.root, 'doc/noosfero/plugins/index.textile')] 12 + rm_f Dir.glob(Rails.root.join('doc/noosfero/plugins/*.textile')) -
  13 + [Rails.root.join('doc/noosfero/plugins/index.textile')]
14 end 14 end
15 input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"} 15 input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"}
16 topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq 16 topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq
lib/tasks/error_messages.rake
1 -templates = Dir.glob(Rails.root + '/public/*.html.erb') 1 +templates = Dir.glob(Rails.root.join('public', '*.html.erb'))
2 targets = [] 2 targets = []
3 templates.each do |template| 3 templates.each do |template|
4 target = template.gsub(/.erb$/, '') 4 target = template.gsub(/.erb$/, '')
lib/tasks/gettext.rake
@@ -21,14 +21,14 @@ task :symlinkmo do @@ -21,14 +21,14 @@ task :symlinkmo do
21 langmap = { 21 langmap = {
22 'pt' => 'pt_BR', 22 'pt' => 'pt_BR',
23 } 23 }
24 - mkdir_p(File.join(Rails.root, 'locale'))  
25 - Dir.glob(File.join(Rails.root, 'locale/*')).each do |dir| 24 + mkdir_p(Rails.root.join('locale'))
  25 + Dir.glob(Rails.root.join('locale/*')).each do |dir|
26 lang = File.basename(dir) 26 lang = File.basename(dir)
27 orig_lang = langmap[lang] || lang 27 orig_lang = langmap[lang] || lang
28 - mkdir_p("#{Rails.root}/locale/#{lang}/LC_MESSAGES") 28 + mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES'))
29 ['iso_3166'].each do |domain| 29 ['iso_3166'].each do |domain|
30 origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo" 30 origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo"
31 - target = "#{Rails.root}/locale/#{lang}/LC_MESSAGES/#{domain}.mo" 31 + target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo")
32 if !File.symlink?(target) 32 if !File.symlink?(target)
33 ln_s origin, target 33 ln_s origin, target
34 end 34 end
lib/tasks/multitenancy.rake
@@ -2,14 +2,14 @@ namespace :multitenancy do @@ -2,14 +2,14 @@ namespace :multitenancy do
2 2
3 task :create do 3 task :create do
4 db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } 4 db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
5 - cd File.join(Rails.root, 'config', 'environments'), :verbose => true 5 + cd Rails.root.join('config', 'environments'), :verbose => true
6 file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" 6 file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}"
7 (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } 7 (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env }
8 end 8 end
9 9
10 task :remove do 10 task :remove do
11 db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } 11 db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
12 - cd File.join(Rails.root, 'config', 'environments'), :verbose => true 12 + cd Rails.root.join('config', 'environments'), :verbose => true
13 file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" 13 file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}"
14 (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } 14 (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env }
15 end 15 end
lib/tasks/plugins.rake
1 namespace :noosfero do 1 namespace :noosfero do
2 namespace :plugins do 2 namespace :plugins do
3 - plugin_migration_dirs = Dir.glob(File.join(Rails.root, 'config', 'plugins', '*', 'db', 'migrate')) 3 + plugin_migration_dirs = Dir.glob(Rails.root.join('config', 'plugins', '*', 'db', 'migrate'))
4 task :migrate do 4 task :migrate do
5 plugin_migration_dirs.each do |path| 5 plugin_migration_dirs.each do |path|
6 ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) 6 ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
lib/tasks/po.rake
@@ -25,7 +25,7 @@ namespace :po do @@ -25,7 +25,7 @@ namespace :po do
25 puts "+----------+----------+------------+--------+--------------+" 25 puts "+----------+----------+------------+--------+--------------+"
26 puts "| Language | Messages | Translated | Fuzzy | Untranslated |" 26 puts "| Language | Messages | Translated | Fuzzy | Untranslated |"
27 puts "+----------+----------+------------+--------+--------------+" 27 puts "+----------+----------+------------+--------+--------------+"
28 - Dir.glob(Rails.root + '/po/*/noosfero.po').each do |file| 28 + Dir.glob(Rails.root.join('po', '*', 'noosfero.po')).each do |file|
29 language = File.basename(File.dirname(file)) 29 language = File.basename(File.dirname(file))
30 output = `msgfmt --output /dev/null --statistics #{file} 2>&1` 30 output = `msgfmt --output /dev/null --statistics #{file} 2>&1`
31 translated = extract_po_stat('translated', output) 31 translated = extract_po_stat('translated', output)
lib/tasks/test_rcov.rake
@@ -22,8 +22,8 @@ namespace :test do @@ -22,8 +22,8 @@ namespace :test do
22 task :rcov do |t| 22 task :rcov do |t|
23 require 'rbconfig' 23 require 'rbconfig'
24 24
25 - tests = Dir.glob(File.join(Rails.root, 'test', '*', '*_test.rb'))  
26 - outdir = File.join(Rails.root, 'coverage') 25 + tests = Dir.glob(Rails.root.join('test', '*', '*_test.rb'))
  26 + outdir = Rails.root.join('coverage')
27 test_loader = File.join(Config::CONFIG['rubylibdir'], 'rake', 'rake_test_loader.rb') 27 test_loader = File.join(Config::CONFIG['rubylibdir'], 'rake', 'rake_test_loader.rb')
28 28
29 system("rcov", '-o', outdir, '-T', '-x', 'rubygems/*,rcov*', '--rails', '-Ilib:test', test_loader, *tests) 29 system("rcov", '-o', outdir, '-T', '-x', 'rubygems/*,rcov*', '--rails', '-Ilib:test', test_loader, *tests)
script/reset_db
1 #!/usr/bin/env ruby 1 #!/usr/bin/env ruby
2 require File.dirname(__FILE__) + '/../config/environment' 2 require File.dirname(__FILE__) + '/../config/environment'
3 3
4 -system "rm #{Rails.root}/tmp/*.db"  
5 -system "rm #{Rails.root}/db/*.db"  
6 -system "rm -rf #{Rails.root}/public/articles" 4 +system "rm #{Rails.root.join('tmp', '*.db')}"
  5 +system "rm #{Rails.root.join('db', '*.db')}"
  6 +system "rm -rf #{Rails.root.join('public', 'articles')}"
7 system "rake db:migrate VERSION=0" 7 system "rake db:migrate VERSION=0"
8 system "rake db:migrate" 8 system "rake db:migrate"
9 -system "#{Rails.root}/script/anhetegua" 9 +system "#{Rails.root.join('script', 'anhetegua')}"
10 system "rake db:test:prepare" 10 system "rake db:test:prepare"
test/factories.rb
@@ -264,7 +264,7 @@ module Noosfero::Factory @@ -264,7 +264,7 @@ module Noosfero::Factory
264 # ExternalFeed 264 # ExternalFeed
265 ############################################### 265 ###############################################
266 def defaults_for_external_feed 266 def defaults_for_external_feed
267 - { :address => Rails.root + '/test/fixtures/files/feed.xml', :blog_id => factory_num_seq } 267 + { :address => Rails.root.join('test', 'fixtures', 'files', 'feed.xml'), :blog_id => factory_num_seq }
268 end 268 end
269 269
270 def create_external_feed(attrs = {}) 270 def create_external_feed(attrs = {})
@@ -278,7 +278,7 @@ module Noosfero::Factory @@ -278,7 +278,7 @@ module Noosfero::Factory
278 # FeedReaderBlock 278 # FeedReaderBlock
279 ############################################### 279 ###############################################
280 def defaults_for_feed_reader_block 280 def defaults_for_feed_reader_block
281 - { :address => File.join(Rails.root, 'test/fixtures/files/feed.xml') } 281 + { :address => Rails.root.join('test/fixtures/files/feed.xml') }
282 end 282 end
283 283
284 ############################################### 284 ###############################################
test/functional/themes_controller_test.rb
@@ -25,7 +25,7 @@ class ThemesControllerTest &lt; ActionController::TestCase @@ -25,7 +25,7 @@ class ThemesControllerTest &lt; ActionController::TestCase
25 FileUtils.rm_rf(TMP_THEMES_DIR) 25 FileUtils.rm_rf(TMP_THEMES_DIR)
26 end 26 end
27 27
28 - TMP_THEMES_DIR = Rails.root + '/test/tmp/themes_controller' 28 + TMP_THEMES_DIR = Rails.root.join("test", "tmp", "themes_controller")
29 29
30 should 'display themes that can be applied' do 30 should 'display themes that can be applied' do
31 env = Environment.default 31 env = Environment.default
@@ -216,7 +216,7 @@ class ThemesControllerTest &lt; ActionController::TestCase @@ -216,7 +216,7 @@ class ThemesControllerTest &lt; ActionController::TestCase
216 post :add_image, :profile => 'testinguser', :id => 'mytheme', :image => fixture_file_upload('/files/rails.png', 'image/png', :binary) 216 post :add_image, :profile => 'testinguser', :id => 'mytheme', :image => fixture_file_upload('/files/rails.png', 'image/png', :binary)
217 assert_redirected_to :action => "edit", :id => 'mytheme' 217 assert_redirected_to :action => "edit", :id => 'mytheme'
218 assert theme.image_files.include?('rails.png') 218 assert theme.image_files.include?('rails.png')
219 - 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') 219 + 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')
220 end 220 end
221 221
222 should 'link to "test theme"' do 222 should 'link to "test theme"' do
test/integration/controller_naming_test.rb
@@ -3,7 +3,7 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot; @@ -3,7 +3,7 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot;
3 class ControllerNamingTest < ActionController::IntegrationTest 3 class ControllerNamingTest < ActionController::IntegrationTest
4 4
5 should 'not have controllers with same name in different folders' do 5 should 'not have controllers with same name in different folders' do
6 - controllers = Dir.glob("#{Rails.root}/app/controllers/**/*_controller.rb").map { |item| item.split(/\//).last } 6 + controllers = Dir.glob(Rails.root.join("app", "controllers", "**", "*_controller.rb")).map { |item| item.split(/\//).last }
7 assert_equal controllers.uniq, controllers 7 assert_equal controllers.uniq, controllers
8 end 8 end
9 9
test/integration/tiny_mce_languages_test.rb
@@ -11,7 +11,7 @@ class TinyMceLanguagesTest &lt; ActionController::IntegrationTest @@ -11,7 +11,7 @@ class TinyMceLanguagesTest &lt; ActionController::IntegrationTest
11 end 11 end
12 12
13 def assert_exists_tinymce_language_file(file) 13 def assert_exists_tinymce_language_file(file)
14 - filename = Rails.root + "/public/javascripts/tinymce/jscripts/tiny_mce/" + file 14 + filename = Rails.root.join("public", "javascripts", "tinymce", "jscripts", "tiny_mce", file)
15 assert(File.exists?(filename), filename + " must exist") 15 assert(File.exists?(filename), filename + " must exist")
16 end 16 end
17 17
test/noosfero_doc_test.rb
@@ -4,7 +4,7 @@ require &#39;mocha&#39; @@ -4,7 +4,7 @@ require &#39;mocha&#39;
4 module Noosfero::DocTest 4 module Noosfero::DocTest
5 5
6 unless defined?(ROOT) 6 unless defined?(ROOT)
7 - ROOT = File.join(Rails.root, "test", "tmp", "doc") 7 + ROOT = Rails.root.join("test", "tmp", "doc")
8 end 8 end
9 9
10 def create_doc(section, topic, language, title, body = nil) 10 def create_doc(section, topic, language, title, body = nil)
test/test_helper.rb
@@ -12,7 +12,7 @@ require File.dirname(__FILE__) + &#39;/factories&#39; @@ -12,7 +12,7 @@ require File.dirname(__FILE__) + &#39;/factories&#39;
12 require File.dirname(__FILE__) + '/noosfero_doc_test' 12 require File.dirname(__FILE__) + '/noosfero_doc_test'
13 require File.dirname(__FILE__) + '/action_tracker_test_helper' 13 require File.dirname(__FILE__) + '/action_tracker_test_helper'
14 14
15 -FileUtils.rm_rf(File.join(Rails.root, 'index', 'test')) 15 +FileUtils.rm_rf(Rails.root.join('index', 'test'))
16 16
17 Image.attachment_options[:path_prefix] = 'test/tmp/public/images' 17 Image.attachment_options[:path_prefix] = 'test/tmp/public/images'
18 Thumbnail.attachment_options[:path_prefix] = 'test/tmp/public/thumbnails' 18 Thumbnail.attachment_options[:path_prefix] = 'test/tmp/public/thumbnails'
@@ -54,7 +54,7 @@ class ActiveSupport::TestCase @@ -54,7 +54,7 @@ class ActiveSupport::TestCase
54 fixtures :environments, :roles 54 fixtures :environments, :roles
55 55
56 def self.all_fixtures 56 def self.all_fixtures
57 - Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.yml')).each do |item| 57 + Dir.glob(Rails.root.join('test', 'fixtures', '*.yml')).each do |item|
58 fixtures File.basename(item).sub(/\.yml$/, '').to_s 58 fixtures File.basename(item).sub(/\.yml$/, '').to_s
59 end 59 end
60 end 60 end
@@ -145,7 +145,7 @@ class ActiveSupport::TestCase @@ -145,7 +145,7 @@ class ActiveSupport::TestCase
145 patch ? patch[1] : nil 145 patch ? patch[1] : nil
146 end.compact 146 end.compact
147 s.each do |css_ref| 147 s.each do |css_ref|
148 - if ! File.exists?( Rails.root.to_s() +'/public/'+ css_ref ) 148 + if ! File.exists?(Rails.root.join('public', css_ref ))
149 flunk 'CSS reference missed on HTML: "%s"' % css_ref 149 flunk 'CSS reference missed on HTML: "%s"' % css_ref
150 end 150 end
151 end 151 end
@@ -154,7 +154,7 @@ class ActiveSupport::TestCase @@ -154,7 +154,7 @@ class ActiveSupport::TestCase
154 # Test image references: 154 # Test image references:
155 (doc/'img').each do |img| 155 (doc/'img').each do |img|
156 src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '') 156 src = img.get_attribute( 'src' ).gsub(/\?[0-9]+$/, '')
157 - if ! File.exists?( Rails.root.to_s() +'/public/'+ src ) 157 + if ! File.exists?(Rails.root.join('public', src))
158 flunk 'Image reference missed on HTML: "%s"' % src 158 flunk 'Image reference missed on HTML: "%s"' % src
159 end 159 end
160 end 160 end
test/unit/application_helper_test.rb
@@ -55,10 +55,10 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -55,10 +55,10 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
55 end 55 end
56 56
57 should 'look for superclasses on view_for_profile actions' do 57 should 'look for superclasses on view_for_profile actions' do
58 - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/float.rhtml").returns(false)  
59 - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/float.html.erb").returns(false)  
60 - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/numeric.rhtml").returns(false)  
61 - File.expects(:exists?).with("#{Rails.root}/app/views/blocks/profile_info_actions/numeric.html.erb").returns(true) 58 + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'float.rhtml')).returns(false)
  59 + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'float.html.erb')).returns(false)
  60 + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'numeric.rhtml')).returns(false)
  61 + File.expects(:exists?).with(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', 'numeric.html.erb')).returns(true)
62 62
63 assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float) 63 assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float)
64 end 64 end
@@ -70,13 +70,13 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -70,13 +70,13 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
70 end 70 end
71 71
72 should 'generate link to stylesheet' do 72 should 'generate link to stylesheet' do
73 - File.expects(:exists?).with(File.join(Rails.root, 'public', 'stylesheets', 'something.css')).returns(true) 73 + File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(true)
74 expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') 74 expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css')
75 assert_match '@import url(/stylesheets/something.css)', stylesheet_import('something') 75 assert_match '@import url(/stylesheets/something.css)', stylesheet_import('something')
76 end 76 end
77 77
78 should 'not generate link to unexisting stylesheet' do 78 should 'not generate link to unexisting stylesheet' do
79 - File.expects(:exists?).with(File.join(Rails.root, 'public', 'stylesheets', 'something.css')).returns(false) 79 + File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(false)
80 expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') 80 expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css')
81 assert_no_match %r{@import url(/stylesheets/something.css)}, stylesheet_import('something') 81 assert_no_match %r{@import url(/stylesheets/something.css)}, stylesheet_import('something')
82 end 82 end
@@ -175,7 +175,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -175,7 +175,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
175 175
176 should 'render theme footer' do 176 should 'render theme footer' do
177 stubs(:theme_path).returns('/user_themes/mytheme') 177 stubs(:theme_path).returns('/user_themes/mytheme')
178 - footer_path = Rails.root + '/public/user_themes/mytheme/footer.rhtml' 178 + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml')
179 179
180 File.expects(:exists?).with(footer_path).returns(true) 180 File.expects(:exists?).with(footer_path).returns(true)
181 expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI") 181 expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI")
@@ -185,8 +185,8 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -185,8 +185,8 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
185 185
186 should 'ignore unexisting theme footer' do 186 should 'ignore unexisting theme footer' do
187 stubs(:theme_path).returns('/user_themes/mytheme') 187 stubs(:theme_path).returns('/user_themes/mytheme')
188 - footer_path = Rails.root + '/public/user_themes/mytheme/footer.rhtml'  
189 - alternate_footer_path = Rails.root + '/public/user_themes/mytheme/footer.html.erb' 188 + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml')
  189 + alternate_footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.html.erb')
190 190
191 File.expects(:exists?).with(footer_path).returns(false) 191 File.expects(:exists?).with(footer_path).returns(false)
192 File.expects(:exists?).with(alternate_footer_path).returns(false) 192 File.expects(:exists?).with(alternate_footer_path).returns(false)
@@ -197,7 +197,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -197,7 +197,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
197 197
198 should 'render theme site title' do 198 should 'render theme site title' do
199 stubs(:theme_path).returns('/user_themes/mytheme') 199 stubs(:theme_path).returns('/user_themes/mytheme')
200 - site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.rhtml' 200 + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml')
201 201
202 File.expects(:exists?).with(site_title_path).returns(true) 202 File.expects(:exists?).with(site_title_path).returns(true)
203 expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title") 203 expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title")
@@ -207,8 +207,8 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -207,8 +207,8 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
207 207
208 should 'ignore unexisting theme site title' do 208 should 'ignore unexisting theme site title' do
209 stubs(:theme_path).returns('/user_themes/mytheme') 209 stubs(:theme_path).returns('/user_themes/mytheme')
210 - site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.rhtml'  
211 - alternate_site_title_path = Rails.root + '/public/user_themes/mytheme/site_title.html.erb' 210 + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml')
  211 + alternate_site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.html.erb')
212 212
213 File.expects(:exists?).with(site_title_path).returns(false) 213 File.expects(:exists?).with(site_title_path).returns(false)
214 File.expects(:exists?).with(alternate_site_title_path).returns(false) 214 File.expects(:exists?).with(alternate_site_title_path).returns(false)
@@ -571,7 +571,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -571,7 +571,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
571 should 'use favicon from profile theme if the profile has theme' do 571 should 'use favicon from profile theme if the profile has theme' do
572 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) 572 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme'))
573 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) 573 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme'))
574 - File.expects(:exists?).with(File.join(Rails.root, 'public', '/designs/themes/profile-theme', 'favicon.ico')).returns(true) 574 + File.expects(:exists?).with(Rails.root.join('public', '/designs/themes/profile-theme', 'favicon.ico')).returns(true)
575 assert_equal '/designs/themes/profile-theme/favicon.ico', theme_favicon 575 assert_equal '/designs/themes/profile-theme/favicon.ico', theme_favicon
576 end 576 end
577 577
@@ -579,7 +579,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -579,7 +579,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
579 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) 579 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme'))
580 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) 580 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme'))
581 file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/favicon.ico', 'image/x-ico'), :profile => profile) 581 file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/favicon.ico', 'image/x-ico'), :profile => profile)
582 - File.expects(:exists?).with(File.join(Rails.root, 'public', theme_path, 'favicon.ico')).returns(false) 582 + File.expects(:exists?).with(Rails.root.join('public', theme_path, 'favicon.ico')).returns(false)
583 583
584 assert_match /favicon.ico/, theme_favicon 584 assert_match /favicon.ico/, theme_favicon
585 end 585 end
@@ -587,7 +587,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -587,7 +587,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
587 should 'use favicon from environment if the profile theme and profile articles do not have' do 587 should 'use favicon from environment if the profile theme and profile articles do not have' do
588 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) 588 stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme'))
589 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) 589 stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme'))
590 - File.expects(:exists?).with(File.join(Rails.root, 'public', theme_path, 'favicon.ico')).returns(false) 590 + File.expects(:exists?).with(Rails.root.join('public', theme_path, 'favicon.ico')).returns(false)
591 assert_equal '/designs/themes/new-theme/favicon.ico', theme_favicon 591 assert_equal '/designs/themes/new-theme/favicon.ico', theme_favicon
592 end 592 end
593 593
@@ -597,7 +597,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase @@ -597,7 +597,7 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
597 stubs(:environment).returns(env) 597 stubs(:environment).returns(env)
598 598
599 @controller = ApplicationController.new 599 @controller = ApplicationController.new
600 - path = File.join(Rails.root, 'app', 'views') 600 + path = Rails.root.join('app', 'views')
601 @controller.stubs(:view_paths).returns([path]) 601 @controller.stubs(:view_paths).returns([path])
602 602
603 file = path + '/shared/usermenu/xmpp_chat.rhtml' 603 file = path + '/shared/usermenu/xmpp_chat.rhtml'
test/unit/colorbox_helper_test.rb
@@ -5,8 +5,8 @@ class ColorboxHelperTest &lt; ActiveSupport::TestCase @@ -5,8 +5,8 @@ class ColorboxHelperTest &lt; ActiveSupport::TestCase
5 include ColorboxHelper 5 include ColorboxHelper
6 6
7 should 'provide the needed files' do 7 should 'provide the needed files' do
8 - assert File.exists?(File.join(Rails.root, 'public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found'  
9 - assert File.exists?(File.join(Rails.root, 'public', 'javascripts', 'colorbox.js')), 'colorbox.js expected to be in public/javascripts, but not found' 8 + assert File.exists?(Rails.root.join('public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found'
  9 + assert File.exists?(Rails.root.join('public', 'javascripts', 'colorbox.js')), 'colorbox.js expected to be in public/javascripts, but not found'
10 end 10 end
11 11
12 should 'provide link to close colorbox' do 12 should 'provide link to close colorbox' do
test/unit/comment_test.rb
@@ -214,7 +214,7 @@ class CommentTest &lt; ActiveSupport::TestCase @@ -214,7 +214,7 @@ class CommentTest &lt; ActiveSupport::TestCase
214 214
215 should 'use an existing image for deleted comments' do 215 should 'use an existing image for deleted comments' do
216 image = Comment.new.removed_user_image 216 image = Comment.new.removed_user_image
217 - assert File.exists?(File.join(Rails.root, 'public', image)), "#{image} does not exist." 217 + assert File.exists?(Rails.root.join('public', image)), "#{image} does not exist."
218 end 218 end
219 219
220 should 'have the action_tracker_target defined' do 220 should 'have the action_tracker_target defined' do
test/unit/doc_item_test.rb
@@ -27,10 +27,10 @@ class DocItemTest &lt; ActiveSupport::TestCase @@ -27,10 +27,10 @@ class DocItemTest &lt; ActiveSupport::TestCase
27 27
28 should 'translate images' do 28 should 'translate images' do
29 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>') 29 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>')
30 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.pt.png').returns(false) 30 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.pt.png')).returns(false)
31 assert_equal doc.text, doc.html 31 assert_equal doc.text, doc.html
32 32
33 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.pt.png').returns(true) 33 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.pt.png')).returns(true)
34 assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html) 34 assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html)
35 end 35 end
36 36
@@ -38,8 +38,8 @@ class DocItemTest &lt; ActiveSupport::TestCase @@ -38,8 +38,8 @@ class DocItemTest &lt; ActiveSupport::TestCase
38 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>') 38 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>')
39 39
40 # the image exists in both the system *and* on the theme 40 # the image exists in both the system *and* on the theme
41 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.pt.png').returns(true)  
42 - File.stubs(:exist?).with(Rails.root + '/public/designs/themes/mytheme/images/doc/myimage.pt.png').returns(true) 41 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.pt.png')).returns(true)
  42 + File.stubs(:exist?).with(Rails.root.join('public', 'designs', 'themes', 'mytheme', 'images', 'doc', 'myimage.pt.png')).returns(true)
43 # the one in the theme must be used 43 # the one in the theme must be used
44 assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.pt.png"/, doc.html('mytheme')) 44 assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.pt.png"/, doc.html('mytheme'))
45 end 45 end
@@ -48,9 +48,9 @@ class DocItemTest &lt; ActiveSupport::TestCase @@ -48,9 +48,9 @@ class DocItemTest &lt; ActiveSupport::TestCase
48 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>') 48 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>')
49 49
50 # the image has a translation in the system but not in the theme 50 # the image has a translation in the system but not in the theme
51 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.pt.png').returns(true)  
52 - File.stubs(:exist?).with(Rails.root + '/public/designs/themes/mytheme/images/doc/myimage.en.png').returns(false)  
53 - File.stubs(:exist?).with(Rails.root + '/public/designs/themes/mytheme/images/doc/myimage.pt.png').returns(false) 51 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.pt.png')).returns(true)
  52 + File.stubs(:exist?).with(Rails.root.join('public', 'designs', 'themes', 'mytheme', 'images', 'doc', 'myimage.en.png')).returns(false)
  53 + File.stubs(:exist?).with(Rails.root.join('public', 'designs', 'themes', 'mytheme', 'images', 'doc', 'myimage.pt.png')).returns(false)
54 # the one in the theme must be used 54 # the one in the theme must be used
55 assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html('mytheme')) 55 assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html('mytheme'))
56 end 56 end
@@ -59,10 +59,10 @@ class DocItemTest &lt; ActiveSupport::TestCase @@ -59,10 +59,10 @@ class DocItemTest &lt; ActiveSupport::TestCase
59 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>') 59 doc = DocItem.new(:language => 'pt', :text => '<p>Look the image:</p><p><img src="/images/doc/myimage.en.png" alt="The image"/></p>')
60 60
61 # the image has no translation, but both system and theme provide an image 61 # the image has no translation, but both system and theme provide an image
62 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.en.png').returns(true)  
63 - File.stubs(:exist?).with(Rails.root + '/public/images/doc/myimage.pt.png').returns(false)  
64 - File.stubs(:exist?).with(Rails.root + '/public/designs/themes/mytheme/images/doc/myimage.en.png').returns(true)  
65 - File.stubs(:exist?).with(Rails.root + '/public/designs/themes/mytheme/images/doc/myimage.pt.png').returns(false) 62 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.en.png')).returns(true)
  63 + File.stubs(:exist?).with(Rails.root.join('public', 'images', 'doc', 'myimage.pt.png')).returns(false)
  64 + File.stubs(:exist?).with(Rails.root.join('public', 'designs', 'themes', 'mytheme', 'images', 'doc', 'myimage.en.png')).returns(true)
  65 + File.stubs(:exist?).with(Rails.root.join('public', 'designs', 'themes', 'mytheme', 'images', 'doc', 'myimage.pt.png')).returns(false)
66 # the one in the theme must be used 66 # the one in the theme must be used
67 assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.en.png"/, doc.html('mytheme')) 67 assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.en.png"/, doc.html('mytheme'))
68 end 68 end
test/unit/doc_topic_test.rb
@@ -7,7 +7,7 @@ class DocTopicTest &lt; ActiveSupport::TestCase @@ -7,7 +7,7 @@ class DocTopicTest &lt; ActiveSupport::TestCase
7 end 7 end
8 8
9 should 'load topic data from file' do 9 should 'load topic data from file' do
10 - doc = DocTopic.loadfile(Rails.root + '/' + 'test/fixtures/files/doctest.en.xhtml') 10 + doc = DocTopic.loadfile(Rails.root.join('test', 'fixtures', 'files', 'doctest.en.xhtml'))
11 assert_equal 'en', doc.language 11 assert_equal 'en', doc.language
12 assert_equal 'Documentation test', doc.title 12 assert_equal 'Documentation test', doc.title
13 assert_match(/Documentation test/, doc.text) 13 assert_match(/Documentation test/, doc.text)
@@ -15,7 +15,7 @@ class DocTopicTest &lt; ActiveSupport::TestCase @@ -15,7 +15,7 @@ class DocTopicTest &lt; ActiveSupport::TestCase
15 end 15 end
16 16
17 should 'load translated topic from file' do 17 should 'load translated topic from file' do
18 - doc = DocTopic.loadfile(Rails.root + '/' + 'test/fixtures/files/doctest.pt.xhtml') 18 + doc = DocTopic.loadfile(Rails.root.join('test', 'fixtures', 'files', 'doctest.pt.xhtml'))
19 assert_equal 'pt', doc.language 19 assert_equal 'pt', doc.language
20 assert_equal 'Teste da documentação', doc.title 20 assert_equal 'Teste da documentação', doc.title
21 end 21 end
test/unit/feed_handler_test.rb
@@ -90,7 +90,7 @@ class FeedHandlerTest &lt; ActiveSupport::TestCase @@ -90,7 +90,7 @@ class FeedHandlerTest &lt; ActiveSupport::TestCase
90 [:external_feed, :feed_reader_block].each do |container_class| 90 [:external_feed, :feed_reader_block].each do |container_class|
91 91
92 should "reset the errors count after a successfull run (#{container_class})" do 92 should "reset the errors count after a successfull run (#{container_class})" do
93 - container = create(container_class, :update_errors => 1, :address => File.join(Rails.root, 'test/fixtures/files/feed.xml')) 93 + container = create(container_class, :update_errors => 1, :address => Rails.root.join('test/fixtures/files/feed.xml'))
94 handler.expects(:actually_process_container).with(container) 94 handler.expects(:actually_process_container).with(container)
95 handler.process(container) 95 handler.process(container)
96 assert_equal 0, container.update_errors 96 assert_equal 0, container.update_errors
test/unit/folder_helper_test.rb
@@ -126,7 +126,7 @@ class FolderHelperTest &lt; ActionView::TestCase @@ -126,7 +126,7 @@ class FolderHelperTest &lt; ActionView::TestCase
126 126
127 private 127 private
128 def render(template, the_binding) 128 def render(template, the_binding)
129 - ERB.new(File.read(File.join(Rails.root, 'app/views', template + '.html.erb'))).result(the_binding) 129 + ERB.new(File.read(Rails.root.join('app/views', template + '.html.erb'))).result(the_binding)
130 end 130 end
131 131
132 end 132 end
test/unit/image_test.rb
@@ -84,7 +84,7 @@ class ImageTest &lt; ActiveSupport::TestCase @@ -84,7 +84,7 @@ class ImageTest &lt; ActiveSupport::TestCase
84 84
85 should 'have a loading image to each size of thumbnails' do 85 should 'have a loading image to each size of thumbnails' do
86 Image.attachment_options[:thumbnails].each do |suffix, size| 86 Image.attachment_options[:thumbnails].each do |suffix, size|
87 - image = File.join(Rails.root, "public/images/icons-app/image-loading-#{suffix}.png") 87 + image = Rails.root.join("public/images/icons-app/image-loading-#{suffix}.png")
88 assert File.exists?(image), "#{image} should exist." 88 assert File.exists?(image), "#{image} should exist."
89 end 89 end
90 end 90 end
test/unit/layout_template_test.rb
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39; @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39;
3 class LayoutTemplateTest < ActiveSupport::TestCase 3 class LayoutTemplateTest < ActiveSupport::TestCase
4 4
5 should 'read configuration' do 5 should 'read configuration' do
6 - YAML.expects(:load_file).with(File.join(Rails.root, 'public/designs/templates/default/config.yml')).returns({'number_of_boxes' => 3, 'description' => 'my description', 'title' => 'my title'}) 6 + YAML.expects(:load_file).with(Rails.root.join('public/designs/templates/default/config.yml')).returns({'number_of_boxes' => 3, 'description' => 'my description', 'title' => 'my title'})
7 t = LayoutTemplate.find('default') 7 t = LayoutTemplate.find('default')
8 assert_equal 3, t.number_of_boxes 8 assert_equal 3, t.number_of_boxes
9 assert_equal 'my description', t.description 9 assert_equal 'my description', t.description
@@ -11,9 +11,9 @@ class LayoutTemplateTest &lt; ActiveSupport::TestCase @@ -11,9 +11,9 @@ class LayoutTemplateTest &lt; ActiveSupport::TestCase
11 end 11 end
12 12
13 should 'list all' do 13 should 'list all' do
14 - Dir.expects(:glob).with(File.join(Rails.root, 'public/designs/templates/*')).returns([File.join(Rails.root, 'public/designs/templates/one'), File.join(Rails.root, 'public/designs/templates/two')])  
15 - YAML.expects(:load_file).with(File.join(Rails.root, 'public/designs/templates/one/config.yml')).returns({})  
16 - YAML.expects(:load_file).with(File.join(Rails.root, 'public/designs/templates/two/config.yml')).returns({}) 14 + Dir.expects(:glob).with(Rails.root.join('public/designs/templates/*')).returns([Rails.root.join('public/designs/templates/one'), Rails.root.join('public/designs/templates/two')])
  15 + YAML.expects(:load_file).with(Rails.root.join('public/designs/templates/one/config.yml')).returns({})
  16 + YAML.expects(:load_file).with(Rails.root.join('public/designs/templates/two/config.yml')).returns({})
17 17
18 all = LayoutTemplate.all 18 all = LayoutTemplate.all
19 assert_equivalent [ 'one', 'two' ], all.map(&:id) 19 assert_equivalent [ 'one', 'two' ], all.map(&:id)
test/unit/lightbox_helper_test.rb
@@ -9,8 +9,8 @@ class LightboxHelperTest &lt; ActiveSupport::TestCase @@ -9,8 +9,8 @@ class LightboxHelperTest &lt; ActiveSupport::TestCase
9 end 9 end
10 10
11 should 'provide the needed files' do 11 should 'provide the needed files' do
12 - assert File.exists?(File.join(Rails.root, 'public', 'stylesheets', 'lightbox.css')), 'lightbox.css expected to be in public/stylesheets, but not found'  
13 - assert File.exists?(File.join(Rails.root, 'public', 'javascripts', 'lightbox.js')), 'lightbox.js expected to be in public/javascripts, but not found' 12 + assert File.exists?(Rails.root.join('public', 'stylesheets', 'lightbox.css')), 'lightbox.css expected to be in public/stylesheets, but not found'
  13 + assert File.exists?(Rails.root.join('public', 'javascripts', 'lightbox.js')), 'lightbox.js expected to be in public/javascripts, but not found'
14 end 14 end
15 15
16 should 'provide lightbox_link_to helper' do 16 should 'provide lightbox_link_to helper' do
test/unit/noosfero_i18n_test.rb
@@ -16,7 +16,7 @@ class NoosferoI18nTest &lt; ActiveSupport::TestCase @@ -16,7 +16,7 @@ class NoosferoI18nTest &lt; ActiveSupport::TestCase
16 16
17 should('have locale file for %s' % locale) do 17 should('have locale file for %s' % locale) do
18 locale_file = 'config/locales/%s.yml' % locale 18 locale_file = 'config/locales/%s.yml' % locale
19 - assert File.exists?(File.join(Rails.root, locale_file)), "#{locale_file} not found" 19 + assert File.exists?(Rails.root.join(locale_file)), "#{locale_file} not found"
20 end 20 end
21 21
22 should('be able to translate activerecord errors header to %s' % locale) do 22 should('be able to translate activerecord errors header to %s' % locale) do
test/unit/noosfero_test.rb
@@ -4,12 +4,12 @@ require &#39;noosfero&#39; @@ -4,12 +4,12 @@ require &#39;noosfero&#39;
4 class NoosferoTest < ActiveSupport::TestCase 4 class NoosferoTest < ActiveSupport::TestCase
5 5
6 def test_should_list_controllers_in_directory 6 def test_should_list_controllers_in_directory
7 - Dir.expects(:glob).with("#{Rails.root}/app/controllers/lala/*_controller.rb").returns(["app/controllers/lala/system_admin_controller.rb", "app/controllers/lala/environment_admin_controller.rb", "app/controllers/lala/public_controller.rb", "app/controllers/lala/profile_admin_controller.rb"]).once 7 + Dir.expects(:glob).with(Rails.root.join('app', 'controllers', 'lala', '*_controller.rb')).returns(["app', 'controllers', 'lala', 'system_admin_controller.rb", "app', 'controllers', 'lala', 'environment_admin_controller.rb", "app', 'controllers', 'lala', 'public_controller.rb", "app', 'controllers', 'lala', 'profile_admin_controller.rb"]).once
8 assert_equal ["system_admin", "environment_admin", "public", "profile_admin"], Noosfero.controllers_in_directory('lala') 8 assert_equal ["system_admin", "environment_admin", "public", "profile_admin"], Noosfero.controllers_in_directory('lala')
9 end 9 end
10 10
11 def test_should_generate_pattern_for_controllers_in_directory 11 def test_should_generate_pattern_for_controllers_in_directory
12 - Dir.expects(:glob).with("#{Rails.root}/app/controllers/lala/*_controller.rb").returns(["app/controllers/lala/system_admin_controller.rb", "app/controllers/lala/environment_admin_controller.rb", "app/controllers/lala/public_controller.rb", "app/controllers/lala/profile_admin_controller.rb"]).once 12 + Dir.expects(:glob).with(Rails.root.join('app', 'controllers', 'lala', '*_controller.rb')).returns(["app', 'controllers', 'lala', 'system_admin_controller.rb", "app', 'controllers', 'lala', 'environment_admin_controller.rb", "app', 'controllers', 'lala', 'public_controller.rb", "app', 'controllers', 'lala', 'profile_admin_controller.rb"]).once
13 assert_equal(/(system_admin|environment_admin|public|profile_admin)/, Noosfero.pattern_for_controllers_in_directory('lala')) 13 assert_equal(/(system_admin|environment_admin|public|profile_admin)/, Noosfero.pattern_for_controllers_in_directory('lala'))
14 end 14 end
15 15
test/unit/profile_test.rb
@@ -1080,7 +1080,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1080,7 +1080,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1080 assert_equal 'default title', p.boxes[0].blocks.first[:title] 1080 assert_equal 'default title', p.boxes[0].blocks.first[:title]
1081 end 1081 end
1082 1082
1083 - TMP_THEMES_DIR = Rails.root + '/test/tmp/profile_themes' 1083 + TMP_THEMES_DIR = Rails.root.join('test', 'tmp', 'profile_themes')
1084 should 'have themes' do 1084 should 'have themes' do
1085 Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) 1085 Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR)
1086 1086
test/unit/slideshow_block_test.rb
@@ -75,7 +75,7 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase @@ -75,7 +75,7 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase
75 should 'decide correct public filename for image' do 75 should 'decide correct public filename for image' do
76 image = mock 76 image = mock
77 image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png') 77 image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png')
78 - File.expects(:exists?).with("#{Rails.root}/public/bli/slideshow.png").returns(true) 78 + File.expects(:exists?).with(Rails.root.join('public', 'bli', 'slideshow.png')).returns(true)
79 79
80 assert_equal '/bli/slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image) 80 assert_equal '/bli/slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image)
81 end 81 end
@@ -83,7 +83,7 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase @@ -83,7 +83,7 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase
83 should 'display the default slideshow image if thumbnails were not processed' do 83 should 'display the default slideshow image if thumbnails were not processed' do
84 image = mock 84 image = mock
85 image.expects(:public_filename).with('slideshow').returns('/images/icons-app/image-loading-slideshow.png') 85 image.expects(:public_filename).with('slideshow').returns('/images/icons-app/image-loading-slideshow.png')
86 - File.expects(:exists?).with("#{Rails.root}/public/images/icons-app/image-loading-slideshow.png").returns(true) 86 + File.expects(:exists?).with(Rails.root.join('public', 'images', 'icons-app', 'image-loading-slideshow.png')).returns(true)
87 87
88 assert_equal '/images/icons-app/image-loading-slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image) 88 assert_equal '/images/icons-app/image-loading-slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image)
89 end 89 end
@@ -94,11 +94,11 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase @@ -94,11 +94,11 @@ class SlideshowBlockTest &lt; ActiveSupport::TestCase
94 image = mock 94 image = mock
95 # "slideshow" size does not exist 95 # "slideshow" size does not exist
96 image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png') 96 image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png')
97 - File.expects(:exists?).with("#{Rails.root}/public/bli/slideshow.png").returns(false) # <<<<< 97 + File.expects(:exists?).with(Rails.root.join('public', 'bli', 'slideshow.png')).returns(false) # <<<<<
98 98
99 # thumb size does exist 99 # thumb size does exist
100 image.expects(:public_filename).with('thumb').returns('/bli/thumb.png') 100 image.expects(:public_filename).with('thumb').returns('/bli/thumb.png')
101 - File.expects(:exists?).with("#{Rails.root}/public/bli/thumb.png").returns(true) # <<<<< 101 + File.expects(:exists?).with(Rails.root.join('public', 'bli', 'thumb.png')).returns(true) # <<<<<
102 102
103 assert_equal '/bli/thumb.png', block.public_filename_for(image) 103 assert_equal '/bli/thumb.png', block.public_filename_for(image)
104 end 104 end
test/unit/theme_test.rb
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39; @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39;
2 2
3 class ThemeTest < ActiveSupport::TestCase 3 class ThemeTest < ActiveSupport::TestCase
4 4
5 - TMP_THEMES_DIR = Rails.root + '/test/tmp/themes' 5 + TMP_THEMES_DIR = Rails.root.join('test', 'tmp', 'themes')
6 6
7 def setup 7 def setup
8 Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) 8 Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR)
@@ -13,11 +13,11 @@ class ThemeTest &lt; ActiveSupport::TestCase @@ -13,11 +13,11 @@ class ThemeTest &lt; ActiveSupport::TestCase
13 end 13 end
14 14
15 should 'list system themes' do 15 should 'list system themes' do
16 - Dir.expects(:glob).with(Rails.root + '/public/designs/themes/*').returns( 16 + Dir.expects(:glob).with(Rails.root.join('public', 'designs', 'themes', '*')).returns(
17 [ 17 [
18 - Rails.root + '/public/designs/themes/themeone',  
19 - Rails.root + '/public/designs/themes/themetwo',  
20 - Rails.root + '/public/designs/themes/themethree' 18 + Rails.root.join('public', 'designs', 'themes', 'themeone'),
  19 + Rails.root.join('public', 'designs', 'themes', 'themetwo'),
  20 + Rails.root.join('public', 'designs', 'themes', 'themethree')
21 ]) 21 ])
22 22
23 assert_equal ['themeone', 'themetwo', 'themethree'], Theme.system_themes.map(&:id) 23 assert_equal ['themeone', 'themetwo', 'themethree'], Theme.system_themes.map(&:id)
test/unit/uploaded_file_test.rb
@@ -223,7 +223,7 @@ class UploadedFileTest &lt; ActiveSupport::TestCase @@ -223,7 +223,7 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
223 223
224 should 'have a loading image to each size of thumbnails' do 224 should 'have a loading image to each size of thumbnails' do
225 UploadedFile.attachment_options[:thumbnails].each do |suffix, size| 225 UploadedFile.attachment_options[:thumbnails].each do |suffix, size|
226 - image = Rails.root + '/public/images/icons-app/image-loading-%s.png' % suffix 226 + image = Rails.root.join('public', 'images', 'icons-app', "image-loading-#{suffix}.png")
227 assert File.exists?(image) 227 assert File.exists?(image)
228 end 228 end
229 end 229 end
@@ -231,10 +231,10 @@ class UploadedFileTest &lt; ActiveSupport::TestCase @@ -231,10 +231,10 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
231 should 'return a thumbnail for images' do 231 should 'return a thumbnail for images' do
232 f = UploadedFile.new 232 f = UploadedFile.new
233 f.expects(:image?).returns(true) 233 f.expects(:image?).returns(true)
234 - f.expects(:full_filename).with(:display).returns(File.join(Rails.root, 'public', 'images', '0000', '0005', 'x.png')) 234 + f.expects(:full_filename).with(:display).returns(Rails.root.join('public', 'images', '0000', '0005', 'x.png'))
235 assert_equal '/images/0000/0005/x.png', f.thumbnail_path 235 assert_equal '/images/0000/0005/x.png', f.thumbnail_path
236 f = UploadedFile.new 236 f = UploadedFile.new
237 - f.stubs(:full_filename).with(:display).returns(File.join(Rails.root, 'public', 'images', '0000', '0005', 'x.png')) 237 + f.stubs(:full_filename).with(:display).returns(Rails.root.join('public', 'images', '0000', '0005', 'x.png'))
238 f.expects(:image?).returns(false) 238 f.expects(:image?).returns(false)
239 assert_nil f.thumbnail_path 239 assert_nil f.thumbnail_path
240 end 240 end