From 4e1d3bd052e094671698525f378a014946e443b0 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 9 Mar 2026 11:17:25 -0500 Subject: [PATCH] Add spanish locales and gravatar options --- app/controllers/application_controller.rb | 27 +++- app/controllers/registrations_controller.rb | 13 -- app/controllers/waiter_controller.rb | 40 +++--- app/models/employee.rb | 5 +- app/models/supplier.rb | 2 +- app/models/user.rb | 6 + app/serializers/suppliers/user_serializer.rb | 2 +- app/serializers/users/user_serializer.rb | 2 +- .../employees/confirmations/new.html.slim | 11 ++ app/views/employees/devise/_links.html.slim | 23 +++ app/views/employees/passwords/edit.html.slim | 22 +-- app/views/employees/passwords/new.html.slim | 16 ++- .../employees/registrations/edit.html.erb | 25 ++++ .../employees/registrations/new.html.slim | 22 +++ app/views/employees/sessions/new.html.slim | 25 ++++ app/views/new_suppliers/new.html.slim | 2 +- config/application.rb | 3 +- config/locales/devise.en.yml | 27 +++- config/locales/devise.es.yml | 45 ++++++ config/locales/devise.nl.yml | 45 ++++-- config/locales/es.yml | 70 +++++++++ config/locales/mailer.es.yml | 12 ++ config/locales/models.es.yml | 136 ++++++++++++++++++ config/locales/simple_form.es.yml | 9 ++ config/locales/site.es.yml | 13 ++ config/locales/supplier.es.yml | 9 ++ config/locales/waiter.es.yml | 6 + config/locales/website.es.yml | 5 + .../application_controller_spec.rb | 14 ++ spec/factories/user_factory.rb | 4 + spec/rails_helper.rb | 60 ++++---- spec/requests/user_sign_ins_spec.rb | 45 ++++++ 32 files changed, 640 insertions(+), 106 deletions(-) delete mode 100644 app/controllers/registrations_controller.rb create mode 100644 app/views/employees/confirmations/new.html.slim create mode 100644 app/views/employees/devise/_links.html.slim create mode 100644 app/views/employees/registrations/edit.html.erb create mode 100644 app/views/employees/registrations/new.html.slim create mode 100644 app/views/employees/sessions/new.html.slim create mode 100644 config/locales/devise.es.yml create mode 100644 config/locales/es.yml create mode 100644 config/locales/mailer.es.yml create mode 100644 config/locales/models.es.yml create mode 100644 config/locales/simple_form.es.yml create mode 100644 config/locales/site.es.yml create mode 100644 config/locales/supplier.es.yml create mode 100644 config/locales/waiter.es.yml create mode 100644 config/locales/website.es.yml create mode 100644 spec/controllers/application_controller_spec.rb create mode 100644 spec/requests/user_sign_ins_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 801e57cd..35016d7a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,7 +13,20 @@ class ApplicationController < ActionController::Base rescue_from SimplyStored::RecordNotFound, with: :show_404 -private + # 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! if auth_token = params[:auth_token].presence || request.headers['HTTP_AUTH_TOKEN'].presence @@ -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,9 +112,10 @@ private def after_sign_in_path_for(resource) case resource - when Employee then supplier_root_path - when Administrator then cmtool.root_path - else root_path + when User then Mozo.user_url + when Employee then Mozo.supplier_url + when Administrator then cmtool.root_path + else root_path end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb deleted file mode 100644 index bb6544de..00000000 --- a/app/controllers/registrations_controller.rb +++ /dev/null @@ -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 diff --git a/app/controllers/waiter_controller.rb b/app/controllers/waiter_controller.rb index e14c8330..d3b454d3 100644 --- a/app/controllers/waiter_controller.rb +++ b/app/controllers/waiter_controller.rb @@ -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 diff --git a/app/models/employee.rb b/app/models/employee.rb index d0f066ab..de79cd35 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -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 diff --git a/app/models/supplier.rb b/app/models/supplier.rb index c2217153..ca797f6e 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 782439c3..da8bc948 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/serializers/suppliers/user_serializer.rb b/app/serializers/suppliers/user_serializer.rb index 54b49141..fbda4771 100644 --- a/app/serializers/suppliers/user_serializer.rb +++ b/app/serializers/suppliers/user_serializer.rb @@ -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 diff --git a/app/serializers/users/user_serializer.rb b/app/serializers/users/user_serializer.rb index 20f15cdf..6aaa9629 100644 --- a/app/serializers/users/user_serializer.rb +++ b/app/serializers/users/user_serializer.rb @@ -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 diff --git a/app/views/employees/confirmations/new.html.slim b/app/views/employees/confirmations/new.html.slim new file mode 100644 index 00000000..cecc8286 --- /dev/null +++ b/app/views/employees/confirmations/new.html.slim @@ -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' diff --git a/app/views/employees/devise/_links.html.slim b/app/views/employees/devise/_links.html.slim new file mode 100644 index 00000000..debb3d35 --- /dev/null +++ b/app/views/employees/devise/_links.html.slim @@ -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] diff --git a/app/views/employees/passwords/edit.html.slim b/app/views/employees/passwords/edit.html.slim index 8530022d..e2b459c6 100644 --- a/app/views/employees/passwords/edit.html.slim +++ b/app/views/employees/passwords/edit.html.slim @@ -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' diff --git a/app/views/employees/passwords/new.html.slim b/app/views/employees/passwords/new.html.slim index 53b9183a..e259a019 100644 --- a/app/views/employees/passwords/new.html.slim +++ b/app/views/employees/passwords/new.html.slim @@ -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' diff --git a/app/views/employees/registrations/edit.html.erb b/app/views/employees/registrations/edit.html.erb new file mode 100644 index 00000000..bb66fbf2 --- /dev/null +++ b/app/views/employees/registrations/edit.html.erb @@ -0,0 +1,25 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+ +
<%= f.submit "Update" %>
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +<%= link_to "Back", :back %> diff --git a/app/views/employees/registrations/new.html.slim b/app/views/employees/registrations/new.html.slim new file mode 100644 index 00000000..f7af7bf7 --- /dev/null +++ b/app/views/employees/registrations/new.html.slim @@ -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' diff --git a/app/views/employees/sessions/new.html.slim b/app/views/employees/sessions/new.html.slim new file mode 100644 index 00000000..7b4b5dda --- /dev/null +++ b/app/views/employees/sessions/new.html.slim @@ -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 + |  + = t('devise.employee.sign_in.remember_me') + .control-group + .controls + = f.submit t('devise.employee.sign_in.button'), class: 'button' += render 'employees/devise/links' diff --git a/app/views/new_suppliers/new.html.slim b/app/views/new_suppliers/new.html.slim index 89eab07a..557b3aff 100644 --- a/app/views/new_suppliers/new.html.slim +++ b/app/views/new_suppliers/new.html.slim @@ -38,4 +38,4 @@ .row .small-12.columns== @page.footer -= render "devise/links", resource_name: :employee +/= render "devise/links", resource_name: :employee diff --git a/config/application.rb b/config/application.rb index 6e5473dc..6f7076cd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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" diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 87136241..575f3404 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -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:' diff --git a/config/locales/devise.es.yml b/config/locales/devise.es.yml new file mode 100644 index 00000000..479e91cb --- /dev/null +++ b/config/locales/devise.es.yml @@ -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:' diff --git a/config/locales/devise.nl.yml b/config/locales/devise.nl.yml index 98f409f6..97182efa 100644 --- a/config/locales/devise.nl.yml +++ b/config/locales/devise.nl.yml @@ -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:' diff --git a/config/locales/es.yml b/config/locales/es.yml new file mode 100644 index 00000000..166f498a --- /dev/null +++ b/config/locales/es.yml @@ -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} diff --git a/config/locales/mailer.es.yml b/config/locales/mailer.es.yml new file mode 100644 index 00000000..04bdb588 --- /dev/null +++ b/config/locales/mailer.es.yml @@ -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: + Confirmar %{unconfirmed_email} diff --git a/config/locales/models.es.yml b/config/locales/models.es.yml new file mode 100644 index 00000000..0da1ef09 --- /dev/null +++ b/config/locales/models.es.yml @@ -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?" diff --git a/config/locales/simple_form.es.yml b/config/locales/simple_form.es.yml new file mode 100644 index 00000000..2cb08de0 --- /dev/null +++ b/config/locales/simple_form.es.yml @@ -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:" diff --git a/config/locales/site.es.yml b/config/locales/site.es.yml new file mode 100644 index 00000000..d54939a7 --- /dev/null +++ b/config/locales/site.es.yml @@ -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. diff --git a/config/locales/supplier.es.yml b/config/locales/supplier.es.yml new file mode 100644 index 00000000..0463ff4e --- /dev/null +++ b/config/locales/supplier.es.yml @@ -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: +
    +
  1. Ir a la aplicación para gestionar los pedidos
  2. +
  3. %{new_supplier_button}
  4. +
diff --git a/config/locales/waiter.es.yml b/config/locales/waiter.es.yml new file mode 100644 index 00000000..dec16be5 --- /dev/null +++ b/config/locales/waiter.es.yml @@ -0,0 +1,6 @@ +es: + waiter: + product_orders: + order_button: Pedir + total: Total + no_orders: Sin productos diff --git a/config/locales/website.es.yml b/config/locales/website.es.yml new file mode 100644 index 00000000..c7e74326 --- /dev/null +++ b/config/locales/website.es.yml @@ -0,0 +1,5 @@ +es: + website: + contact_form: + submitted: Has enviado el formulario de contacto exitosamente + send_button: "Enviar formulario" diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb new file mode 100644 index 00000000..de96b164 --- /dev/null +++ b/spec/controllers/application_controller_spec.rb @@ -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 diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index 4e48a94c..add67f60 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -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 {{ diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 058d406e..7a949ed3 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 diff --git a/spec/requests/user_sign_ins_spec.rb b/spec/requests/user_sign_ins_spec.rb new file mode 100644 index 00000000..b924a6b1 --- /dev/null +++ b/spec/requests/user_sign_ins_spec.rb @@ -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