Skip to content

Commit

Permalink
Merge pull request #4287 from mrzasa/decorating-forms
Browse files Browse the repository at this point in the history
Method #decorate? should use form.options[:decorate]
  • Loading branch information
seanlinsley committed Feb 14, 2016
2 parents ac8e77b + d79b3cb commit 0a175de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_admin/resource_controller/decorators.rb
Expand Up @@ -28,7 +28,7 @@ def self.undecorate(resource)

def decorate?
case action_name
when 'new', 'edit'
when 'new', 'edit', 'create', 'update'
form = active_admin_config.get_page_presenter :form
form && form.options[:decorate] && decorator_class.present?
else
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/resource_controller/decorators_spec.rb
Expand Up @@ -28,6 +28,17 @@ def self.name
context 'with a decorator configured' do
let(:decorator_class) { PostDecorator }
it { is_expected.to be_kind_of(PostDecorator) }

context 'with form' do
let(:action) { 'update' }

it "does not decorate when :decorate is set to false" do
form = double
allow(form).to receive(:options).and_return(:decorate => false)
allow(active_admin_config).to receive(:get_page_presenter).and_return(form)
is_expected.not_to be_kind_of(PostDecorator)
end
end
end

context 'with no decorator configured' do
Expand Down

0 comments on commit 0a175de

Please sign in to comment.