Sha256: c240626c91c0dd4cc733f7cfad669958c72d4490ecd9334b3321e53eae476ad5

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices
  module Prepares
    describe InitializerPrepare do
      let(:runner) { Core::Runner.new(prepares: described_class.new) }

      context 'initializers' do
        it 'sets include_forbidden_attributes_protection config' do
          content = <<-EOF
          class AR
            ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
          end
          EOF
          runner.prepare('config/initializers/ar.rb', content)
          configs = Prepares.configs
          expect(configs['railsbp.include_forbidden_attributes_protection']).to eq('true')
        end

        it 'does not set include_forbidden_attributes_protection config' do
          content = <<-EOF
          class AR
          end
          EOF
          runner.prepare('config/initializers/ar.rb', content)
          configs = Prepares.configs
          expect(configs['railsbp.include_forbidden_attributes_protection']).to be_nil
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_best_practices-1.23.2 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/prepares/initializer_prepare_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/prepares/initializer_prepare_spec.rb