mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 03:31:42 +00:00
46 lines
937 B
Ruby
46 lines
937 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class SitesControllerTest < ActionDispatch::IntegrationTest
|
||
|
setup do
|
||
|
@rol = create :rol
|
||
|
@site = @rol.site
|
||
|
@usuarie = @rol.usuarie
|
||
|
|
||
|
@authorization = {
|
||
|
Authorization: ActionController::HttpAuthentication::Basic
|
||
|
.encode_credentials(@usuarie.email, @usuarie.password)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
teardown do
|
||
|
@site.destroy
|
||
|
end
|
||
|
|
||
|
test 'se pueden ver' do
|
||
|
get sites_url, headers: @authorization
|
||
|
|
||
|
assert_match @site.name, response.body
|
||
|
end
|
||
|
|
||
|
test 'se puede ver el formulario de creación' do
|
||
|
get new_site_url, headers: @authorization
|
||
|
|
||
|
assert_match(/<form.*id="new_site"/, response.body)
|
||
|
end
|
||
|
|
||
|
test 'se pueden crear' do
|
||
|
name = SecureRandom.hex
|
||
|
|
||
|
post sites_url, headers: @authorization, params: {
|
||
|
site: {
|
||
|
name: name
|
||
|
}
|
||
|
}
|
||
|
|
||
|
assert_nothing_raised do
|
||
|
site = Site.find_by_name(name)
|
||
|
site.destroy
|
||
|
end
|
||
|
end
|
||
|
end
|