More Roles Tests
Explore how to extend security testing by adding more user roles and access controls within your Rails application. Understand custom matcher implementation and fix integration test failures that arise from role-based visibility, ensuring robust user authentication and authorization.
We'll cover the following...
Adding more roles test
In the previous lesson, we created a custom matcher, be_able_to_see, which takes in a list of projects and validates the can_view? and visible_projects in parallel, thereby asserting that the two methods stay in sync. It also validates that projects that aren’t specified are not visible. We get around the fixture data by explicitly specifying the universe of all_projects. (In Minitest we’d use a custom assertion. We can see an example in the sample code at /test/models/user_test.rb).
At this point, our original integration ...