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

Change default response format of the show action to HTML #3705

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rails_admin/config/actions/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Show < RailsAdmin::Config::Actions::Base
register_instance_option :controller do
proc do
respond_to do |format|
format.json { render json: @object }
format.html { render @action.template_name }
format.json { render json: @object }
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/integration/actions/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
end
end

context 'with default format' do
it 'responds with HTML' do
page.driver.options[:headers] = {'HTTP_ACCEPT' => '*/*'}
visit show_path(model_name: 'team', id: team.id)

response_type = Mime::Type.parse(response_headers['Content-Type']).first
expect(response_type).to be_html
end
end

context 'when compact_show_view is enabled' do
it 'hides nil fields in show view by default' do
visit show_path(model_name: 'team', id: team.id)
Expand Down
Loading