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

29 lines
942 B
Ruby
Raw Normal View History

2016-12-04 18:09:49 -05:00
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