Sha256: 6022613650be3a2a2a2b07a899aa04b02f251d67d31d338c34b319344fc2813d

Contents?: true

Size: 1.5 KB

Versions: 174

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

174 entries across 174 versions & 1 rubygems

Version Path
pg_rails-7.6.27 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.26 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.25 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.24 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.24.pre.5 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.24.pre.4 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.24.pre.3 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.23 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.22 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.22.pre.3 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.22.pre.2 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.22.pre.1 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.11 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.10 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.9 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.8 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.7 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.6 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb
pg_rails-7.6.21.pre.5 pg_scaffold/lib/generators/pg_rspec/scaffold/scaffold_generator.rb