Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the configuration for Dragonfly so you can use the before_s… #3451

Merged
merged 6 commits into from Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, otherwise it'd get immediately executed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're passing in a block, it would be a Proc object at this point. So it would only execute if you invoked the call method on it. The & is converting the Proc object back into a block since the before_serve method is expecting a block.

I'm pretty sure that is the case, let me know if I mistook something.



# 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