This is a short description of your app.
- Ruby
- PostgreSQL (e.g. Postgres.app)
$ bundle install
$ rails db:setup
To generate models, resources, and controllers:
$ rails generate model widget [fields]
$ rails generate jsonapi:resource widget
$ rails generate jsonapi:controller widget
$ bin/rspec
In request tests, you can use the user and access token factories to create test data to access protected resources:
user = FactoryBot.create(:user)
token = FactoryBot.create(:access_token, resource_owner_id: user.id).token
headers = {
'Authorization' => "Bearer #{token}",
'Content-Type' => 'application/vnd.api+json',
}
# assuming you have a Widget model that belongs to a User
FactoryBot.create(:widget, user: user)
get '/widgets', headers: headers
$ rails server