[Catalyst] user_exists dies when used from Test::WWW::Mechanize::Catalyst

Robert Rothenberg robrwo at gmail.com
Mon Jun 25 12:12:48 GMT 2012

On 25/06/12 13:00 Bill Moseley wrote:
> On Mon, Jun 25, 2012 at 4:48 AM, Robert Rothenberg <robrwo at gmail.com
> <mailto:robrwo at gmail.com>> wrote:
>     Several DBIC classes in our application have been customized with a method
>      user_can_modify($c)
> Do you really need the context? 


> I think the suggestion is normally pass in
> the data you need, which I suspect is a user object.  Then you are not
> binding DBIC and Catalyst so tightly.
>     user_can_modify( $user ):

No. I need other information from the context, such as whether a user is
even logged in, the user's roles, and session information, among other things.

> Sure, you can mock up a context object, but for flexible to pass in only the
> data you really need.

It's much more complex to set up and change a mock object, and have to worry
about whether it's set up correctly, than to log in as a particular user and
do actions that the user would normally do, and test how that affects the
user's access permissions.

More information about the Catalyst mailing list