Sha256: a687063510331848a2cc2ca0bf21458de0e0ac41de0b3788349c5b8bd914f0a8

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'
require 'rollbar'

Rollbar.plugins.load!

describe Rollbar::ActiveRecordExtension do
  it 'has the extensions loaded into ActiveRecord::Base' do
    expect(ActiveModel::Validations.ancestors).to include(described_class)
    expect(ActiveModel::Validations.instance_methods.map(&:to_sym)).to include(:report_validation_errors_to_rollbar)
  end

  context 'with an ActiveRecord::Base instance' do
    let(:user) { User.new }

    it 'calls report_validation_errors_to_rollbar' do
      expect(user).to receive(:report_validation_errors_to_rollbar)

      user.valid?
    end

    context 'using Rails 5.0' do
      next unless Gem::Version.new(Rails.version) >= Gem::Version.new('5.0')

      context 'with belongs_to' do
        let(:book) { Book.new }

        it 'report validations error' do
          expect(book).to receive(:report_validation_errors_to_rollbar)
          book.valid?
        end
      end
    end
  end

  context 'with class using ActiveModel::Validations' do
    let(:post) { Post.new }

    it 'calls report_validation_errors_to_rollbar' do
      expect(post).to receive(:report_validation_errors_to_rollbar)

      post.valid?
    end
  end

  describe '#report_validation_errors_to_rollbar', :reconfigure_notifier => true do
    context 'having validation errors' do
      let(:user) { User.new }

      it 'send the errors to Rollbar' do
        expect(Rollbar).to receive(:warning)

        user.valid?
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rollbar-2.18.2 spec/rollbar/plugins/validations_spec.rb
rollbar-2.18.0 spec/rollbar/plugins/validations_spec.rb
rollbar-2.17.0 spec/rollbar/plugins/validations_spec.rb
rollbar-2.16.4 spec/rollbar/plugins/validations_spec.rb
rollbar-2.16.3 spec/rollbar/plugins/validations_spec.rb
rollbar-2.16.2 spec/rollbar/plugins/validations_spec.rb
rollbar-2.16.0 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.6 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.5 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.4 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.3 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.2 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.1 spec/rollbar/plugins/validations_spec.rb
rollbar-2.15.0 spec/rollbar/plugins/validations_spec.rb
rollbar-2.14.1 spec/rollbar/plugins/validations_spec.rb
rollbar-2.14.0 spec/rollbar/plugins/validations_spec.rb