Sha256: 698e963fc874ae7c130e10d7cd6c652d884b5eb39ce5628fd74bd29b4cc428dd

Contents?: true

Size: 1.15 KB

Versions: 29

Compression:

Stored size: 1.15 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"

      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

      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

29 entries across 29 versions & 5 rubygems

Version Path
railties-4.2.11.3 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.11.2 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.11.1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.11 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.10 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.10.rc1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.9 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.9.rc2 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.9.rc1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/railties-4.2.8/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.8 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.8.rc1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.7.1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.7 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.7.rc1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.6 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.6.rc1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.5.2 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
railties-4.2.5.1 lib/rails/generators/test_unit/scaffold/scaffold_generator.rb