Sha256: e81b9ab2e68a1897d6c5f19669f2a2a4ca0a1a726d78f49ff6abb20b479bd093

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

require "spec_helper"

RSpec.describe ArticlesController, type: :controller do
  describe "PaperTrail.enabled_for_controller?" do
    context "PaperTrail.enabled? == true" do
      before { PaperTrail.enabled = true }

      it "returns true" do
        assert PaperTrail.enabled?
        post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
        expect(assigns(:article)).not_to be_nil
        assert PaperTrail.enabled_for_controller?
        assert_equal 1, assigns(:article).versions.length
      end

      after { PaperTrail.enabled = false }
    end

    context "PaperTrail.enabled? == false" do
      it "returns false" do
        assert !PaperTrail.enabled?
        post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
        assert !PaperTrail.enabled_for_controller?
        assert_equal 0, assigns(:article).versions.length
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paper_trail-7.1.0 spec/controllers/articles_controller_spec.rb
paper_trail-7.0.3 spec/controllers/articles_controller_spec.rb