Commit 9e0087a15ab9a73c8284e0bd91bd9a007c7d75a3
1 parent
e227e0e3
Exists in
master
and in
27 other branches
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 | 19 | def avatar |
20 | 20 | profile = environment.profiles.find_by_identifier(params[:id]) |
21 | 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 | 23 | render :text => data, :layout => false, :content_type => mimetype |
24 | 24 | expires_in 24.hours |
25 | 25 | end | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -310,7 +310,7 @@ module ApplicationHelper |
310 | 310 | raise ArgumentError, 'No profile actions view for this class.' if klass.nil? |
311 | 311 | |
312 | 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 | 315 | view_for_profile_actions(klass.superclass) |
316 | 316 | end |
... | ... | @@ -328,7 +328,7 @@ module ApplicationHelper |
328 | 328 | "\n" + |
329 | 329 | sources.flatten.map do |source| |
330 | 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 | 332 | "@import url(#{filename});\n" |
333 | 333 | else |
334 | 334 | "/* Not included: url(#{filename}) */\n" |
... | ... | @@ -372,7 +372,7 @@ module ApplicationHelper |
372 | 372 | if Rails.env == 'development' && environment.theme == 'random' |
373 | 373 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand |
374 | 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 | 376 | params[:theme] |
377 | 377 | else |
378 | 378 | if profile && !profile.theme.nil? |
... | ... | @@ -398,7 +398,7 @@ module ApplicationHelper |
398 | 398 | # XXX Since we cannot control what people are doing in external themes, we |
399 | 399 | # will keep looking for the deprecated .rhtml extension here. |
400 | 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 | 402 | if File.exists?(file) |
403 | 403 | return render :file => file, :use_full_path => false |
404 | 404 | end |
... | ... | @@ -408,7 +408,7 @@ module ApplicationHelper |
408 | 408 | |
409 | 409 | def theme_favicon |
410 | 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 | 412 | '/designs/themes/' + profile.theme + '/favicon.ico' |
413 | 413 | else |
414 | 414 | favicon = profile.articles.find_by_path('favicon.ico') |
... | ... | @@ -478,7 +478,7 @@ module ApplicationHelper |
478 | 478 | end |
479 | 479 | |
480 | 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 | 482 | theme_path + icon |
483 | 483 | else |
484 | 484 | icon |
... | ... | @@ -503,7 +503,7 @@ module ApplicationHelper |
503 | 503 | compact.uniq.map do |c| |
504 | 504 | cat_name = c.gsub( /[-_\s,.;'"]+/, '_' ) |
505 | 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 | 507 | cat_icon = '/images/icons-cat/undefined.png' |
508 | 508 | end |
509 | 509 | content_tag('span', |
... | ... | @@ -711,7 +711,7 @@ module ApplicationHelper |
711 | 711 | |
712 | 712 | def theme_javascript_ng |
713 | 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 | 715 | javascript_include_tag script |
716 | 716 | else |
717 | 717 | nil |
... | ... | @@ -923,7 +923,7 @@ module ApplicationHelper |
923 | 923 | theme_icon_themes = theme_option(:icon_theme) || [] |
924 | 924 | for icon_theme in theme_icon_themes do |
925 | 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 | 927 | icon_themes << theme_path |
928 | 928 | end |
929 | 929 | end |
... | ... | @@ -1116,7 +1116,7 @@ module ApplicationHelper |
1116 | 1116 | def render_environment_features(folder) |
1117 | 1117 | result = '' |
1118 | 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 | 1120 | if File.exists?(file) |
1121 | 1121 | result << render(:file => file, :use_full_path => false) |
1122 | 1122 | end | ... | ... |
app/helpers/content_viewer_helper.rb
... | ... | @@ -62,7 +62,7 @@ module ContentViewerHelper |
62 | 62 | end |
63 | 63 | |
64 | 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 | 66 | image_tag(File.join(theme_path, 'images', 'addthis.gif'), :border => 0, :alt => '') |
67 | 67 | else |
68 | 68 | image_tag("/images/bt-bookmark.gif", :width => 53, :height => 16, :border => 0, :alt => '') | ... | ... |
app/helpers/display_helper.rb
app/helpers/layout_helper.rb
... | ... | @@ -69,7 +69,7 @@ module LayoutHelper |
69 | 69 | theme_icon_themes = theme_option(:icon_theme) || [] |
70 | 70 | for icon_theme in theme_icon_themes do |
71 | 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 | 73 | icon_themes << theme_path |
74 | 74 | end |
75 | 75 | end | ... | ... |
app/models/article.rb
... | ... | @@ -262,7 +262,7 @@ class Article < ActiveRecord::Base |
262 | 262 | |
263 | 263 | def reported_version(options = {}) |
264 | 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 | 266 | partial_path = File.join('shared', 'reported_versions', partial_for_class_in_view_path(article.class, search_path)) |
267 | 267 | lambda { render_to_string(:partial => partial_path, :locals => {:article => article}) } |
268 | 268 | end | ... | ... |
app/models/doc_item.rb
... | ... | @@ -31,7 +31,7 @@ class DocItem |
31 | 31 | search_path.unshift("/designs/themes/#{theme}#{translation}") # higher priority |
32 | 32 | search_path.push("/designs/themes/#{theme}#{image}") # lower priority |
33 | 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 | 35 | end |
36 | 36 | |
37 | 37 | end | ... | ... |
app/models/doc_section.rb
app/models/layout_template.rb
... | ... | @@ -7,7 +7,7 @@ class LayoutTemplate |
7 | 7 | end |
8 | 8 | |
9 | 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 | 11 | end |
12 | 12 | |
13 | 13 | attr_reader :id |
... | ... | @@ -34,7 +34,7 @@ class LayoutTemplate |
34 | 34 | protected |
35 | 35 | |
36 | 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 | 38 | end |
39 | 39 | |
40 | 40 | end | ... | ... |
app/models/slideshow_block.rb
... | ... | @@ -20,7 +20,7 @@ class SlideshowBlock < Block |
20 | 20 | |
21 | 21 | def check_filename(image, size) |
22 | 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 | 24 | filename |
25 | 25 | else |
26 | 26 | nil | ... | ... |
app/models/spammer_logger.rb
app/models/theme.rb
... | ... | @@ -10,11 +10,11 @@ class Theme |
10 | 10 | end |
11 | 11 | |
12 | 12 | def user_themes_dir |
13 | - File.join(Rails.root, 'public', 'user_themes') | |
13 | + Rails.root.join('public', 'user_themes') | |
14 | 14 | end |
15 | 15 | |
16 | 16 | def system_themes_dir |
17 | - File.join(Rails.root, 'public', 'designs', 'themes') | |
17 | + Rails.root.join('public', 'designs', 'themes') | |
18 | 18 | end |
19 | 19 | |
20 | 20 | def create(id, attributes = {}) | ... | ... |
app/models/uploaded_file.rb
... | ... | @@ -31,7 +31,7 @@ class UploadedFile < Article |
31 | 31 | end |
32 | 32 | |
33 | 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 | 35 | end |
36 | 36 | |
37 | 37 | def display_title | ... | ... |
app/views/layouts/_javascript.html.erb
... | ... | @@ -8,6 +8,6 @@ |
8 | 8 | <% language = FastGettext.locale %> |
9 | 9 | <% %w{messages methods}.each do |type| %> |
10 | 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 | 12 | <%= javascript_include_tag require_path if File.exists?(full_path) %> |
13 | 13 | <% end %> | ... | ... |
config/application.rb
... | ... | @@ -24,7 +24,7 @@ module Noosfero |
24 | 24 | # -- all .rb files in that directory are automatically loaded. |
25 | 25 | |
26 | 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 | 28 | config.autoload_paths += Dir["#{config.root}/lib/**/"] |
29 | 29 | config.autoload_paths += Dir["#{config.root}/app/controllers/**/"] |
30 | 30 | ... | ... |
config/environment.rb
... | ... | @@ -7,7 +7,7 @@ require File.expand_path('../application', __FILE__) |
7 | 7 | |
8 | 8 | # extra directories for controllers organization |
9 | 9 | extra_controller_dirs = %w[ |
10 | -].map {|item| File.join(Rails.root, item) } | |
10 | +].map {|item| Rails.root.join(item) } | |
11 | 11 | |
12 | 12 | # Add new inflection rules using the following format |
13 | 13 | # (all these examples are active by default): |
... | ... | @@ -32,7 +32,7 @@ require 'noosfero' |
32 | 32 | |
33 | 33 | # load a local configuration if present, but not under test environment. |
34 | 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 | 36 | if File.exists?(localconfigfile) |
37 | 37 | require localconfigfile |
38 | 38 | end | ... | ... |
config/environments/cucumber.rb
... | ... | @@ -20,7 +20,7 @@ config.action_controller.allow_forgery_protection = false |
20 | 20 | # ActionMailer::Base.deliveries array. |
21 | 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
config/initializers/default_icon_theme.rb
1 | 1 | if File.writable?(Rails.root) |
2 | 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 | 4 | if !File.exists?(default) |
5 | 5 | File.symlink('tango', default) |
6 | 6 | end |
7 | 7 | |
8 | 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 | 10 | if !File.exist?(tango_symlink) |
11 | 11 | File.symlink('/usr/share/icons/Tango', tango_symlink) |
12 | 12 | end | ... | ... |
config/initializers/default_theme.rb
1 | 1 | if File.writable?(Rails.root) |
2 | 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 | 4 | if !File.exists?(default) |
5 | 5 | File.symlink('noosfero', default) |
6 | 6 | end | ... | ... |
lib/noosfero.rb
... | ... | @@ -63,7 +63,7 @@ module Noosfero |
63 | 63 | private |
64 | 64 | |
65 | 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 | 67 | app_controller_path.map do |item| |
68 | 68 | item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') |
69 | 69 | end | ... | ... |
lib/noosfero/multi_tenancy.rb
... | ... | @@ -25,7 +25,7 @@ module Noosfero |
25 | 25 | private |
26 | 26 | |
27 | 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 | 29 | db_config = YAML.load_file(db_file) |
30 | 30 | map = { } |
31 | 31 | db_config.each do |env, attr| |
... | ... | @@ -36,7 +36,7 @@ module Noosfero |
36 | 36 | end |
37 | 37 | |
38 | 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 | 40 | db_config = YAML.load_file(db_file) |
41 | 41 | db_config.select{ |env, attr| Rails.env.to_s.match(/_#{env}$/) }.any? |
42 | 42 | end | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -69,9 +69,9 @@ class Noosfero::Plugin |
69 | 69 | def enabled |
70 | 70 | @enabled ||= |
71 | 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 | 75 | end |
76 | 76 | plugins.select do |entry| |
77 | 77 | File.directory?(entry) |
... | ... | @@ -96,7 +96,7 @@ class Noosfero::Plugin |
96 | 96 | end |
97 | 97 | |
98 | 98 | def root_path |
99 | - File.join(Rails.root, 'plugins', public_name) | |
99 | + Rails.root.join('plugins', public_name) | |
100 | 100 | end |
101 | 101 | |
102 | 102 | def view_path |
... | ... | @@ -122,7 +122,7 @@ class Noosfero::Plugin |
122 | 122 | end |
123 | 123 | |
124 | 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 | 126 | ERB.new(File.read("#{views_path}/#{file_path}")).result(binding) |
127 | 127 | end |
128 | 128 | ... | ... |
lib/noosfero/plugin/mailer_base.rb
1 | 1 | class Noosfero::Plugin::MailerBase < ActionMailer::Base |
2 | 2 | |
3 | 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 | 5 | end |
6 | 6 | |
7 | 7 | def self.plugin_name | ... | ... |
lib/noosfero/plugin/routes.rb
1 | 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 | 4 | prefixes_by_folder = {'public' => 'plugin', |
5 | 5 | 'profile' => 'profile/:profile/plugin', |
6 | 6 | 'myprofile' => 'myprofile/:profile/plugin', | ... | ... |
lib/postgresql_attachment_fu.rb
... | ... | @@ -10,7 +10,7 @@ module PostgresqlAttachmentFu |
10 | 10 | def full_filename(thumbnail = nil) |
11 | 11 | file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s |
12 | 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 | 14 | end |
15 | 15 | end |
16 | 16 | ... | ... |
lib/tasks/cucumber.rake
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | |
8 | 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 | 11 | $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? |
12 | 12 | |
13 | 13 | begin | ... | ... |
lib/tasks/doc.rake
... | ... | @@ -5,12 +5,12 @@ namespace :noosfero do |
5 | 5 | end |
6 | 6 | task :link_plugins_textiles do |
7 | 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 | 9 | end |
10 | 10 | end |
11 | 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 | 14 | end |
15 | 15 | input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"} |
16 | 16 | topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq | ... | ... |
lib/tasks/error_messages.rake
lib/tasks/gettext.rake
... | ... | @@ -21,14 +21,14 @@ task :symlinkmo do |
21 | 21 | langmap = { |
22 | 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 | 26 | lang = File.basename(dir) |
27 | 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 | 29 | ['iso_3166'].each do |domain| |
30 | 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 | 32 | if !File.symlink?(target) |
33 | 33 | ln_s origin, target |
34 | 34 | end | ... | ... |
lib/tasks/multitenancy.rake
... | ... | @@ -2,14 +2,14 @@ namespace :multitenancy do |
2 | 2 | |
3 | 3 | task :create do |
4 | 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 | 6 | file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" |
7 | 7 | (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } |
8 | 8 | end |
9 | 9 | |
10 | 10 | task :remove do |
11 | 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 | 13 | file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}" |
14 | 14 | (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } |
15 | 15 | end | ... | ... |
lib/tasks/plugins.rake
1 | 1 | namespace :noosfero do |
2 | 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 | 4 | task :migrate do |
5 | 5 | plugin_migration_dirs.each do |path| |
6 | 6 | ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) | ... | ... |
lib/tasks/po.rake
... | ... | @@ -25,7 +25,7 @@ namespace :po do |
25 | 25 | puts "+----------+----------+------------+--------+--------------+" |
26 | 26 | puts "| Language | Messages | Translated | Fuzzy | Untranslated |" |
27 | 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 | 29 | language = File.basename(File.dirname(file)) |
30 | 30 | output = `msgfmt --output /dev/null --statistics #{file} 2>&1` |
31 | 31 | translated = extract_po_stat('translated', output) | ... | ... |
lib/tasks/test_rcov.rake
... | ... | @@ -22,8 +22,8 @@ namespace :test do |
22 | 22 | task :rcov do |t| |
23 | 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 | 27 | test_loader = File.join(Config::CONFIG['rubylibdir'], 'rake', 'rake_test_loader.rb') |
28 | 28 | |
29 | 29 | system("rcov", '-o', outdir, '-T', '-x', 'rubygems/*,rcov*', '--rails', '-Ilib:test', test_loader, *tests) | ... | ... |
script/reset_db
1 | 1 | #!/usr/bin/env ruby |
2 | 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 | 7 | system "rake db:migrate VERSION=0" |
8 | 8 | system "rake db:migrate" |
9 | -system "#{Rails.root}/script/anhetegua" | |
9 | +system "#{Rails.root.join('script', 'anhetegua')}" | |
10 | 10 | system "rake db:test:prepare" | ... | ... |
test/factories.rb
... | ... | @@ -264,7 +264,7 @@ module Noosfero::Factory |
264 | 264 | # ExternalFeed |
265 | 265 | ############################################### |
266 | 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 | 268 | end |
269 | 269 | |
270 | 270 | def create_external_feed(attrs = {}) |
... | ... | @@ -278,7 +278,7 @@ module Noosfero::Factory |
278 | 278 | # FeedReaderBlock |
279 | 279 | ############################################### |
280 | 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 | 282 | end |
283 | 283 | |
284 | 284 | ############################################### | ... | ... |
test/functional/themes_controller_test.rb
... | ... | @@ -25,7 +25,7 @@ class ThemesControllerTest < ActionController::TestCase |
25 | 25 | FileUtils.rm_rf(TMP_THEMES_DIR) |
26 | 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 | 30 | should 'display themes that can be applied' do |
31 | 31 | env = Environment.default |
... | ... | @@ -216,7 +216,7 @@ class ThemesControllerTest < ActionController::TestCase |
216 | 216 | post :add_image, :profile => 'testinguser', :id => 'mytheme', :image => fixture_file_upload('/files/rails.png', 'image/png', :binary) |
217 | 217 | assert_redirected_to :action => "edit", :id => 'mytheme' |
218 | 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 | 220 | end |
221 | 221 | |
222 | 222 | should 'link to "test theme"' do | ... | ... |
test/integration/controller_naming_test.rb
... | ... | @@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" |
3 | 3 | class ControllerNamingTest < ActionController::IntegrationTest |
4 | 4 | |
5 | 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 | 7 | assert_equal controllers.uniq, controllers |
8 | 8 | end |
9 | 9 | ... | ... |
test/integration/tiny_mce_languages_test.rb
... | ... | @@ -11,7 +11,7 @@ class TinyMceLanguagesTest < ActionController::IntegrationTest |
11 | 11 | end |
12 | 12 | |
13 | 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 | 15 | assert(File.exists?(filename), filename + " must exist") |
16 | 16 | end |
17 | 17 | ... | ... |
test/noosfero_doc_test.rb
test/test_helper.rb
... | ... | @@ -12,7 +12,7 @@ require File.dirname(__FILE__) + '/factories' |
12 | 12 | require File.dirname(__FILE__) + '/noosfero_doc_test' |
13 | 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 | 17 | Image.attachment_options[:path_prefix] = 'test/tmp/public/images' |
18 | 18 | Thumbnail.attachment_options[:path_prefix] = 'test/tmp/public/thumbnails' |
... | ... | @@ -54,7 +54,7 @@ class ActiveSupport::TestCase |
54 | 54 | fixtures :environments, :roles |
55 | 55 | |
56 | 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 | 58 | fixtures File.basename(item).sub(/\.yml$/, '').to_s |
59 | 59 | end |
60 | 60 | end |
... | ... | @@ -145,7 +145,7 @@ class ActiveSupport::TestCase |
145 | 145 | patch ? patch[1] : nil |
146 | 146 | end.compact |
147 | 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 | 149 | flunk 'CSS reference missed on HTML: "%s"' % css_ref |
150 | 150 | end |
151 | 151 | end |
... | ... | @@ -154,7 +154,7 @@ class ActiveSupport::TestCase |
154 | 154 | # Test image references: |
155 | 155 | (doc/'img').each do |img| |
156 | 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 | 158 | flunk 'Image reference missed on HTML: "%s"' % src |
159 | 159 | end |
160 | 160 | end | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -55,10 +55,10 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
55 | 55 | end |
56 | 56 | |
57 | 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 | 63 | assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float) |
64 | 64 | end |
... | ... | @@ -70,13 +70,13 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
70 | 70 | end |
71 | 71 | |
72 | 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 | 74 | expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') |
75 | 75 | assert_match '@import url(/stylesheets/something.css)', stylesheet_import('something') |
76 | 76 | end |
77 | 77 | |
78 | 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 | 80 | expects(:filename_for_stylesheet).with('something', nil).returns('/stylesheets/something.css') |
81 | 81 | assert_no_match %r{@import url(/stylesheets/something.css)}, stylesheet_import('something') |
82 | 82 | end |
... | ... | @@ -175,7 +175,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
175 | 175 | |
176 | 176 | should 'render theme footer' do |
177 | 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 | 180 | File.expects(:exists?).with(footer_path).returns(true) |
181 | 181 | expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI") |
... | ... | @@ -185,8 +185,8 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
185 | 185 | |
186 | 186 | should 'ignore unexisting theme footer' do |
187 | 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 | 191 | File.expects(:exists?).with(footer_path).returns(false) |
192 | 192 | File.expects(:exists?).with(alternate_footer_path).returns(false) |
... | ... | @@ -197,7 +197,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
197 | 197 | |
198 | 198 | should 'render theme site title' do |
199 | 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 | 202 | File.expects(:exists?).with(site_title_path).returns(true) |
203 | 203 | expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title") |
... | ... | @@ -207,8 +207,8 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
207 | 207 | |
208 | 208 | should 'ignore unexisting theme site title' do |
209 | 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 | 213 | File.expects(:exists?).with(site_title_path).returns(false) |
214 | 214 | File.expects(:exists?).with(alternate_site_title_path).returns(false) |
... | ... | @@ -571,7 +571,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
571 | 571 | should 'use favicon from profile theme if the profile has theme' do |
572 | 572 | stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) |
573 | 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 | 575 | assert_equal '/designs/themes/profile-theme/favicon.ico', theme_favicon |
576 | 576 | end |
577 | 577 | |
... | ... | @@ -579,7 +579,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
579 | 579 | stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) |
580 | 580 | stubs(:profile).returns(fast_create(Profile, :theme => 'profile-theme')) |
581 | 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 | 584 | assert_match /favicon.ico/, theme_favicon |
585 | 585 | end |
... | ... | @@ -587,7 +587,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
587 | 587 | should 'use favicon from environment if the profile theme and profile articles do not have' do |
588 | 588 | stubs(:environment).returns(fast_create(Environment, :theme => 'new-theme')) |
589 | 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 | 591 | assert_equal '/designs/themes/new-theme/favicon.ico', theme_favicon |
592 | 592 | end |
593 | 593 | |
... | ... | @@ -597,7 +597,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
597 | 597 | stubs(:environment).returns(env) |
598 | 598 | |
599 | 599 | @controller = ApplicationController.new |
600 | - path = File.join(Rails.root, 'app', 'views') | |
600 | + path = Rails.root.join('app', 'views') | |
601 | 601 | @controller.stubs(:view_paths).returns([path]) |
602 | 602 | |
603 | 603 | file = path + '/shared/usermenu/xmpp_chat.rhtml' | ... | ... |
test/unit/colorbox_helper_test.rb
... | ... | @@ -5,8 +5,8 @@ class ColorboxHelperTest < ActiveSupport::TestCase |
5 | 5 | include ColorboxHelper |
6 | 6 | |
7 | 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 | 10 | end |
11 | 11 | |
12 | 12 | should 'provide link to close colorbox' do | ... | ... |
test/unit/comment_test.rb
... | ... | @@ -214,7 +214,7 @@ class CommentTest < ActiveSupport::TestCase |
214 | 214 | |
215 | 215 | should 'use an existing image for deleted comments' do |
216 | 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 | 218 | end |
219 | 219 | |
220 | 220 | should 'have the action_tracker_target defined' do | ... | ... |
test/unit/doc_item_test.rb
... | ... | @@ -27,10 +27,10 @@ class DocItemTest < ActiveSupport::TestCase |
27 | 27 | |
28 | 28 | should 'translate images' do |
29 | 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 | 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 | 34 | assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html) |
35 | 35 | end |
36 | 36 | |
... | ... | @@ -38,8 +38,8 @@ class DocItemTest < ActiveSupport::TestCase |
38 | 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 | 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 | 43 | # the one in the theme must be used |
44 | 44 | assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.pt.png"/, doc.html('mytheme')) |
45 | 45 | end |
... | ... | @@ -48,9 +48,9 @@ class DocItemTest < ActiveSupport::TestCase |
48 | 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 | 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 | 54 | # the one in the theme must be used |
55 | 55 | assert_match(/<img src="\/images\/doc\/myimage.pt.png"/, doc.html('mytheme')) |
56 | 56 | end |
... | ... | @@ -59,10 +59,10 @@ class DocItemTest < ActiveSupport::TestCase |
59 | 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 | 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 | 66 | # the one in the theme must be used |
67 | 67 | assert_match(/<img src="\/designs\/themes\/mytheme\/images\/doc\/myimage.en.png"/, doc.html('mytheme')) |
68 | 68 | end | ... | ... |
test/unit/doc_topic_test.rb
... | ... | @@ -7,7 +7,7 @@ class DocTopicTest < ActiveSupport::TestCase |
7 | 7 | end |
8 | 8 | |
9 | 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 | 11 | assert_equal 'en', doc.language |
12 | 12 | assert_equal 'Documentation test', doc.title |
13 | 13 | assert_match(/Documentation test/, doc.text) |
... | ... | @@ -15,7 +15,7 @@ class DocTopicTest < ActiveSupport::TestCase |
15 | 15 | end |
16 | 16 | |
17 | 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 | 19 | assert_equal 'pt', doc.language |
20 | 20 | assert_equal 'Teste da documentação', doc.title |
21 | 21 | end | ... | ... |
test/unit/feed_handler_test.rb
... | ... | @@ -90,7 +90,7 @@ class FeedHandlerTest < ActiveSupport::TestCase |
90 | 90 | [:external_feed, :feed_reader_block].each do |container_class| |
91 | 91 | |
92 | 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 | 94 | handler.expects(:actually_process_container).with(container) |
95 | 95 | handler.process(container) |
96 | 96 | assert_equal 0, container.update_errors | ... | ... |
test/unit/folder_helper_test.rb
... | ... | @@ -126,7 +126,7 @@ class FolderHelperTest < ActionView::TestCase |
126 | 126 | |
127 | 127 | private |
128 | 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 | 130 | end |
131 | 131 | |
132 | 132 | end | ... | ... |
test/unit/image_test.rb
... | ... | @@ -84,7 +84,7 @@ class ImageTest < ActiveSupport::TestCase |
84 | 84 | |
85 | 85 | should 'have a loading image to each size of thumbnails' do |
86 | 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 | 88 | assert File.exists?(image), "#{image} should exist." |
89 | 89 | end |
90 | 90 | end | ... | ... |
test/unit/layout_template_test.rb
... | ... | @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper' |
3 | 3 | class LayoutTemplateTest < ActiveSupport::TestCase |
4 | 4 | |
5 | 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 | 7 | t = LayoutTemplate.find('default') |
8 | 8 | assert_equal 3, t.number_of_boxes |
9 | 9 | assert_equal 'my description', t.description |
... | ... | @@ -11,9 +11,9 @@ class LayoutTemplateTest < ActiveSupport::TestCase |
11 | 11 | end |
12 | 12 | |
13 | 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 | 18 | all = LayoutTemplate.all |
19 | 19 | assert_equivalent [ 'one', 'two' ], all.map(&:id) | ... | ... |
test/unit/lightbox_helper_test.rb
... | ... | @@ -9,8 +9,8 @@ class LightboxHelperTest < ActiveSupport::TestCase |
9 | 9 | end |
10 | 10 | |
11 | 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 | 14 | end |
15 | 15 | |
16 | 16 | should 'provide lightbox_link_to helper' do | ... | ... |
test/unit/noosfero_i18n_test.rb
... | ... | @@ -16,7 +16,7 @@ class NoosferoI18nTest < ActiveSupport::TestCase |
16 | 16 | |
17 | 17 | should('have locale file for %s' % locale) do |
18 | 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 | 20 | end |
21 | 21 | |
22 | 22 | should('be able to translate activerecord errors header to %s' % locale) do | ... | ... |
test/unit/noosfero_test.rb
... | ... | @@ -4,12 +4,12 @@ require 'noosfero' |
4 | 4 | class NoosferoTest < ActiveSupport::TestCase |
5 | 5 | |
6 | 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 | 8 | assert_equal ["system_admin", "environment_admin", "public", "profile_admin"], Noosfero.controllers_in_directory('lala') |
9 | 9 | end |
10 | 10 | |
11 | 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 | 13 | assert_equal(/(system_admin|environment_admin|public|profile_admin)/, Noosfero.pattern_for_controllers_in_directory('lala')) |
14 | 14 | end |
15 | 15 | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1080,7 +1080,7 @@ class ProfileTest < ActiveSupport::TestCase |
1080 | 1080 | assert_equal 'default title', p.boxes[0].blocks.first[:title] |
1081 | 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 | 1084 | should 'have themes' do |
1085 | 1085 | Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) |
1086 | 1086 | ... | ... |
test/unit/slideshow_block_test.rb
... | ... | @@ -75,7 +75,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
75 | 75 | should 'decide correct public filename for image' do |
76 | 76 | image = mock |
77 | 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 | 80 | assert_equal '/bli/slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image) |
81 | 81 | end |
... | ... | @@ -83,7 +83,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
83 | 83 | should 'display the default slideshow image if thumbnails were not processed' do |
84 | 84 | image = mock |
85 | 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 | 88 | assert_equal '/images/icons-app/image-loading-slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image) |
89 | 89 | end |
... | ... | @@ -94,11 +94,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
94 | 94 | image = mock |
95 | 95 | # "slideshow" size does not exist |
96 | 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 | 99 | # thumb size does exist |
100 | 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 | 103 | assert_equal '/bli/thumb.png', block.public_filename_for(image) |
104 | 104 | end | ... | ... |
test/unit/theme_test.rb
... | ... | @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | 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 | 7 | def setup |
8 | 8 | Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) |
... | ... | @@ -13,11 +13,11 @@ class ThemeTest < ActiveSupport::TestCase |
13 | 13 | end |
14 | 14 | |
15 | 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 | 23 | assert_equal ['themeone', 'themetwo', 'themethree'], Theme.system_themes.map(&:id) | ... | ... |
test/unit/uploaded_file_test.rb
... | ... | @@ -223,7 +223,7 @@ class UploadedFileTest < ActiveSupport::TestCase |
223 | 223 | |
224 | 224 | should 'have a loading image to each size of thumbnails' do |
225 | 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 | 227 | assert File.exists?(image) |
228 | 228 | end |
229 | 229 | end |
... | ... | @@ -231,10 +231,10 @@ class UploadedFileTest < ActiveSupport::TestCase |
231 | 231 | should 'return a thumbnail for images' do |
232 | 232 | f = UploadedFile.new |
233 | 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 | 235 | assert_equal '/images/0000/0005/x.png', f.thumbnail_path |
236 | 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 | 238 | f.expects(:image?).returns(false) |
239 | 239 | assert_nil f.thumbnail_path |
240 | 240 | end | ... | ... |