2020-02-18 16:45:08 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class PostsControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
setup do
|
|
|
|
@rol = create :rol
|
|
|
|
@site = @rol.site
|
|
|
|
@usuarie = @rol.usuarie
|
|
|
|
|
|
|
|
@site.update_attribute :colaboracion_anonima, true
|
2021-04-15 14:34:42 +00:00
|
|
|
@host = { host: "api.#{Site.domain}" }
|
2020-02-18 16:45:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
teardown do
|
|
|
|
@site.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'primero hay que pedir una cookie' do
|
2021-04-15 14:34:42 +00:00
|
|
|
get v1_site_invitades_cookie_url(@site.hostname, **@host)
|
2020-02-18 16:45:08 +00:00
|
|
|
|
|
|
|
assert cookies[@site.name]
|
|
|
|
assert cookies['_sutty_session']
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'solo si el sitio existe' do
|
|
|
|
site = SecureRandom.hex
|
|
|
|
|
2021-04-15 14:34:42 +00:00
|
|
|
get v1_site_invitades_cookie_url(site_id: site, **@host)
|
2020-02-18 16:45:08 +00:00
|
|
|
|
|
|
|
assert_not cookies[site]
|
|
|
|
assert_not cookies['_sutty_session']
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'solo si el sitio tiene colaboracion anonima' do
|
|
|
|
@site.update_attribute :colaboracion_anonima, false
|
|
|
|
|
2021-04-15 14:34:42 +00:00
|
|
|
get v1_site_invitades_cookie_url(@site.hostname, **@host)
|
2020-02-18 16:45:08 +00:00
|
|
|
|
|
|
|
assert_not cookies[@site.name]
|
|
|
|
assert_not cookies['_sutty_session']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|