mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Lint: Fix RSpec/HooksBeforeExamples
This commit is contained in:
parent
5a605b7c29
commit
206023b0b7
5 changed files with 30 additions and 38 deletions
|
@ -18,14 +18,6 @@ Naming/MemoizedInstanceVariableName:
|
|||
RSpec/ContextWording:
|
||||
Enabled: false
|
||||
|
||||
RSpec/HooksBeforeExamples:
|
||||
Exclude:
|
||||
- spec/controllers/articles_controller_spec.rb
|
||||
- spec/models/version_spec.rb
|
||||
- spec/paper_trail/config_spec.rb
|
||||
- spec/paper_trail/request_spec.rb
|
||||
- spec/paper_trail_spec.rb
|
||||
|
||||
RSpec/NestedGroups:
|
||||
Exclude:
|
||||
- spec/paper_trail/model_spec.rb
|
||||
|
|
|
@ -7,6 +7,8 @@ RSpec.describe ArticlesController, type: :controller 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 } }
|
||||
|
@ -14,8 +16,6 @@ RSpec.describe ArticlesController, type: :controller do
|
|||
expect(PaperTrail.request.enabled?).to eq(true)
|
||||
expect(assigns(:article).versions.length).to eq(1)
|
||||
end
|
||||
|
||||
after { PaperTrail.enabled = false }
|
||||
end
|
||||
|
||||
context "PaperTrail.enabled? == false" do
|
||||
|
|
|
@ -45,13 +45,13 @@ module PaperTrail
|
|||
PaperTrail.serializer = PaperTrail::Serializers::JSON
|
||||
end
|
||||
|
||||
it "store out as a plain hash" do
|
||||
expect(value).not_to include("HashWithIndifferentAccess")
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.serializer = PaperTrail::Serializers::YAML
|
||||
end
|
||||
|
||||
it "store out as a plain hash" do
|
||||
expect(value).not_to include("HashWithIndifferentAccess")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,28 +11,28 @@ module PaperTrail
|
|||
end
|
||||
|
||||
describe ".disable_model" do
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
|
||||
it "sets enabled_for_model? to false" do
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(true)
|
||||
PaperTrail.request.disable_model(Widget)
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(false)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".enabled_for_model" do
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
|
||||
it "sets enabled_for_model? to true" do
|
||||
PaperTrail.request.enabled_for_model(Widget, false)
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(false)
|
||||
PaperTrail.request.enabled_for_model(Widget, true)
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(true)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".enabled?" do
|
||||
|
@ -42,16 +42,16 @@ module PaperTrail
|
|||
end
|
||||
|
||||
describe ".enabled=" do
|
||||
after do
|
||||
PaperTrail.request.enabled = true
|
||||
end
|
||||
|
||||
it "sets enabled? to true" do
|
||||
PaperTrail.request.enabled = true
|
||||
expect(PaperTrail.request.enabled?).to eq(true)
|
||||
PaperTrail.request.enabled = false
|
||||
expect(PaperTrail.request.enabled?).to eq(false)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.request.enabled = true
|
||||
end
|
||||
end
|
||||
|
||||
describe ".controller_info" do
|
||||
|
@ -61,27 +61,27 @@ module PaperTrail
|
|||
end
|
||||
|
||||
describe ".controller_info=" do
|
||||
after do
|
||||
PaperTrail.request.controller_info = {}
|
||||
end
|
||||
|
||||
it "sets controller_info" do
|
||||
PaperTrail.request.controller_info = { foo: :bar }
|
||||
expect(PaperTrail.request.controller_info).to eq(foo: :bar)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.request.controller_info = {}
|
||||
end
|
||||
end
|
||||
|
||||
describe ".enable_model" do
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
|
||||
it "sets enabled_for_model? to true" do
|
||||
PaperTrail.request.disable_model(Widget)
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(false)
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
expect(PaperTrail.request.enabled_for_model?(Widget)).to eq(true)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.request.enable_model(Widget)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".whodunnit" do
|
||||
|
|
|
@ -40,14 +40,14 @@ RSpec.describe PaperTrail do
|
|||
end
|
||||
|
||||
context "when enabled" do
|
||||
after do
|
||||
described_class.enabled = true
|
||||
end
|
||||
|
||||
it "affects all threads" do
|
||||
Thread.new { described_class.enabled = false }.join
|
||||
assert_equal false, described_class.enabled?
|
||||
end
|
||||
|
||||
after do
|
||||
described_class.enabled = true
|
||||
end
|
||||
end
|
||||
|
||||
context "default" do
|
||||
|
|
Loading…
Reference in a new issue