janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
571 stars 40 forks source link

Add: fixtures #122

Closed benkoshy closed 2 years ago

benkoshy commented 2 years ago

What is this?

Why?

I want to automatically create user accounts as fixtures, so I can run request specs without creating accounts on the fly:

# don't want to do this
account = Account.create(email: ....etc) #
login(account)

# I want this:
account  = accounts(:one) # fixtures
login(account) # preferably using the same login params used by rodauth

def login(account)
    post "/login", params: {"login"=>"brian@queen.com", "password"=>"password"}
end

(By the way, is there any way of getting a hold of a rodauth object in tests so we can write?

   post rodauth.login_path # etc.

I hope this is useful/helpful. if not feel free to discard.

janko commented 2 years ago

Looks good now, thanks 👍🏻 I'll fix the failing tests after merge.

janko commented 2 years ago

I realized we'll also need to handle RSpec, where the fixture needs to be created in spec/fixtures. Would you be comfortable working on a PR for that?

benkoshy commented 2 years ago

I'll give it a shot!

I had avoided rspec, because it is a gem which needs to be added to rails. However because you asked, i can def add it: Looks very straightforward, i can add a conditional, check for rspec, and add the fixtures. Probably will be done tomorrow