Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class ExampleController < ActionController::Base
include ::Rails.application.routes.url_helpers

# Enable CSRF Protection
protect_from_forgery with: :exception
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @rhythmdesai404! Since I haven't heard back from you after Eric's comment earlier, I'm assuming this is ready for review.

I'm curious about why we need to turn this on. This is test code, and shouldn't impact the user. Why do we need to enable it here?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @kaylareopelle! Great question. Even though it's test code, enabling CSRF protection is important because it helps ensure that the tests accurately reflect the security measures in place for the actual application. By turning it on, we:
Simulate Real Conditions: Make sure the test environment mimics the real application environment, including its security features.
Consistency: Maintain consistency in how the application handles requests, whether in testing or in production.
In short, enabling CSRF protection in test code helps ensure that your application is secure and behaves as expected in all scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the context, @rhythmdesai404! That makes sense to me. If you'd still like to see this change, please reopen the PR and we'll give it a look.


def ok
render plain: 'actually ok'
end
Expand Down
Loading