Sha256: 6022613650be3a2a2a2b07a899aa04b02f251d67d31d338c34b319344fc2813d

Contents?: true

Size: 1.5 KB

Versions: 175

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'generators/rspec/scaffold/scaffold_generator'

module PgRspec
  module Generators
    class ScaffoldGenerator < Rspec::Generators::ScaffoldGenerator
      # agrego la carpeta para que busque templates
      # manteniendo la source_root de Rspec::Generators::ScaffoldGenerator
      # para poder copiar sólo los que quiero cambiar
      source_paths << File.expand_path('templates', __dir__)

      class_option :paranoia, type: :boolean, default: false, desc: 'Paranoid y deleted_at.'
      class_option :discard, type: :boolean, default: false, desc: 'Discard y discarded_at.'
      class_option :trackeo_de_usuarios, type: :boolean, default: true,
                                         desc: 'Genera campos creado_por y actualizado_por.'

      class_option :controller_specs, type: :boolean, default: true
      class_option :request_specs,    type: :boolean, default: false
      class_option :view_specs,       type: :boolean, default: false

      # remove_hook_for :integration_tool, as: :integration
      # remove_hook_for :fixture_replacement

      def generate_routing_spec
        # piso el método para que no genere nada
      end

      protected

      def referencias_requeridas
        attributes.select { |at| at.reference? && at.required? }
      end

      def merge_referencias
        return if referencias_requeridas.blank?

        asd = referencias_requeridas.map { |r| "#{r.name}_id: #{r.name}.id" }
        ".merge(#{asd.join(', ')})"
      end
    end
  end
end

Version data entries

175 entries across 175 versions & 1 rubygems

Version Path
pg_rails-7.6.21.pre.5 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.4 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.3 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.2 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.1 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.20 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.19 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.18 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.17 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.16 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.15 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.14 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.13 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.12 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.11 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.10 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.9 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.8 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.7 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.6 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb