This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devise_for :users, | |
path: '', | |
path_names: { | |
sign_in: 'login', | |
sign_out: 'logout', | |
registration: 'signup' | |
}, | |
controllers: { | |
sessions: 'sessions', | |
registrations: 'registrations' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegistrationsController < Devise::RegistrationsController | |
respond_to :json | |
def create | |
build_resource(sign_up_params) | |
resource.save | |
render_resource(resource) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::API | |
def render_resource(resource) | |
if resource.errors.empty? | |
render json: resource | |
else | |
validation_error(resource) | |
end | |
end | |
def validation_error(resource) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe 'POST /login', type: :request do | |
let(:user) { Fabricate(:user) } | |
let(:url) { '/login' } | |
let(:params) do | |
{ | |
user: { | |
email: user.email, | |
password: user.password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe 'POST /signup', type: :request do | |
let(:url) { '/signup' } | |
let(:params) do | |
{ | |
user: { | |
email: '[email protected]', | |
password: 'password' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("when user inputs more characters ", () => { | |
const { getByLabelText, getByText } = render(<Component />); | |
const input = getByLabelText("label", { selector: "input" }); | |
beforeEach(() => { | |
fireEvent.change(input, { target: { value: "new value" } }); | |
}); | |
it("displays suggestions", () => { | |
expect(getByText("new value")).toBeInTheDocument(); |
OlderNewer