5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-03 13:26:07 +00:00

usar el nombre del sitio y no el hostname

This commit is contained in:
f 2020-03-25 15:36:06 -03:00
parent abae3b5141
commit eb2bdacd5c
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 13 additions and 3 deletions

View file

@ -64,9 +64,13 @@ module Api
render html: body(:gave_consent), status: status render html: body(:gave_consent), status: status
end end
def site_id
params[:site_id].gsub(/\.#{Site.domain}\z/, '')
end
# Encuentra el sitio # Encuentra el sitio
def site def site
@site ||= Site.find_by(name: params[:site_id]) @site ||= Site.find_by(name: site_id)
end end
# Parámetros limpios # Parámetros limpios

View file

@ -65,11 +65,15 @@ module Api
end end
test 'enviar un mensaje genera correos' do test 'enviar un mensaje genera correos' do
ActionMailer::Base.deliveries.clear
redirect = "#{@site.url}/?thanks"
10.times do 10.times do
create :rol, site: @site create :rol, site: @site
end end
post v1_site_contact_url(@site), post v1_site_contact_url(site_id: @site.hostname),
headers: { headers: {
Origin: @site.url Origin: @site.url
}, },
@ -79,9 +83,11 @@ module Api
contact: SecureRandom.hex, contact: SecureRandom.hex,
from: "#{SecureRandom.hex}@sutty.nl", from: "#{SecureRandom.hex}@sutty.nl",
body: SecureRandom.hex, body: SecureRandom.hex,
gdpr: true gdpr: true,
redirect: redirect
} }
assert_equal redirect, response.headers['Location']
assert_equal 2, ActionMailer::Base.deliveries.size assert_equal 2, ActionMailer::Base.deliveries.size
end end
end end