Skip to content

Commit

Permalink
Fix the configuration for Dragonfly so you can use the before_s… (#3451)
Browse files Browse the repository at this point in the history
This fixes an issue with setting the `Dragonfly` configuration for `before_serve`. It looked like before it was a simple attr_accessor, but since `before_serve` is more like a DSL it was expecting to be called with a block. This PR corrects that, and I'm able to confirm it works on my project.

The good news is this also solves another use case, serving private content. If you look at this Google Groups post from a few years ago, it appears my client isn't alone in wanting this feature. https://groups.google.com/forum/#!searchin/refinery-cms/dragonfly$20before_serve%7Csort:date/refinery-cms/lRBOsddSzHM/1tXNjzaHcBUJ
  • Loading branch information
joebutler2 authored and parndt committed Nov 27, 2019
1 parent 6e3e74e commit c387993
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dragonfly/lib/refinery/dragonfly/dragonfly.rb
Expand Up @@ -32,7 +32,7 @@ def configure!(extension)

# These options require a name and block
define_url extension.dragonfly_define_url if extension.dragonfly_define_url.present?
before_serve extension.dragonfly_before_serve if extension.dragonfly_before_serve.present?
before_serve(&extension.dragonfly_before_serve) if extension.dragonfly_before_serve.present?


# There can be more than one instance of each of these options.
Expand Down
3 changes: 1 addition & 2 deletions dragonfly/refinerycms-dragonfly.gemspec
@@ -1,10 +1,9 @@
# Encoding: UTF-8


Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = %q{refinerycms-dragonfly}
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = %q{Dragonfly interface for Refinery CMS}
s.description = %q{Allows Refinery to use dragonfly for file storage and processing}
s.email = %q{anita@joli.com.au}
Expand Down
12 changes: 12 additions & 0 deletions resources/spec/lib/refinery/resources/engine_spec.rb
Expand Up @@ -4,5 +4,17 @@ module Refinery
describe Resources do
it_has_behaviour 'Creates a dragonfly App:'
it_has_behaviour 'adds the dragonfly app to the middleware stack'

it 'calls dragonfly#before_serve to set configuration' do
dummy_proc = -> (_job, _env) {}
expect_any_instance_of(::Dragonfly::Server).to(
receive(:before_serve) { |&block| expect(block).to be(dummy_proc) }
)
::Refinery::Resources.configure do |config|
config.dragonfly_before_serve = dummy_proc
end

::Refinery::Dragonfly.configure!(::Refinery::Resources)
end
end
end

0 comments on commit c387993

Please sign in to comment.