Maintenance: Fixed data leaking test by migrating to db_strategy: :reset
from use_transactional_tests
.
This commit is contained in:
parent
b930827b77
commit
e474539f55
1 changed files with 91 additions and 90 deletions
|
@ -3,8 +3,6 @@ require 'rails_helper'
|
|||
RSpec.describe NotificationFactory::Renderer do
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
describe 'render' do
|
||||
self.use_transactional_tests = false
|
||||
|
||||
before { @user = User.where(firstname: 'Nicole').first }
|
||||
|
||||
it 'correctly renders a blank template' do
|
||||
|
@ -31,118 +29,121 @@ RSpec.describe NotificationFactory::Renderer do
|
|||
ticket.destroy
|
||||
end
|
||||
|
||||
it 'correctly renders simple select attributes' do
|
||||
create :object_manager_attribute_select, name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
context 'when handling ObjectManager::Attribute usage', db_strategy: :reset do
|
||||
|
||||
ticket = create :ticket, customer: @user, select: 'key_1'
|
||||
it 'correctly renders simple select attributes' do
|
||||
create :object_manager_attribute_select, name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.select} _SEPERATOR_ #{ticket.select.value}'
|
||||
ticket = create :ticket, customer: @user, select: 'key_1'
|
||||
|
||||
expect(renderer.render).to eq 'key_1 _SEPERATOR_ value_1'
|
||||
ticket.destroy
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.select} _SEPERATOR_ #{ticket.select.value}'
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Ticket',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
expect(renderer.render).to eq 'key_1 _SEPERATOR_ value_1'
|
||||
ticket.destroy
|
||||
|
||||
it 'correctly renders select attributes on chained user object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('User'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Ticket',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
|
||||
user = User.where(firstname: 'Nicole').first
|
||||
user.select = 'key_2'
|
||||
user.save
|
||||
ticket = create :ticket, customer: user
|
||||
it 'correctly renders select attributes on chained user object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('User'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.customer.select} _SEPERATOR_ #{ticket.customer.select.value}'
|
||||
user = User.where(firstname: 'Nicole').first
|
||||
user.select = 'key_2'
|
||||
user.save
|
||||
ticket = create :ticket, customer: user
|
||||
|
||||
expect(renderer.render).to eq 'key_2 _SEPERATOR_ value_2'
|
||||
ticket.destroy
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.customer.select} _SEPERATOR_ #{ticket.customer.select.value}'
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'User',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
expect(renderer.render).to eq 'key_2 _SEPERATOR_ value_2'
|
||||
ticket.destroy
|
||||
|
||||
it 'correctly renders select attributes on chained group object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('Group'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'User',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
|
||||
ticket = create :ticket, customer: @user
|
||||
group = ticket.group
|
||||
group.select = 'key_3'
|
||||
group.save
|
||||
it 'correctly renders select attributes on chained group object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('Group'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.group.select} _SEPERATOR_ #{ticket.group.select.value}'
|
||||
ticket = create :ticket, customer: @user
|
||||
group = ticket.group
|
||||
group.select = 'key_3'
|
||||
group.save
|
||||
|
||||
expect(renderer.render).to eq 'key_3 _SEPERATOR_ value_3'
|
||||
ticket.destroy
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.group.select} _SEPERATOR_ #{ticket.group.select.value}'
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Group',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
expect(renderer.render).to eq 'key_3 _SEPERATOR_ value_3'
|
||||
ticket.destroy
|
||||
|
||||
it 'correctly renders select attributes on chained organization object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('Organization'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Group',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
|
||||
@user.organization.select = 'key_2'
|
||||
@user.organization.save
|
||||
ticket = create :ticket, customer: @user
|
||||
it 'correctly renders select attributes on chained organization object' do
|
||||
create :object_manager_attribute_select,
|
||||
object_lookup_id: ObjectLookup.by_name('Organization'),
|
||||
name: 'select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.customer.organization.select} _SEPERATOR_ #{ticket.customer.organization.select.value}'
|
||||
@user.organization.select = 'key_2'
|
||||
@user.organization.save
|
||||
ticket = create :ticket, customer: @user
|
||||
|
||||
expect(renderer.render).to eq 'key_2 _SEPERATOR_ value_2'
|
||||
ticket.destroy
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.customer.organization.select} _SEPERATOR_ #{ticket.customer.organization.select.value}'
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Organization',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
expect(renderer.render).to eq 'key_2 _SEPERATOR_ value_2'
|
||||
ticket.destroy
|
||||
|
||||
it 'correctly renders tree select attributes' do
|
||||
create :object_manager_attribute_tree_select, name: 'tree_select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Organization',
|
||||
name: 'select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
|
||||
ticket = create :ticket, customer: @user, tree_select: 'Incident::Hardware::Laptop'
|
||||
it 'correctly renders tree select attributes' do
|
||||
create :object_manager_attribute_tree_select, name: 'tree_select'
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.tree_select} _SEPERATOR_ #{ticket.tree_select.value}'
|
||||
ticket = create :ticket, customer: @user, tree_select: 'Incident::Hardware::Laptop'
|
||||
|
||||
expect(renderer.render).to eq 'Incident::Hardware::Laptop _SEPERATOR_ Incident::Hardware::Laptop'
|
||||
ticket.destroy
|
||||
renderer = build :notification_factory_renderer,
|
||||
objects: { ticket: ticket },
|
||||
template: '#{ticket.tree_select} _SEPERATOR_ #{ticket.tree_select.value}'
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Ticket',
|
||||
name: 'tree_select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
expect(renderer.render).to eq 'Incident::Hardware::Laptop _SEPERATOR_ Incident::Hardware::Laptop'
|
||||
ticket.destroy
|
||||
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'Ticket',
|
||||
name: 'tree_select',
|
||||
)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
|
|
Loading…
Reference in a new issue