nathanl / authority

*CURRENTLY UNMAINTAINED*. Authority helps you authorize actions in your Rails app. It's ORM-neutral and has very little fancy syntax; just group your models under one or more Authorizer classes and write plain Ruby methods on them.
MIT License
1.21k stars 67 forks source link

Authority and Capybara #70

Closed elle closed 10 years ago

elle commented 10 years ago

I am not sure this is a problem in the gem, but just not sure where to post a question, so hoping you could help me.

I have a Company resource which has self.authorizer_name = "OperationsAuthorizer"

In the companies controller I have authorize_actions_for(Company)

In my specs, I log in as an operations user, and even check that expect(Company.creatable_by?(user)).to be_truthy which passes

But when I submit the form in my feature spec (using capybara), I get an error: User is not authorized to create this resource: Company And if I add debugger in my create action, I don't even get to it. And the path stays on the new view.

I do not get this error when I check the form in the browser.

What am I missing?

focused commented 10 years ago

I think it happens because of misunderstanding of capybara mechanics. What driver do you use, webkit, selenium? I do not think it is an Authority issue.

elle commented 10 years ago

You are right. Not n Authority issue. It was a problem with posting forms via ajax.

nathanl commented 10 years ago

@focused Thanks for the help. I am obviously behind on looking at issues. :)