Sha256: d340366463778bcf2adbe899e307011c97e9fbc4ef22c0c2a1f27a4afa796d36
Contents?: true
Size: 1.33 KB
Versions: 21
Compression:
Stored size: 1.33 KB
Contents
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" class_option :api, type: :boolean, desc: "Generates API functional tests" argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_test_files template_file = options.api? ? "api_functional_test.rb" : "functional_test.rb" template template_file, File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb") end def fixture_name @fixture_name ||= if mountable_engine? "%s_%s" % [namespaced_path, table_name] else table_name end end private def attributes_hash return if attributes_names.empty? attributes_names.map do |name| if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?) "#{name}: 'secret'" else "#{name}: @#{singular_table_name}.#{name}" end end.sort.join(', ') end end end end
Version data entries
21 entries across 21 versions & 3 rubygems
Version | Path |
---|---|
railties-5.0.0.beta1 | lib/rails/generators/test_unit/scaffold/scaffold_generator.rb |