mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
29 lines
942 B
Ruby
29 lines
942 B
Ruby
|
require "rails_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)).to_not 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
|