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

Config/enable previews test environment #928

Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## main

* Enable previews by default in test environment.

*Edouard Piron*

* Fix test helper compatibility with Rails 7.0, TestRequest, and TestSession.

*Leo Correa*
Expand Down
9 changes: 9 additions & 0 deletions docs/guide/previews.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,12 @@ Previews can be extended to allow users to add authentication, authorization, be
# config/application.rb
config.view_component.preview_controller = "MyPreviewController"
```

## Enabling and disabling previews
joelhawksley marked this conversation as resolved.
Show resolved Hide resolved

Previews are enabled by default in test and development environments. To enable or disable previews, use the `show_previews` option:

```ruby
# config/environments/test.rb
config.view_component.show_previews = false
```
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ViewComponent is built by:

<img src="https://github.com/avatars/asgerb?s=64" alt="asgerb" width="32" />
<img src="https://github.com/avatars/bbugh?s=64" alt="bbugh" width="32" />
<img src="https://github.com/avatars/bigbigdoudou?s=64" alt="bigbigdoudou" width="32" />
<img src="https://github.com/avatars/blakewilliams?s=64" alt="blakewilliams" width="32" />
<img src="https://github.com/avatars/bobmaerten?s=64" alt="bobmaerten" width="32" />
<img src="https://github.com/avatars/bradparker?s=64" alt="bradparker" width="32" />
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Engine < Rails::Engine # :nodoc:
options = app.config.view_component

options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
options.show_previews = Rails.env.development? if options.show_previews.nil?
options.show_previews = Rails.env.development? || Rails.env.test? if options.show_previews.nil?
options.preview_route ||= ViewComponent::Base.preview_route
options.preview_controller ||= ViewComponent::Base.preview_controller

Expand Down