-
Git repo in your app
-
Create account on heroku.com
- Add your SSH key to Heroku so you can push to your heroku remote repo. Hopefully you already have an SSH key for GitHub, in which case you can run the following:
$ heroku keys:add
# app/controllers/v1/users_controller.rb | |
class V1::UsersController < V1::ApplicationController | |
def create | |
user = SignUpUser.perform(user_params) | |
render json: user, serializer: AuthenticationSerializer, root: :user | |
end | |
private |
# config/routes.rb | |
Rails.application.routes.draw do | |
api_version(module: 'V1', | |
header: { | |
name: 'Accept', | |
value: 'application/vnd.authentication-demo-app.com; version=1' }, | |
defaults: { format: :json }) do | |
resources :users, only: :create | |
end |
$ rails g model email password_digest authentication_token authentication_token_expires_at:datetime |
RSpec.configure do |config| | |
# ... | |
config.include Helpers::Requests, type: :request | |
config.include JsonSpec::Helpers | |
# ... | |
end |
# spec/support/helpers/requests.rb | |
module Helpers | |
module Requests | |
def body | |
response.body | |
end | |
def json_value_at_path(path = '') | |
parse_json(body, path) |
# spec/requests/v1/users_requests_spec.rb | |
require 'rails_helper' | |
describe 'Users endpoints' do | |
describe 'POST /users' do | |
context 'with valid email and password' do | |
it 'returns JSON for a user' do | |
user_attributes = { | |
user: { |
oh hai |
timeframes = [ | |
"6-9 AM", | |
"9-12 PM", | |
"12-3 PM" | |
] | |
direction = [ | |
"inbound", | |
"outbound" | |
] |