Project

General

Profile

« Previous | Next » 

Revision 445dd7ab

Added by Daniel Lobato Garcia almost 9 years ago

Fixes #11089 - Adapt tests to Rails 4

This commit contains all changes to tests in branch
https://github.com/theforeman/foreman/pull/2055 that I found to be
retrocompatible with Rails 3. The more of these we can get in, the less
code we will have to review for Rails 4, and the more relevant it will
be, as it'll be all completly Rails 4 specific.

View differences:

test/functional/operatingsystems_controller_test.rb
test 'create invalid' do
Operatingsystem.any_instance.stubs(:valid?).returns(false)
post :create, {}, set_session_user
post :create, {:operatingsystem => {:name => nil}}, set_session_user
assert_template 'new'
end
......
test 'update invalid' do
Operatingsystem.any_instance.stubs(:valid?).returns(false)
Redhat.any_instance.stubs(:valid?).returns(false)
put :update, {:id => Operatingsystem.first}, set_session_user
put :update, {:id => Operatingsystem.first, :operatingsystem => {:name => Operatingsystem.first.name}}, set_session_user
assert_template 'edit'
end
end
......
context 'redirects' do
test 'create valid' do
Operatingsystem.any_instance.stubs(:valid?).returns(true)
post :create, {}, set_session_user
post :create, {:operatingsystem => {:name => "MyOS"}}, set_session_user
assert_redirected_to operatingsystems_url
end
test 'update valid' do
Operatingsystem.any_instance.stubs(:valid?).returns(true)
Redhat.any_instance.stubs(:valid?).returns(true)
put :update, {:id => Operatingsystem.first}, set_session_user
put :update, {:id => Operatingsystem.first, :operatingsystem => {:name => "MyOS"}}, set_session_user
assert_redirected_to operatingsystems_url
end
......
assert_difference 'OsDefaultTemplate.count', -1 do
os_default_template_id = operatingsystem.os_default_templates.first.id
put :update, {:id => operatingsystem.id,
:operatingsystem => {:os_default_templates_attributes => {0 => { :id => os_default_template_id, :provisioning_template_id => '', :template_kind_id => @template_kind.id }}}}, set_session_user
:operatingsystem => {:os_default_templates_attributes => [{ :id => os_default_template_id, :provisioning_template_id => '', :template_kind_id => @template_kind.id }]}}, set_session_user
end
end
end

Also available in: Unified diff