2014-07-27 01:50:22 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Free Software groups life cycle
|
2015-02-15 17:10:17 +01:00
|
|
|
class OrgasControllerTest < ActionController::TestCase
|
2015-02-28 17:28:05 +01:00
|
|
|
include Devise::TestHelpers
|
2015-07-25 18:32:27 +02:00
|
|
|
|
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
|
2014-07-27 01:50:22 +02:00
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
2015-02-28 17:28:05 +01:00
|
|
|
test 'should get new' do
|
|
|
|
sign_in users(:one)
|
|
|
|
get :new
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should create orga' do
|
|
|
|
sign_in users(:one)
|
|
|
|
assert_difference 'Orga.count' do
|
|
|
|
post :create, orga: {
|
|
|
|
kind_id: @orga.kind_id,
|
|
|
|
name: @orga.name,
|
|
|
|
city: @orga.city,
|
|
|
|
region_id: @orga.region.id,
|
|
|
|
url: @orga.url,
|
|
|
|
feed: @orga.feed,
|
2015-12-26 23:32:04 +01:00
|
|
|
contact: @orga.contact,
|
|
|
|
submitter: @orga.contact
|
2015-02-28 17:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_empty assigns(:orga).errors.messages
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to :root
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not create orga' do
|
|
|
|
sign_in users(:one)
|
|
|
|
assert_no_difference 'Orga.count' do
|
|
|
|
post :create, orga: { url: @orga.url }
|
|
|
|
|
|
|
|
assert_not_empty assigns(:orga).errors.messages
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
test 'should get show' do
|
2015-02-15 17:10:17 +01:00
|
|
|
get :show, id: @orga
|
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
|
|
|
|
@orga.update_attributes name: 'My Title'
|
|
|
|
|
2015-05-25 11:42:53 +02:00
|
|
|
patch :update, id: @orga, orga: { name: @orga.name }
|
|
|
|
|
|
|
|
assert_empty assigns(:orga).errors.messages
|
|
|
|
assert_redirected_to assigns(:orga)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not update orga' do
|
|
|
|
sign_in users(:one)
|
|
|
|
patch :update, id: @orga, orga: { name: nil }
|
|
|
|
|
|
|
|
assert_not_empty assigns(:orga).errors.messages
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should not update orga without proper secret' do
|
|
|
|
patch :update, id: @orga, secret: @orga.secret, orga: {
|
|
|
|
name: 'hello world'
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_redirected_to assigns(:orga)
|
|
|
|
end
|
2014-07-27 01:50:22 +02:00
|
|
|
end
|