1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/spec/controllers/articles_controller_spec.rb
2020-08-18 01:56:22 -04:00

30 lines
997 B
Ruby

# frozen_string_literal: true
require "spec_helper"
RSpec.describe ArticlesController, type: :controller do
describe "PaperTrail.request.enabled?" do
context "PaperTrail.enabled? == true" do
before { PaperTrail.enabled = true }
after { PaperTrail.enabled = false }
it "returns true" do
expect(PaperTrail.enabled?).to eq(true)
post :create, params: { article: { title: "Doh", content: FFaker::Lorem.sentence } }
expect(assigns(:article)).not_to be_nil
expect(PaperTrail.request.enabled?).to eq(true)
expect(assigns(:article).versions.length).to eq(1)
end
end
context "PaperTrail.enabled? == false" do
it "returns false" do
expect(PaperTrail.enabled?).to eq(false)
post :create, params: { article: { title: "Doh", content: FFaker::Lorem.sentence } }
expect(PaperTrail.request.enabled?).to eq(false)
expect(assigns(:article).versions.length).to eq(0)
end
end
end
end