Small code cleanup.

This commit is contained in:
Martin Edenhofer 2018-06-22 13:12:51 +02:00
parent 24a30ad26c
commit f80fbf4744
19 changed files with 78 additions and 79 deletions

View file

@ -38,7 +38,6 @@ module Zammad
'observer::_ticket::_ref_object_touch',
'observer::_ticket::_online_notification_seen',
'observer::_ticket::_stats_reopen',
'observer::_ticket::_escalation_update',
'observer::_tag::_ticket_history',
'observer::_user::_ref_object_touch',
'observer::_user::_ticket_organization',

View file

@ -12,7 +12,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'api-admin',
firstname: 'API',
lastname: 'Admin',
@ -25,7 +25,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'api-agent@example.com',
firstname: 'API',
lastname: 'Agent',
@ -38,7 +38,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer = User.create_or_update(
@customer = User.create!(
login: 'api-customer1@example.com',
firstname: 'API',
lastname: 'Customer1',

View file

@ -12,7 +12,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'api-admin-auth-behalf',
firstname: 'API',
lastname: 'Admin',
@ -25,7 +25,7 @@ class ApiAuthControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer = User.create_or_update(
@customer = User.create!(
login: 'api-customer1-auth-behalf@example.com',
firstname: 'API',
lastname: 'Customer1',

View file

@ -12,7 +12,7 @@ class CalendarControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'calendar-admin',
firstname: 'Packages',
lastname: 'Admin',

View file

@ -14,7 +14,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -27,7 +27,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'rest-agent@example.com',
firstname: 'Rest',
lastname: 'Agent',
@ -40,7 +40,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -51,18 +51,18 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
)
# create orgs
@organization = Organization.create_or_update(
@organization = Organization.create!(
name: 'Rest Org',
)
@organization2 = Organization.create_or_update(
@organization2 = Organization.create!(
name: 'Rest Org #2',
)
@organization3 = Organization.create_or_update(
@organization3 = Organization.create!(
name: 'Rest Org #3',
)
# create customer with org
@customer_with_org = User.create_or_update(
@customer_with_org = User.create!(
login: 'rest-customer2@example.com',
firstname: 'Rest',
lastname: 'Customer2',
@ -229,7 +229,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
end
test '04.01 organization show and response format' do
organization = Organization.create_or_update(
organization = Organization.create!(
name: 'Rest Org NEW',
members: [@customer_without_org],
updated_by_id: @admin.id,
@ -297,7 +297,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
end
test '04.02 organization index and response format' do
organization = Organization.create_or_update(
organization = Organization.create!(
name: 'Rest Org NEW',
members: [@customer_without_org],
updated_by_id: @admin.id,
@ -420,7 +420,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
end
test '04.04 ticket update and response formats' do
organization = Organization.create_or_update(
organization = Organization.create!(
name: 'Rest Org NEW',
members: [@customer_without_org],
updated_by_id: @admin.id,
@ -510,7 +510,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
test '05.03 csv import - admin access' do
UserInfo.current_user_id = 1
customer1 = User.create_or_update(
customer1 = User.create!(
login: 'customer1-members@example.com',
firstname: 'Member',
lastname: 'Customer',
@ -518,7 +518,7 @@ class OrganizationControllerTest < ActionDispatch::IntegrationTest
password: 'customerpw',
active: true,
)
customer2 = User.create_or_update(
customer2 = User.create!(
login: 'customer2-members@example.com',
firstname: 'Member',
lastname: 'Customer',

View file

@ -12,7 +12,7 @@ class OverviewsControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'tickets-admin',
firstname: 'Tickets',
lastname: 'Admin',
@ -25,7 +25,7 @@ class OverviewsControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'tickets-agent@example.com',
firstname: 'Tickets',
lastname: 'Agent',

View file

@ -12,7 +12,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'packages-admin',
firstname: 'Packages',
lastname: 'Admin',
@ -25,7 +25,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'packages-agent@example.com',
firstname: 'Rest',
lastname: 'Agent',
@ -38,7 +38,7 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'packages-customer1@example.com',
firstname: 'Packages',
lastname: 'Customer1',

View file

@ -18,7 +18,7 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -32,7 +32,7 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest
)
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -44,7 +44,7 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest
created_by_id: 1
)
@group1 = Group.create_or_update(
@group1 = Group.create!(
name: "GroupWithoutPermission-#{rand(9_999_999_999)}",
active: true,
updated_by_id: 1,

View file

@ -15,7 +15,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
roles = Role.where(name: %w[Admin Agent])
groups = Group.all
@admin = User.create_or_update(
@admin = User.create!(
login: 'search-admin',
firstname: 'Search',
lastname: 'Admin',
@ -28,7 +28,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'search-agent@example.com',
firstname: 'Search 1234',
lastname: 'Agent',
@ -41,7 +41,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'search-customer1@example.com',
firstname: 'Search',
lastname: 'Customer1',
@ -52,18 +52,18 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
)
# create orgs
@organization = Organization.create_or_update(
@organization = Organization.create!(
name: 'Rest Org',
)
@organization2 = Organization.create_or_update(
@organization2 = Organization.create!(
name: 'Rest Org #2',
)
@organization3 = Organization.create_or_update(
@organization3 = Organization.create!(
name: 'Rest Org #3',
)
# create customer with org
@customer_with_org2 = User.create_or_update(
@customer_with_org2 = User.create!(
login: 'search-customer2@example.com',
firstname: 'Search',
lastname: 'Customer2',
@ -74,7 +74,7 @@ class SearchControllerTest < ActionDispatch::IntegrationTest
organization_id: @organization.id,
)
@customer_with_org3 = User.create_or_update(
@customer_with_org3 = User.create!(
login: 'search-customer3@example.com',
firstname: 'Search',
lastname: 'Customer3',

View file

@ -12,7 +12,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin_full = User.create_or_update(
@admin_full = User.create!(
login: 'setting-admin',
firstname: 'Setting',
lastname: 'Admin',
@ -23,7 +23,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
groups: groups,
)
role_api = Role.create_or_update(
role_api = Role.create!(
name: 'AdminApi',
note: 'To configure your api.',
preferences: {
@ -34,7 +34,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
created_by_id: 1
)
role_api.permission_grant('admin.api')
@admin_api = User.create_or_update(
@admin_api = User.create!(
login: 'setting-admin-api',
firstname: 'Setting',
lastname: 'Admin Api',
@ -47,7 +47,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'setting-agent@example.com',
firstname: 'Setting',
lastname: 'Agent',
@ -60,7 +60,7 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'setting-customer1@example.com',
firstname: 'Setting',
lastname: 'Customer1',

View file

@ -12,7 +12,7 @@ class SlaControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'sla-admin',
firstname: 'Packages',
lastname: 'Admin',

View file

@ -12,7 +12,7 @@ class TaskbarsControllerTest < ActionDispatch::IntegrationTest
roles = Role.where(name: 'Agent')
groups = Group.all
@agent = User.create_or_update(
@agent = User.create!(
login: 'taskbar-agent@example.com',
firstname: 'Taskbar',
lastname: 'Agent',
@ -25,7 +25,7 @@ class TaskbarsControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'taskbar-customer1@example.com',
firstname: 'Taskbar',
lastname: 'Customer1',

View file

@ -14,7 +14,7 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -27,7 +27,7 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'rest-agent@example.com',
firstname: 'Rest',
lastname: 'Agent',
@ -40,7 +40,7 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -51,7 +51,7 @@ class TextModuleControllerTest < ActionDispatch::IntegrationTest
)
# create customer
@customer_with_org = User.create_or_update(
@customer_with_org = User.create!(
login: 'rest-customer2@example.com',
firstname: 'Rest',
lastname: 'Customer2',

View file

@ -9,7 +9,7 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'tickets-admin',
firstname: 'Tickets',
lastname: 'Admin',
@ -22,7 +22,7 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'tickets-agent@example.com',
firstname: 'Tickets',
lastname: 'Agent',
@ -35,7 +35,7 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'tickets-customer1@example.com',
firstname: 'Tickets',
lastname: 'Customer1',

View file

@ -12,7 +12,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'tickets-admin',
firstname: 'Tickets',
lastname: 'Admin',
@ -25,7 +25,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'tickets-agent@example.com',
firstname: 'Tickets',
lastname: 'Agent',
@ -38,7 +38,7 @@ class TicketArticlesControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'tickets-customer1@example.com',
firstname: 'Tickets',
lastname: 'Customer1',

View file

@ -12,7 +12,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
groups = Group.all
UserInfo.current_user_id = 1
@admin = User.create_or_update(
@admin = User.create!(
login: 'tickets-admin',
firstname: 'Tickets',
lastname: 'Admin',
@ -25,7 +25,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'tickets-agent@example.com',
firstname: 'Tickets',
lastname: 'Agent',
@ -38,7 +38,7 @@ class TicketsControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'tickets-customer1@example.com',
firstname: 'Tickets',
lastname: 'Customer1',
@ -719,7 +719,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
end
test '02.03 ticket with wrong ticket id' do
group = Group.create_or_update(
group = Group.create!(
name: "GroupWithoutPermission-#{rand(9_999_999_999)}",
active: true,
updated_by_id: 1,
@ -1952,7 +1952,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
end
test '06.01 - ticket with follow up possible set to new_ticket' do
group = Group.create_or_update(
group = Group.create!(
name: "GroupWithNoFollowUp-#{rand(9_999_999_999)}",
active: true,
updated_by_id: 1,
@ -2024,7 +2024,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
end
test '07.01 ticket merge' do
group_no_permission = Group.create_or_update(
group_no_permission = Group.create!(
name: 'GroupWithNoPermission',
active: true,
updated_by_id: 1,
@ -2089,7 +2089,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
end
test '07.02 ticket merge - change permission' do
group_change_permission = Group.create_or_update(
group_change_permission = Group.create!(
name: 'GroupWithChangePermission',
active: true,
updated_by_id: 1,

View file

@ -15,7 +15,7 @@ class TimeAccountingControllerTest < ActionDispatch::IntegrationTest
@year = DateTime.now.utc.year
@month = DateTime.now.utc.month
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -29,7 +29,7 @@ class TimeAccountingControllerTest < ActionDispatch::IntegrationTest
)
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -43,7 +43,7 @@ class TimeAccountingControllerTest < ActionDispatch::IntegrationTest
end
test '01.01 time account report' do
group = Group.create_or_update(
group = Group.create!(
name: "GroupWithoutPermission-#{rand(9_999_999_999)}",
active: true,
updated_by_id: 1,

View file

@ -14,7 +14,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest
UserInfo.current_user_id = 1
@backup_admin = User.create_or_update(
@backup_admin = User.create!(
login: 'backup-admin',
firstname: 'Backup',
lastname: 'Agent',
@ -25,7 +25,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest
groups: groups,
)
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -38,7 +38,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'rest-agent@example.com',
firstname: 'Rest',
lastname: 'Agent',
@ -51,7 +51,7 @@ class UserControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -62,18 +62,18 @@ class UserControllerTest < ActionDispatch::IntegrationTest
)
# create orgs
@organization = Organization.create_or_update(
@organization = Organization.create!(
name: 'Rest Org',
)
@organization2 = Organization.create_or_update(
@organization2 = Organization.create!(
name: 'Rest Org #2',
)
@organization3 = Organization.create_or_update(
@organization3 = Organization.create!(
name: 'Rest Org #3',
)
# create customer with org
@customer_with_org = User.create_or_update(
@customer_with_org = User.create!(
login: 'rest-customer2@example.com',
firstname: 'Rest',
lastname: 'Customer2',

View file

@ -14,7 +14,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest
UserInfo.current_user_id = 1
@backup_admin = User.create_or_update(
@backup_admin = User.create!(
login: 'backup-admin',
firstname: 'Backup',
lastname: 'Agent',
@ -25,7 +25,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest
groups: groups,
)
@admin = User.create_or_update(
@admin = User.create!(
login: 'rest-admin',
firstname: 'Rest',
lastname: 'Agent',
@ -38,7 +38,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest
# create agent
roles = Role.where(name: 'Agent')
@agent = User.create_or_update(
@agent = User.create!(
login: 'rest-agent@example.com',
firstname: 'Rest',
lastname: 'Agent',
@ -51,7 +51,7 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest
# create customer without org
roles = Role.where(name: 'Customer')
@customer_without_org = User.create_or_update(
@customer_without_org = User.create!(
login: 'rest-customer1@example.com',
firstname: 'Rest',
lastname: 'Customer1',
@ -62,18 +62,18 @@ class UserOrganizationControllerTest < ActionDispatch::IntegrationTest
)
# create orgs
@organization = Organization.create_or_update(
@organization = Organization.create!(
name: 'Rest Org',
)
@organization2 = Organization.create_or_update(
@organization2 = Organization.create!(
name: 'Rest Org #2',
)
@organization3 = Organization.create_or_update(
@organization3 = Organization.create!(
name: 'Rest Org #3',
)
# create customer with org
@customer_with_org = User.create_or_update(
@customer_with_org = User.create!(
login: 'rest-customer2@example.com',
firstname: 'Rest',
lastname: 'Customer2',