Project

General

Profile

« Previous | Next » 

Revision edd5310f

Added by Dominic Cleal about 7 years ago

fixes #19131 - upgrade minitest to latest 5.x

- override minitest's `_` expectation method with the gettext method
- rename `location` let helper, conflicted with a minitest method name
- fix `assert_equal nil, [..]` deprecation warnings, prefer `assert nil`

Contains fixes for tests that leak data or behavioral changes between
tests, as the ordering of test cases is now randomised:

- remove Host/Nic class modifications in orchestration concern test
- move NotificationBlueprint seeding into test transaction, preventing
DB truncation in integration tests from removing the records
- ensure DBCleaner.start is called when in transaction mode to prevent
records leaking out of integration tests
- sort records for reliable comparisons in TaxonomyTest
- move IPs of BMC NIC factory objects to 1.0.0.0/8 to avoid duplicates
- remove duplicate SettingTest cache clear, missing rescue

View differences:

test/controllers/notification_recipients_controller_test.rb
require 'test_helper'
require 'notifications_test_helper'
class NotificationRecipientsControllerTest < ActionController::TestCase
setup do
......
assert_empty response['notifications']
end
test "notification when host is destroyed" do
host = FactoryGirl.create(:host)
assert host.destroy
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has been deleted successfully", response['notifications'][0]["text"]
end
test "notification when host is built" do
host = FactoryGirl.create(:host, owner: User.current)
assert host.update_attribute(:build, true)
assert host.built
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has been provisioned successfully", response['notifications'][0]["text"]
end
test "notification when host has no owner" do
host = FactoryGirl.create(:host, :managed)
User.current = nil
assert host.update_attributes(owner_id: nil, owner_type: nil, build: true)
assert_nil host.owner
assert host.built
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has no owner set", response['notifications'][0]["text"]
context "with seeded notification types" do
include NotificationBlueprintSeeds
test "notification when host is destroyed" do
host = FactoryGirl.create(:host)
assert host.destroy
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has been deleted successfully", response['notifications'][0]["text"]
end
test "notification when host is built" do
host = FactoryGirl.create(:host, owner: User.current)
assert host.update_attribute(:build, true)
assert host.built
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has been provisioned successfully", response['notifications'][0]["text"]
end
test "notification when host has no owner" do
host = FactoryGirl.create(:host, :managed)
User.current = nil
assert host.update_attributes(owner_id: nil, owner_type: nil, build: true)
assert_nil host.owner
assert host.built
get :index, { :format => 'json' }, set_session_user
assert_response :success
response = ActiveSupport::JSON.decode(@response.body)
assert_equal 1, response['notifications'].size
assert_equal "#{host} has no owner set", response['notifications'][0]["text"]
end
end
test 'group mark as read' do

Also available in: Unified diff