5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 13:36:06 +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
end
def site_id
params[:site_id].gsub(/\.#{Site.domain}\z/, '')
end
# Encuentra el sitio
def site
@site ||= Site.find_by(name: params[:site_id])
@site ||= Site.find_by(name: site_id)
end
# Parámetros limpios

View file

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