pass the local and the current Rack request to the 'new sign up' notification

did committed Jun 22, 2017
commit 3d3806a436f5ef073f43e202d24442da754df9b8
Showing 3 changed files with 9 additions and 4 deletions
locomotive/steam/middlewares/auth.rb b/lib/locomotive/steam/middlewares/auth.rb +1 -1
@@ @@ -30,7 +30,7 @@ module Locomotive::Steam
def sign_up(options)
return if authenticated?
- status, entry = services.auth.sign_up(options, default_liquid_context)
+ status, entry = services.auth.sign_up(options, default_liquid_context, request)
if status == :entry_created
store_authenticated(entry)
locomotive/steam/services/auth_service.rb b/lib/locomotive/steam/services/auth_service.rb +7 -2
@@ @@ -12,14 +12,19 @@ module Locomotive
entries.find(type, id)
end
- def sign_up(options, context)
+ def sign_up(options, context, request = nil)
entry = entries.create(options.type, options.entry) do |_entry|
_entry.extend(ContentEntryAuth)
_entry[:_password_field] = options.password_field.to_sym
end
if entry.errors.empty?
- ActiveSupport::Notifications.instrument('steam.auth.signup', site: site, entry: entry)
+ ActiveSupport::Notifications.instrument('steam.auth.signup',
+ site: site,
+ entry: entry,
+ locale: entries.locale,
+ request: request
+ )
context[options.type.singularize] = entry
send_welcome_email(options, context)
spec/unit/services/auth_service_spec.rb +1 -1
@@ @@ -3,7 +3,7 @@ require 'spec_helper'
describe Locomotive::Steam::AuthService do
let(:site) { instance_double('CurrentSite') }
- let(:entries) { instance_double('ContentService') }
+ let(:entries) { instance_double('ContentService', locale: 'en') }
let(:emails) { instance_double('EmailService') }
let(:service) { described_class.new(site, entries, emails) }
let(:liquid_context) { {} }