agenda-libre-ruby/test/controllers/orgas_controller_test.rb

80 lines
1.7 KiB
Ruby
Raw Normal View History

2014-07-27 01:50:22 +02:00
require 'test_helper'
# Free Software groups life cycle
2015-02-15 17:10:17 +01:00
class OrgasControllerTest < ActionController::TestCase
include Devise::TestHelpers
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
test 'should get index' do
2014-07-27 01:50:22 +02:00
get :index
assert_response :success
end
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,
contact: @orga.contact
}
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
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
# 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