Skip to main content
100%

Gist 850654

✓ Published0🌍 Public
VVortex
Last edited Mar 2, 2011
Created on Mar 2, 2011

This example shows how to test authorization and role-protected attribute updates in a Rails controller using RSpec. It verifies that a user cannot edit another user’s profile, can change their own given name, and cannot modify their role field, with assertions on flash messages, response codes, and assigned attributes. The code uses Devise::TestHelpers to sign in a factory-built user, and RSpec’s `describe`, `context`, and `it` blocks to structure the test cases.

AI-generated description

Similar vizzes