Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3d8fcdd3bf
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (24 sloc) 0.872 kb
require 'rails/generators/test_unit'
require 'rails/generators/resource_helpers'
module TestUnit # :nodoc:
module Generators # :nodoc:
class ScaffoldGenerator < Base # :nodoc:
include Rails::Generators::ResourceHelpers
check_class_collision suffix: "ControllerTest"
argument :attributes, type: :array, default: [], banner: "field:type field:type"
def create_test_files
template "functional_test.rb",
File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
end
private
def attributes_hash
return if attributes.empty?
attributes.map do |a|
name = a.name
name = "#{name}_id" if a.reference?
"#{name}: @#{singular_table_name}.#{name}"
end.sort.join(', ')
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.