Fix EmailAddress dependency issue in Ticket factory
This commit is contained in:
parent
85d6d78eea
commit
9f33ca5c0a
10 changed files with 49 additions and 48 deletions
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
|||
factory :email_address do
|
||||
sequence(:email) { |n| "zammad#{n}@localhost.com" }
|
||||
sequence(:realname) { |n| "zammad#{n}" }
|
||||
channel_id 1
|
||||
channel { create(:email_channel) }
|
||||
created_by_id 1
|
||||
updated_by_id 1
|
||||
end
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
FactoryBot.define do
|
||||
sequence :test_group_name do |n|
|
||||
"TestGroup#{n}"
|
||||
end
|
||||
end
|
||||
|
||||
FactoryBot.define do
|
||||
|
||||
factory :group do
|
||||
name { generate(:test_group_name) }
|
||||
created_by_id 1
|
||||
updated_by_id 1
|
||||
sequence(:name) { |n| "Group #{n}" }
|
||||
email_address
|
||||
created_by_id { 1 }
|
||||
updated_by_id { 1 }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
FactoryBot.define do
|
||||
factory :ticket do
|
||||
title 'Test Ticket'
|
||||
group { Group.lookup(name: 'Users') }
|
||||
customer { FactoryBot.create(:customer_user) }
|
||||
title { 'Test Ticket' }
|
||||
group
|
||||
customer
|
||||
state { Ticket::State.lookup(name: 'new') }
|
||||
priority { Ticket::Priority.lookup(name: '2 normal') }
|
||||
updated_by_id 1
|
||||
created_by_id 1
|
||||
updated_by_id { 1 }
|
||||
created_by_id { 1 }
|
||||
|
||||
factory :twitter_ticket do
|
||||
transient do
|
||||
|
|
|
@ -16,17 +16,17 @@ FactoryBot.define do
|
|||
login_failed 0
|
||||
updated_by_id 1
|
||||
created_by_id 1
|
||||
end
|
||||
|
||||
factory :customer_user, parent: :user do
|
||||
factory :customer_user, aliases: %i[customer] do
|
||||
role_ids { Role.signup_role_ids.sort }
|
||||
end
|
||||
|
||||
factory :agent_user, parent: :user do
|
||||
factory :agent_user, aliases: %i[agent] do
|
||||
roles { Role.where(name: 'Agent') }
|
||||
end
|
||||
|
||||
factory :admin_user, parent: :user do
|
||||
factory :admin_user, aliases: %i[admin] do
|
||||
roles { Role.where(name: %w[Admin Agent]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,6 @@ RSpec.describe Trigger do
|
|||
describe 'sms' do
|
||||
|
||||
it 'sends interpolated, html-free SMS' do
|
||||
customer = create(:customer_user)
|
||||
agent = create(:agent_user)
|
||||
another_agent = create(:admin_user, mobile: '+37061010000')
|
||||
Group.lookup(id: 1).users << another_agent
|
||||
|
@ -20,7 +19,7 @@ RSpec.describe Trigger do
|
|||
}
|
||||
})
|
||||
|
||||
ticket = create(:ticket, customer: customer, created_by_id: agent.id)
|
||||
ticket = create(:ticket, group: Group.lookup(id: 1), created_by_id: agent.id)
|
||||
Observer::Transaction.commit
|
||||
|
||||
triggered_article = Ticket::Article.last
|
||||
|
|
|
@ -2,11 +2,12 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Search', type: :request, searchindex: true do
|
||||
|
||||
let(:group) { create(:group) }
|
||||
let!(:admin_user) do
|
||||
create(:admin_user, groups: Group.all)
|
||||
create(:admin_user, groups: [Group.lookup(name: 'Users'), group])
|
||||
end
|
||||
let!(:agent_user) do
|
||||
create(:agent_user, firstname: 'Search 1234', groups: Group.all)
|
||||
create(:agent_user, firstname: 'Search 1234', groups: [Group.lookup(name: 'Users'), group])
|
||||
end
|
||||
let!(:customer_user) do
|
||||
create(:customer_user)
|
||||
|
@ -33,13 +34,13 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
|||
create(:customer_user, organization: organization1)
|
||||
end
|
||||
let!(:ticket1) do
|
||||
create(:ticket, title: 'test 1234-1', customer: customer_user)
|
||||
create(:ticket, title: 'test 1234-1', customer: customer_user, group: group)
|
||||
end
|
||||
let!(:ticket2) do
|
||||
create(:ticket, title: 'test 1234-2', customer: customer_user2)
|
||||
create(:ticket, title: 'test 1234-2', customer: customer_user2, group: group)
|
||||
end
|
||||
let!(:ticket3) do
|
||||
create(:ticket, title: 'test 1234-2', customer: customer_user3)
|
||||
create(:ticket, title: 'test 1234-2', customer: customer_user3, group: group)
|
||||
end
|
||||
let!(:article1) do
|
||||
create(:ticket_article, ticket_id: ticket1.id)
|
||||
|
|
|
@ -2,14 +2,16 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||
|
||||
let(:group) { create(:group) }
|
||||
|
||||
let(:agent_user) do
|
||||
create(:agent_user, groups: Group.all)
|
||||
create(:agent_user, groups: [Group.lookup(name: 'Users'), group])
|
||||
end
|
||||
|
||||
describe 'request handling' do
|
||||
|
||||
it 'does test attachment urls' do
|
||||
ticket1 = create(:ticket)
|
||||
ticket1 = create(:ticket, group: group)
|
||||
article1 = create(:ticket_article, ticket_id: ticket1.id)
|
||||
|
||||
store1 = Store.add(
|
||||
|
@ -34,7 +36,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
|||
expect(response).to have_http_status(401)
|
||||
expect(@response.body).to match(/401: Unauthorized/)
|
||||
|
||||
ticket2 = create(:ticket)
|
||||
ticket2 = create(:ticket, group: group)
|
||||
ticket1.merge_to(
|
||||
ticket_id: ticket2.id,
|
||||
user_id: 1,
|
||||
|
|
|
@ -5,8 +5,10 @@ RSpec.describe 'Ticket Article', type: :request do
|
|||
let(:admin_user) do
|
||||
create(:admin_user)
|
||||
end
|
||||
let(:group) { create(:group) }
|
||||
|
||||
let(:agent_user) do
|
||||
create(:agent_user, groups: Group.all)
|
||||
create(:agent_user, groups: [Group.lookup(name: 'Users'), group])
|
||||
end
|
||||
let(:customer_user) do
|
||||
create(:customer_user)
|
||||
|
@ -307,7 +309,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
|||
end
|
||||
|
||||
it 'does ticket split with html - check attachments' do
|
||||
ticket = create(:ticket)
|
||||
ticket = create(:ticket, group: group)
|
||||
article = create(
|
||||
:ticket_article,
|
||||
ticket_id: ticket.id,
|
||||
|
@ -401,6 +403,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
|||
it 'does ticket split with plain - check attachments' do
|
||||
ticket = create(
|
||||
:ticket,
|
||||
group: group,
|
||||
updated_by_id: agent_user.id,
|
||||
created_by_id: agent_user.id,
|
||||
)
|
||||
|
|
|
@ -2105,9 +2105,9 @@ RSpec.describe 'Ticket', type: :request do
|
|||
end
|
||||
|
||||
describe 'stats' do
|
||||
let(:ticket1) { create(:ticket, customer: customer, organization: organization) }
|
||||
let(:ticket2) { create(:ticket, customer: customer, organization: organization) }
|
||||
let(:ticket3) { create(:ticket, customer: customer, organization: organization) }
|
||||
let(:ticket1) { create(:ticket, customer: customer, organization: organization, group: ticket_group) }
|
||||
let(:ticket2) { create(:ticket, customer: customer, organization: organization, group: ticket_group) }
|
||||
let(:ticket3) { create(:ticket, customer: customer, organization: organization, group: ticket_group) }
|
||||
let(:customer) { create(:customer_user, organization: organization) }
|
||||
let(:organization) { create(:organization, shared: false) }
|
||||
|
||||
|
|
|
@ -4,25 +4,27 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
context 'when applying ticket templates' do
|
||||
# Regression test for issue #2424 - Unavailable ticket template attributes get applied
|
||||
scenario 'unavailable attributes do not get applied', authenticated: false do
|
||||
# create a new agent with permissions for only group "some group1"
|
||||
user = create :agent_user
|
||||
user = create(:agent_user)
|
||||
permitted_group = create(:group)
|
||||
unpermitted_group = create(:group)
|
||||
|
||||
user.group_names_access_map = {
|
||||
'some group1' => 'full',
|
||||
permitted_group.name => 'full',
|
||||
}
|
||||
|
||||
# create a template that sets the group to Users and ticket owner to user id 1
|
||||
template = create :template, options: {
|
||||
'title' => 'Template Title',
|
||||
'group_id' => '1',
|
||||
'group_id' => unpermitted_group.id,
|
||||
'owner_id' => '2',
|
||||
}
|
||||
|
||||
# apply the ticket template and confirm that the group_id dropdown does not appear
|
||||
login(
|
||||
username: user.email,
|
||||
password: 'test',
|
||||
)
|
||||
visit 'ticket/create'
|
||||
|
||||
# apply the ticket template and confirm that the group_id dropdown does not appear
|
||||
find('#form-template select[name="id"]').find(:option, template.name).select_option
|
||||
click '.sidebar-content .js-apply'
|
||||
expect(page).not_to have_selector 'select[name="group_id"]'
|
||||
|
|
Loading…
Reference in a new issue