diff --git a/CHANGELOG.md b/CHANGELOG.md index 6afbd5ce..e896d7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/). ### Added -- None +- [#1074](https://github.com/airblade/paper_trail/pull/1074) + `PaperTrail.request do ... end` now returns the value the given block. ### Fixed diff --git a/lib/paper_trail.rb b/lib/paper_trail.rb index 8fa79029..4b2788aa 100644 --- a/lib/paper_trail.rb +++ b/lib/paper_trail.rb @@ -121,7 +121,8 @@ module PaperTrail # word "request" right there in your application code will remind you that # these variables only affect the current request, not all threads. # - # Given a block, temporarily sets the given `options` and execute the block. + # Given a block, temporarily sets the given `options`, executes the block, + # and returns the value of the block. # # Without a block, this currently just returns `PaperTrail::Request`. # However, please do not use `PaperTrail::Request` directly. Currently, @@ -135,7 +136,6 @@ module PaperTrail Request else Request.with(options, &block) - nil end end diff --git a/spec/paper_trail_spec.rb b/spec/paper_trail_spec.rb index 33d8cbce..4f29d8f7 100644 --- a/spec/paper_trail_spec.rb +++ b/spec/paper_trail_spec.rb @@ -3,6 +3,12 @@ require "spec_helper" RSpec.describe PaperTrail do + describe ".request" do + it "returns the value returned by the block" do + expect(described_class.request(whodunnit: "abe lincoln") { "A test" }).to eq("A test") + end + end + describe "#config", versioning: true do it "allows for config values to be set" do expect(described_class.config.enabled).to eq(true)