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

54 lines
1.1 KiB
Ruby

require 'test_helper'
# Free Software groups life cycle
class OrgasControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@orga = orgas :one
end
test 'should get index' do
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
get :show, id: @orga
assert_response :success
end
end