aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Vizcay <pablo.vizcay@gmail.com>2015-04-09 04:48:01 -0300
committerPablo Vizcay <pablo.vizcay@gmail.com>2015-04-09 04:48:01 -0300
commit6c5a53e9ca4a81c40fbf7ebe2c63663ac9eb4f6d (patch)
tree3af9d9855dc3f7b3b485a8a0340af9f3f95e6fa5
parent8c8e9b34d576d2b223345d9073aca28c7975ecd7 (diff)
downloadrails-6c5a53e9ca4a81c40fbf7ebe2c63663ac9eb4f6d.tar.gz
rails-6c5a53e9ca4a81c40fbf7ebe2c63663ac9eb4f6d.tar.bz2
rails-6c5a53e9ca4a81c40fbf7ebe2c63663ac9eb4f6d.zip
bugfix CodeStatics#calculate_directory_statics when dir has source extension
-rw-r--r--railties/lib/rails/code_statistics.rb6
-rw-r--r--railties/test/code_statistics_test.rb20
2 files changed, 22 insertions, 4 deletions
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 583d005d46..fd352dc9b7 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -41,11 +41,9 @@ class CodeStatistics #:nodoc:
if File.directory?(path) && (/^\./ !~ file_name)
stats.add(calculate_directory_statistics(path, pattern))
+ elsif file_name =~ pattern
+ stats.add_by_file_path(path)
end
-
- next unless file_name =~ pattern
-
- stats.add_by_file_path(path)
end
stats
diff --git a/railties/test/code_statistics_test.rb b/railties/test/code_statistics_test.rb
new file mode 100644
index 0000000000..1b1ff80bc1
--- /dev/null
+++ b/railties/test/code_statistics_test.rb
@@ -0,0 +1,20 @@
+require 'abstract_unit'
+require 'rails/code_statistics'
+
+class CodeStatisticsTest < ActiveSupport::TestCase
+ def setup
+ @tmp_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'tmp'))
+ @dir_js = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'tmp', 'lib.js'))
+ FileUtils.mkdir_p(@dir_js)
+ end
+
+ def teardown
+ FileUtils.rm_rf(@tmp_path)
+ end
+
+ test 'ignores directories that happen to have source files extensions' do
+ assert_nothing_raised do
+ @code_statistics = CodeStatistics.new(['tmp dir', @tmp_path])
+ end
+ end
+end