2014-07-27 01:50:22 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
2017-11-11 12:44:09 +01:00
|
|
|
# Organisations life cycle tests
|
|
|
|
class OrgasControllerTest < ActionDispatch::IntegrationTest
|
2014-07-27 01:50:22 +02:00
|
|
|
setup do
|
2015-02-15 17:10:17 +01:00
|
|
|
@orga = orgas :one
|
2014-07-27 01:50:22 +02:00
|
|
|
end
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
test 'should get index' do
|
2017-11-11 12:44:09 +01:00
|
|
|
get orgas_url, params: {
|
|
|
|
orga: {
|
|
|
|
region: regions(:region_one)
|
|
|
|
}
|
|
|
|
}
|
2014-07-27 01:50:22 +02:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2015-02-28 17:28:05 +01:00
|
|
|
test 'should get new' do
|
2017-11-11 12:44:09 +01:00
|
|
|
get new_orga_url
|
2015-02-28 17:28:05 +01:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should create orga' do
|
|
|
|
assert_difference 'Orga.count' do
|
2017-11-11 12:44:09 +01:00
|
|
|
post orgas_url, params: {
|
|
|
|
orga: {
|
|
|
|
kind_id: @orga.kind_id,
|
|
|
|
name: @orga.name,
|
|
|
|
city: @orga.city,
|
|
|
|
region_id: @orga.region.id,
|
|
|
|
description: @orga.description,
|
|
|
|
url: @orga.url,
|
|
|
|
feed: @orga.feed,
|
|
|
|
contact: @orga.contact,
|
|
|
|
submitter: @orga.contact
|
|
|
|
}
|
2015-02-28 17:28:05 +01:00
|
|
|
}
|
2017-07-02 12:16:53 +02:00
|
|
|
end
|
|
|
|
|
2018-03-01 20:42:14 +01:00
|
|
|
assert_redirected_to assigns(:orga)
|
2017-07-02 12:16:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should create minimalist orga' do
|
|
|
|
assert_difference 'Orga.count' do
|
2017-11-11 12:44:09 +01:00
|
|
|
post orgas_url, params: {
|
|
|
|
orga: {
|
|
|
|
kind_id: @orga.kind_id,
|
|
|
|
name: @orga.name,
|
|
|
|
region_id: @orga.region.id,
|
|
|
|
description: @orga.description,
|
|
|
|
url: @orga.url
|
|
|
|
}
|
2017-07-02 12:16:53 +02:00
|
|
|
}
|
2015-02-28 17:28:05 +01:00
|
|
|
end
|
|
|
|
|
2018-03-01 20:42:14 +01:00
|
|
|
assert_redirected_to assigns(:orga)
|
2015-02-28 17:28:05 +01:00
|
|
|
end
|
|
|
|
|
2019-06-20 21:59:04 +02:00
|
|
|
test 'should create orga without content' do
|
|
|
|
assert_difference 'Orga.count' do
|
|
|
|
post orgas_url, params: {
|
|
|
|
orga: {
|
|
|
|
kind_id: @orga.kind_id,
|
|
|
|
name: @orga.name,
|
|
|
|
region_id: @orga.region.id,
|
|
|
|
url: @orga.url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to assigns(:orga)
|
|
|
|
end
|
|
|
|
|
2015-02-28 17:28:05 +01:00
|
|
|
test 'should not create orga' do
|
|
|
|
assert_no_difference 'Orga.count' do
|
2017-11-11 12:44:09 +01:00
|
|
|
post orgas_url, params: {
|
|
|
|
orga: { url: @orga.url }
|
|
|
|
}
|
2015-02-28 17:28:05 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
test 'should get show' do
|
2017-11-11 12:44:09 +01:00
|
|
|
get orga_url(@orga.id)
|
2014-07-27 01:50:22 +02:00
|
|
|
assert_response :success
|
|
|
|
end
|
2015-05-25 11:42:53 +02:00
|
|
|
|
|
|
|
test 'should update orga' do
|
2015-09-05 18:56:48 +02:00
|
|
|
# Necessary to have the proper paper_trail version
|
2018-03-17 15:49:43 +01:00
|
|
|
@orga.update name: 'My Title'
|
2015-09-05 18:56:48 +02:00
|
|
|
|
2017-11-11 12:44:09 +01:00
|
|
|
patch orga_url(@orga), params: {
|
|
|
|
secret: @orga.secret,
|
|
|
|
orga: { name: @orga.name }
|
|
|
|
}
|
2015-05-25 11:42:53 +02:00
|
|
|
|
2017-11-11 12:44:09 +01:00
|
|
|
assert_redirected_to orga_url(@orga)
|
2015-05-25 11:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not update orga' do
|
2017-11-11 12:44:09 +01:00
|
|
|
patch orga_url(@orga), params: {
|
|
|
|
orga: { name: nil }
|
|
|
|
}
|
2015-05-25 11:42:53 +02:00
|
|
|
|
2017-11-11 12:44:09 +01:00
|
|
|
assert_redirected_to :new_user_session
|
2015-05-25 11:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not update orga without proper secret' do
|
2017-11-11 12:44:09 +01:00
|
|
|
patch orga_url(@orga), params: {
|
|
|
|
orga: {
|
|
|
|
name: 'hello world'
|
|
|
|
}
|
2015-05-25 11:42:53 +02:00
|
|
|
}
|
|
|
|
|
2016-02-13 17:24:23 +01:00
|
|
|
assert_redirected_to :new_user_session
|
2015-05-25 11:42:53 +02:00
|
|
|
end
|
2014-07-27 01:50:22 +02:00
|
|
|
end
|