Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix CodeStatics#calculate_directory_statics when dir has source ext #19703

Merged
merged 1 commit into from
Apr 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions railties/lib/rails/code_statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|coffee)$/)

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
Expand Down
20 changes: 20 additions & 0 deletions railties/test/code_statistics_test.rb
Original file line number Diff line number Diff line change
@@ -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