Add spanish locales and gravatar options

This commit is contained in:
2026-03-09 11:17:25 -05:00
parent 2711edb167
commit 4e1d3bd052
32 changed files with 640 additions and 106 deletions
+18 -3
View File
@@ -13,6 +13,19 @@ class ApplicationController < ActionController::Base
rescue_from SimplyStored::RecordNotFound, with: :show_404
# protected
#
# def after_sign_in_path_for(resource)
# case resource
# when 'user' then Mozo.user_url
# else
# main_app.root_path
# end
# # Customize the redirect path here
# # For example, redirect to a dashboard page
# dashboard_path || root_path
# end
#
private
def authenticate_employee!
@@ -67,8 +80,9 @@ private
end
def set_locale
#session[:locale] = (params[:locale].presence || session[:locale] || Rails.configuration.i18n.default_locale).to_sym
I18n.locale = params[:locale].presence.try(:to_sym) || Rails.configuration.i18n.default_locale
session[:locale] = (params[:locale].presence || session[:locale] || Rails.configuration.i18n.default_locale).to_sym
I18n.locale = session[:locale]
# I18n.locale = params[:locale].presence.try(:to_sym) || Rails.configuration.i18n.default_locale
end
def _render_with_renderer_json(resource, options)
@@ -98,7 +112,8 @@ private
def after_sign_in_path_for(resource)
case resource
when Employee then supplier_root_path
when User then Mozo.user_url
when Employee then Mozo.supplier_url
when Administrator then cmtool.root_path
else root_path
end
@@ -1,13 +0,0 @@
# class RegistrationsController < Devise::RegistrationsController
# protected
#
# #def after_sign_up_path(resource)
# #end
#
# private
#
# # override devise internal to allow name as sign_up param
# def sign_up_params
# params.require(resource_name).permit resource_class.authentication_keys + [:name, :password, :password_confirmation]
# end
# end
+20 -20
View File
@@ -1,20 +1,20 @@
# class WaiterController < ApplicationController
# layout 'waiter'
# def index
#
# end
#
# def product_categories
# respond_to do |format|
# format.html { redirect_to '/waiter'}
# format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
# end
# end
#
# def order_products
# @table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
# @list = List.from_table_by_employee(@table, current_employee)
# @list.place_order products: params[:order], employee: current_employee
# render nothing: true
# end
# end
class WaiterController < ApplicationController
layout 'waiter'
def index
end
def product_categories
respond_to do |format|
format.html { redirect_to '/waiter'}
format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
end
end
def order_products
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
@list = List.from_table_by_employee(@table, current_employee)
@list.place_order products: params[:order], employee: current_employee
render nothing: true
end
end
+4 -1
View File
@@ -19,7 +19,10 @@ class Employee
end
#view :by_confirmation_token, key: :confirmation_token # devise confirmable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable #, :registerable #, :confirmable
devise_plugins = [:database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable] #, :omniauthable, {omniauth_providers: [:facebook, :instagram]}] #, :token_authenticatable , :registerable
devise_plugins -= [:trackable] if Rails.env.test? # creates conflicts
devise *devise_plugins
# devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable #, :registerable #, :confirmable
property :unconfirmed_email
property :name
+1 -1
View File
@@ -219,7 +219,7 @@ class Supplier
private
def add_section_on_create
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title', default: nil) || 'Room'
end
+6
View File
@@ -6,6 +6,7 @@ class User
property :name
property :active_list_id
property :admin, type: :boolean, default: false
property :email_sha256
#FACEBOOK
property :provider
@@ -26,6 +27,7 @@ class User
validates_uniqueness_of :email
before_save :ensure_authentication_token
before_create :set_email_sha256
#has_many :error_logs
has_many :user_feedbacks
@@ -150,6 +152,10 @@ class User
reset_authentication_token! if authentication_token.blank?
end
def set_email_sha256
self.email_sha256 = Digest::SHA256.hexdigest email.to_s.strip.downcase
end
def self.authentication_token
SecureRandom.hex(24)
end
+1 -1
View File
@@ -1,5 +1,5 @@
class Suppliers::UserSerializer
include Mozo::SupplierBaseSerializer
attributes :email, :provider, :uid, :avatar, :number_of_lists_at_supplier
attributes :email, :email_sha256, :provider, :uid, :avatar, :number_of_lists_at_supplier
attribute(:name) { object.supplier_name }
end
+1 -1
View File
@@ -1,6 +1,6 @@
class Users::UserSerializer
include Mozo::UserBaseSerializer
attributes :email, :provider, :uid, :avatar
attributes :email, :email_sha256, :provider, :uid, :avatar
attribute(:name){ object.friends_name }
end
@@ -0,0 +1,11 @@
h2= t('devise.employee.confirmations.title')
= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
.control-group
.controls
= f.submit t('devise.employee.confirmations.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,23 @@
dl.devise-links
- devise_mapping = Devise.mappings[resource_name]
dt= t 'devise.links.prefix'
- if controller_name != 'sessions'
dd= link_to t('devise.employee.sign_in.link'), new_session_path(resource_name), class: ['devise-link', 'new-session']
- if devise_mapping.registerable? && controller_name != 'registrations'
dd= link_to t('devise.employee.registrations.link'), new_registration_path(resource_name), class: ['devise-link', 'new-registration']
- if resource_name == :employee and controller_name != 'new_suppliers'
dd= link_to t('devise.employee.registrations.link'), new_suppliers_path, class: ['devise-link', 'new-registration']
- if devise_mapping.recoverable? && controller_name != 'passwords'
dd= link_to t('devise.employee.passwords.link'), new_password_path(resource_name), class: ['devise-link', 'forgot-password']
- if devise_mapping.confirmable? && controller_name != 'confirmations'
dd= link_to t('devise.employee.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
dd= link_to t('devise.employee.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
dd= link_to t('devise.employee.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: ['devise-link', 'omniauth', provider]
+12 -10
View File
@@ -1,12 +1,14 @@
h2= t('devise.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {method: :put}) do |f|
h2= t('devise.employee.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal', method: :put}) do |f|
= devise_error_messages!
= f.hidden_field :reset_password_token
= f.row :password
.form-label= f.label :password
.form-field= f.password_field :password
= f.row :password_confirmation
.form-label= f.label :password_confirmation
.form-field= f.password_field :password_confirmation
.form-row= f.submit t('devise.passwords.edit.button'), class: 'button'
= render "devise/links"
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.employee.passwords.edit.button'), class: 'button'
= render 'employees/devise/links'
+9 -7
View File
@@ -1,8 +1,10 @@
h2= t('devise.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f|
h2= t('devise.employee.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
= f.row :email do
.form-label= f.label :email, class: 'control-label'
.form-field= f.email_field :email, autofocus: true
.form-row.form-actions= f.submit t('devise.passwords.button'), class: 'button'
= render "devise/links"
.control-group
= f.label :email, class: 'control-label'
.controls= f.email_field :email
.control-group
.controls
= f.submit t('devise.employee.passwords.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,25 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<%= link_to "Back", :back %>
@@ -0,0 +1,22 @@
h2= t('devise.employee.registrations.title')
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :name, class: 'control-label'
.controls= f.text_field :name
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.employee.registrations.button'), class: 'button'
= render 'employees/devise/links'
@@ -0,0 +1,25 @@
h2= t('devise.employee.sign_in.title')
= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls
= f.password_field :password
- if f.object.errors[:password].present?
small.error= f.object.errors[:password].to_sentence
.control-group
.controls
= f.label :remember_me do
= f.check_box :remember_me
|&nbsp;
= t('devise.employee.sign_in.remember_me')
.control-group
.controls
= f.submit t('devise.employee.sign_in.button'), class: 'button'
= render 'employees/devise/links'
+1 -1
View File
@@ -38,4 +38,4 @@
.row
.small-12.columns== @page.footer
= render "devise/links", resource_name: :employee
/= render "devise/links", resource_name: :employee
+2 -1
View File
@@ -15,6 +15,7 @@ require 'net/http' # lib/mozo/broadcaster/faye.rb
Bundler.require(*Rails.groups(assets: %w[development test user_app]))
Bundler.require(:assets) if ENV['DEPLOY'] == 'yes'
Bundler.require(:test) if ENV['RAILS_TEST'] == 'yes'
#NOTE: the JSON.create_id getter/setter has been moved to Thread.current implementation which
# leads to "json_class" fallbacks for created threads. Maybe this will be fixed for future
@@ -254,7 +255,7 @@ module Mozo
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :nl]
config.i18n.available_locales = [:en, :es, :nl]
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
+24 -3
View File
@@ -2,12 +2,12 @@ en:
devise:
user:
sign_in:
title: Sign in
title: Sign in as user
remember_me: Remember me
link: Sign in
button: Sign in
passwords:
title: Recover password
title: Recover user password
link: Recover password
button: Send reset
edit:
@@ -18,7 +18,28 @@ en:
link: Sign up
button: Sign up
confirmations:
title: Resend confirmation instructions
title: Resend confirmation instructions for user
button: Resend confirmation instructions
did_not_receive_instructions_link: I did not receive the confirmation e-mail.
employee:
sign_in:
title: Sign in as employee
remember_me: Remember me
link: Sign in
button: Sign in
passwords:
title: Recover password for employee
link: Recover password
button: Send reset
edit:
title: Change employee password
button: Change password
registrations:
title: Sign up for mozo as a employee
link: Sign up
button: Sign up
confirmations:
title: Resend confirmation instructions for employee
button: Resend confirmation instructions
links:
prefix: 'OR:'
+45
View File
@@ -0,0 +1,45 @@
es:
devise:
user:
sign_in:
title: Iniciar sesión como usuario
remember_me: Recordarme
link: Iniciar sesión
button: Iniciar sesión
passwords:
title: Recuperar contraseña de usuario
link: Recuperar contraseña
button: Enviar reinicio
edit:
title: Cambiar tu contraseña
button: Cambiar contraseña
registrations:
title: Regístrate en mozo como usuario
link: Registrarse
button: Registrarse
confirmations:
title: Reenviar instrucciones de confirmación para usuario
button: Reenviar instrucciones de confirmación
did_not_receive_instructions_link: No recibí el correo con instrucciones de confirmar
employee:
sign_in:
title: Iniciar sesión como empleado
remember_me: Recordarme
link: Iniciar sesión
button: Iniciar sesión
passwords:
title: Recuperar contraseña de empleado
link: Recuperar contraseña
button: Enviar reinicio
edit:
title: Cambiar contraseña de empleado
button: Cambiar contraseña
registrations:
title: Regístrate en mozo como empleado
link: Registrarse
button: Registrarse
confirmations:
title: Reenviar instrucciones de confirmación para empleado
button: Reenviar instrucciones de confirmación
links:
prefix: 'O:'
+33 -12
View File
@@ -2,23 +2,44 @@ nl:
devise:
user:
sign_in:
title: Inloggen
remember_me: Mij onthouden
link: Inloggen
button: Inloggen
title: Sign in as user
remember_me: Remember me
link: Sign in
button: Sign in
passwords:
title: Wachtwoord vergeten
link: Wachtwoord vergeten
button: Stuur reset
title: Recover user password
link: Recover password
button: Send reset
edit:
title: Change your password
button: Change password
registrations:
title: Aanmelden als gebruiker
link: Aanmelden
button: Aanmelden
title: Sign up for mozo as a user
link: Sign up
button: Sign up
confirmations:
title: Resend confirmation instructions
title: Resend confirmation instructions for user
button: Resend confirmation instructions
did_not_receive_instructions_link: I did not receive the confirmation e-mail.
employee:
sign_in:
title: Sign in as employee
remember_me: Remember me
link: Sign in
button: Sign in
passwords:
title: Recover password for employee
link: Recover password
button: Send reset
edit:
title: Change employee password
button: Change password
registrations:
title: Sign up for mozo as a employee
link: Sign up
button: Sign up
confirmations:
title: Resend confirmation instructions for employee
button: Resend confirmation instructions
links:
prefix: 'OF:'
prefix: 'OR:'
+70
View File
@@ -0,0 +1,70 @@
es:
hello: "Hola mundo"
page:
not_found: "404 La página que buscaste no se encontró"
helpers:
links:
are_you_sure: '¿Estás seguro?'
place_order: Realizar pedido de %{models.order}
show_active_list: Mostrar %{list}
edit: Editar
show: Mostrar
new: Nuevo
destroy: Eliminar
back: Volver
cancel: Cancelar
index: Resumen
forms:
errors:
title: Se encontraron problemas al guardar (%{count})
submit:
create: 'Agregar %{model}'
update: 'Actualizar %{model}'
submit: 'Guardar %{model}'
list:
no_records: No hay elementos presentes
actions:
title: Acciones
messages:
cannot_order_on_non_active_list: No puedes realizar un %{models.order} en una %{models.list} cerrada
no_active_list: No hay una %{models.list} activa
order_is_placed: Tu pedido ha sido recibido correctamente
new_list_created: Se ha creado una nueva %{models.list}
the_list_has_been_closed: La %{models.list} ha sido cerrada
illegal_history_list_attempt: La %{models.list} que intentas acceder no es tuya
table_not_found: La %{models.table} solicitada no se encontró o no fue proporcionada
table_is_occupied: La %{models.table} en la que quieres sentarte ya está ocupada
table_is_reserved: La %{models.table} que quieres ocupar está reservada por otra persona
table_is_closed: La %{models.table} en la que quieres sentarte no está disponible para atender
supplier_is_closed: El propietario de esta %{models.table} actualmente no está atendiendo pedidos
join_request_rejected: Tu solicitud para unirte a la %{models.table} ha sido rechazada
join_request_approved: Tu solicitud para unirte a la %{models.table} ha sido aprobada
table_is_from_other_supplier: No puedes moverte a otra %{models.list} cuando tienes una %{models.list} abierta
moved_to_another_table: Te has movido exitosamente a otra %{models.table}
cannot_identify_table: La aplicación no puede determinar el %{models.table} %{attributes.table.number}
action:
index:
label: Listado de %{models}
new:
label: Nuevo %{model}
show:
label: Mostrando %{model}
edit:
label: Editar %{model}
create:
successfull: '%{model} se ha creado exitosamente'
update:
successfull: '%{model} se ha actualizado exitosamente'
destroy:
successfull: '%{model} se ha eliminado exitosamente'
table:
is_occupied: Esta %{models.table} está ocupada
general:
boolean:
boolean_yes: "Sí"
boolean_no: "No"
selected_products:
clear: Limpiar
order: Pedir
product_variant:
add_product_variant: Agregar %{models.product_variant}
+12
View File
@@ -0,0 +1,12 @@
es:
mailer:
supplier:
creation:
subject: 'Bienvenido a mozo.bar'
title: '¡El registro de %{name} en mozo.bar ha sido exitoso!'
user:
confirmation_instructions:
salutation: Bienvenido a mozo.bar. Te registraste con el correo %{email}
body: |
Tu registro actualmente no está confirmado. Para confirmar tu correo, haz clic en el siguiente enlace:
<a href="%{confirm_url}">Confirmar %{unconfirmed_email}</a>
+136
View File
@@ -0,0 +1,136 @@
es:
activemodel:
models:
user: Usuario
supplier: Restaurante
new_supplier: Nuevo restaurante
table: Mesa
list: Cuenta
product: Producto
order: Pedido
product_category: Categoría de producto
product_variant: Variante
section: Sección
join_request: Solicitud de unión
user_feedback: Comentario de usuario
employee: Empleado
employee_shift: Turno
svg_element: Elemento SVG
section_element: Elemento de sección
section_area: Área de sección
plural:
user: Usuarios
supplier: Restaurantes
new_supplier: Nuevos restaurantes
table: Mesas
list: Cuentas
product: Productos
order: Pedidos
product_category: Categorías de producto
product_variant: Variantes
section: Secciones
join_request: Solicitudes de unión
user_feedback: Comentarios de usuario
employee: Empleados
employee_shift: Turnos
svg_element: Elementos SVG
section_element: Elementos de sección
section_area: Áreas de sección
attributes:
product_category:
name: Nombre
position: Posición
week_days: Disponibilidad
full_day: Todo el día
start_from: Desde
end_on: Hasta
visible_on: Activo el
product:
name: Nombre
code: Código
price: Precio
description: Descripción
active: "¿Activo?"
visible: "¿Visible?"
created_at: Creado
image: Imagen
product_variant:
name: Nombre
list:
created_at: Creado
state: Estado
needs_help: Necesita atención
needs_payment: Quiere pagar
closed_at: Cerrado a las
price: Total
section:
title: Título
width: Ancho
height: Largo
created_at: Creado
supplier:
name: Nombre del %{models.supplier}
user_message: Mensaje para %{models.plural.user}
email: 'Correo electrónico'
password: 'Contraseña'
password_confirmation: 'Confirmación'
location: Ubicación
time_zone: Zona horaria
iens_profile: ID de perfil Iens
address: Dirección
postal_code: Código postal
city: Ciudad
country: País
new_supplier:
supplier_name: Nombre del restaurante
email: Correo electrónico
password: Contraseña
password_confirmation: Confirmación de contraseña
table:
table_number: Número
from_number: Desde número
to_number: Hasta número
created_at: Creado
width: Ancho
height: Alto
user:
name: Nombre
email: Correo electrónico
password: 'Contraseña'
password_confirmation: 'Confirmación'
employee:
name: Nombre
email: Correo electrónico
manager: '¿Gerente?'
active: '¿Activo?'
color: Color
employee_shift:
description: Descripción
cmtool/contact_form:
name: "Tu nombre:"
body: 'Tu pregunta o comentarios:'
email: "Tu correo electrónico:*"
male: "Sr."
female: "Sra."
svg_element:
name: Nombre
svg: SVG
dpm: Puntos por metro
box_width: Ancho de caja
box_height: Alto de caja
snap_code: Código QR
section_element:
name: Nombre
svg: SVG
dpm: Puntos por metro
box_width: Ancho de caja
box_height: Alto de caja
snap_code: Código QR
position_x: X
position_y: Y
rotation: Ángulo
section_area:
title: Título
width: Ancho
height: Alto
rounded: "¿Redondeado?"
+9
View File
@@ -0,0 +1,9 @@
es:
simple_form:
"yes": 'Sí'
"no": 'No'
required:
text: 'requerido'
mark: '*'
error_notification:
default_message: "Por favor revisa los problemas a continuación:"
+13
View File
@@ -0,0 +1,13 @@
es:
site:
home:
introduction: >
Bienvenido a la página de mozo.bar. Mozo.bar es una aplicación que te permite hacer pedidos
simplemente escaneando un código de una mesa en una terraza o restaurante. Entonces,
directamente aparece el menú y puedes hacer tu pedido. ¡Mira el progreso mientras esperas tus bebidas!
development: >
Actualmente mozo.bar está en fase de desarrollo. Esto significa que todavía hay mucho por hacer y que
estamos totalmente abiertos a toda la información que podamos recibir. Nuestra misión es complacer tanto al cliente como
al propietario del bar con las posibilidades que nos ofrece esta época.
enroll:
Inscríbete en %{facebook} o %{twitter} para mantenerte informado.
+9
View File
@@ -0,0 +1,9 @@
es:
new_supplier:
already_signed_in_new_restaurant_button_text: "Agregar un nuevo %{supplier} contigo como primer gerente"
employee_already_signed_in: |
Ya has iniciado sesión como %{employee}, por lo que hay algunas acciones posibles:
<ol>
<li><a href="/supplier" class="button">Ir a la aplicación para gestionar los pedidos</a></li>
<li>%{new_supplier_button}</li>
</ol>
+6
View File
@@ -0,0 +1,6 @@
es:
waiter:
product_orders:
order_button: Pedir
total: Total
no_orders: Sin productos
+5
View File
@@ -0,0 +1,5 @@
es:
website:
contact_form:
submitted: Has enviado el formulario de contacto exitosamente
send_button: "Enviar formulario"
@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe 'Applications', type: :controller do
subject { ApplicationController.new }
describe 'after_sign_in_path_for' do
it 'returns the user path if the resource is user' do
result = subject.after_sign_in_path_for('user')
binding.pry
end
end
end
+4
View File
@@ -3,6 +3,10 @@ FactoryBot.define do
sequence( :email ){|i| "test#{i}@example.com" }
password { "secret" }
trait :confirmed do
confirmed_at { '2026-03-04T13:44:14Z'.to_time }
end
trait :other_auth do
sequence( :email ){|i| "test-other-user#{i}@example.com" }
auth_data {{
+31 -29
View File
@@ -123,7 +123,9 @@ RSpec.configure do |config|
#config.mock_with :rspec
config.include FactoryBot::Syntax::Methods
config.include FactoryAttributesFor
config.include Devise::TestHelpers, type: :controller
#config.include Devise::TestHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::IntegrationHelpers, type: :request
config.include SpecControllerHelpers, type: :controller
config.include EndWithMatcher
config.include Matchers
@@ -142,34 +144,34 @@ RSpec.configure do |config|
config.render_views = true
config.expect_with(:rspec) { |c| c.syntax = [:expect, :should] }
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock :facebook, {
info: {
nickname: 'Joey',
name: "Facebook Joe",
first_name: "Facebook Joe"
},
credentials: {
'token' => 'fbAuthToken234',
'expires_at' => 1.week.from_now.to_i,
'expires' => true
},
uid: '123456790'
}
OmniAuth.config.add_mock :instagram, {
info: {
nickname: 'Iggy',
name: "Instagram Jane",
first_name: "Insta"
},
credentials: {
'token' => 'igAuthToken234',
'expires_at' => 1.week.from_now.to_i,
'expires' => true
},
uid: '123498765'
}
# OmniAuth.config.test_mode = true
# OmniAuth.config.add_mock :facebook, {
# info: {
# nickname: 'Joey',
# name: "Facebook Joe",
# first_name: "Facebook Joe"
# },
# credentials: {
# 'token' => 'fbAuthToken234',
# 'expires_at' => 1.week.from_now.to_i,
# 'expires' => true
# },
# uid: '123456790'
# }
#
# OmniAuth.config.add_mock :instagram, {
# info: {
# nickname: 'Iggy',
# name: "Instagram Jane",
# first_name: "Insta"
# },
# credentials: {
# 'token' => 'igAuthToken234',
# 'expires_at' => 1.week.from_now.to_i,
# 'expires' => true
# },
# uid: '123498765'
# }
# Use color in STDOUT
config.color = true
+45
View File
@@ -0,0 +1,45 @@
require 'rails_helper'
RSpec.describe "UserSignIns", type: :request do
describe "GET /users/sign_in" do
it "works! (now write some real specs)" do
get new_user_session_path
expect(response).to have_http_status(200)
end
end
describe 'POST /users/sign_in' do
context 'no user' do
it 'shows appropriate message' do
post user_session_path, params: {user: {email: 'user435@example.com', password: 'test124'}}
# expect(response.redirect_url.to_s).to include '/users/sign_in'
# get response.redirect_url
expect(response.body).to include 'Invalid email or password'
end
end
context 'unconfirmed user' do
let!(:user) { create :user, password: 'test124' }
it 'shows message indicating that there should be a confirmation' do
post user_session_path, params: {user: {email: user.email, password: 'test124'}}
expect(response.redirect_url.to_s).to include '/users/sign_in'
get response.redirect_url
expect(response.body).to include 'You have to confirm your account before continuing'
end
end
context 'confirmed user' do
let!(:user) { create :user, :confirmed, password: 'test124' }
it 'redirects to the user app' do
post user_session_path, params: {user: {email: user.email, password: 'test124'}}
expect(response.redirect_url).to eq Mozo.user_url
expect(response.redirect_url).to eq 'https://user.mozo.bar'
end
end
end
end