Fixes #2671 - Pending till can be changed by customer via web interface

This commit is contained in:
Mantas 2020-11-18 17:40:09 +02:00 committed by Thorsten Eckel
parent cb111a15df
commit aaa30b2b90
5 changed files with 48 additions and 16 deletions

View file

@ -323,22 +323,8 @@ RSpec/ExpectInHook:
RSpec/FilePath:
Exclude:
- 'spec/db/migrate/20171023000001_fixed_store_upgrade_ror_45_spec.rb'
- 'spec/db/migrate/issue_1219_zhtw_locale_typo_spec.rb'
- 'spec/db/migrate/issue_1660_fix_tree_select_configurations_spec.rb'
- 'spec/db/migrate/issue_1905_exchange_login_from_remote_id_spec.rb'
- 'spec/db/migrate/issue_1977_remove_invalid_user_foreign_keys_spec.rb'
- 'spec/db/migrate/issue_2019_fix_double_domain_links_in_trigger_emails_spec.rb'
- 'spec/db/migrate/issue_2140_reset_ldap_config_spec.rb'
- 'spec/db/migrate/issue_2333_object_country_already_exists_spec.rb'
- 'spec/db/migrate/issue_2345_es_attachment_max_size_in_mb_setting_lower_default_spec.rb'
- 'spec/db/migrate/issue_2368_add_indices_to_histories_and_tickets_spec.rb'
- 'spec/db/migrate/issue_2541_fix_notification_email_without_body_spec.rb'
- 'spec/db/migrate/issue_2608_missing_trigger_permission_spec.rb'
- 'spec/db/migrate/issue_2460_fix_corrupted_twitter_ids_spec.rb'
- 'spec/db/migrate/issue_2715_fix_broken_twitter_urls_spec.rb'
- 'spec/db/migrate/issue_2943_add_setting_enforce_special_character_spec.rb'
- 'spec/jobs/issue_2715_fix_broken_twitter_urls_job_spec.rb'
- 'spec/db/migrate/issue_2867_footer_header_public_link_spec.rb'
- 'spec/db/migrate/issue_*_spec.rb'
- 'spec/jobs/issue_*_spec.rb'
- 'spec/lib/import/base_factory_spec.rb'
RSpec/InstanceVariable:

View file

@ -0,0 +1,10 @@
class Issue2671PendingTillCanBeChangedByCustomer < ActiveRecord::Migration[5.2]
def up
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
attr = ObjectManager::Attribute.find_by name: :pending_time
attr.data_option[:permission] = %w[ticket.agent]
attr.save!
end
end

View file

@ -239,6 +239,7 @@ ObjectManager::Attribute.add(
shown_if: {
state_id: Ticket::State.by_category(:pending).pluck(:id),
},
permission: %w[ticket.agent],
},
editable: false,
active: true,

View file

@ -0,0 +1,20 @@
require 'rails_helper'
RSpec.describe Issue2671PendingTillCanBeChangedByCustomer, type: :db_migration do
let(:attr) { ObjectManager::Attribute.find_by name: :pending_time }
let(:initial_data_option) { { future: true, past: true, diff: 0 } }
before do
attr.update!(data_option: initial_data_option)
end
it 'adds permission' do
migrate
expect(attr.reload.data_option).to include(permission: %w[ticket.agent])
end
it 'keeps other settings' do
migrate
expect(attr.reload.data_option).to include(initial_data_option)
end
end

View file

@ -1250,4 +1250,19 @@ RSpec.describe 'Ticket zoom', type: :system do
end
end
end
# https://github.com/zammad/zammad/issues/2671
describe 'Pending time field in ticket sidebar', authenticated_as: :customer do
let(:customer) { create(:customer) }
let(:ticket) { create(:ticket, customer: customer, pending_time: 1.day.from_now, state: Ticket::State.lookup(name: 'pending reminder')) }
it 'not shown to customer' do
visit "ticket/zoom/#{ticket.id}"
await_empty_ajax_queue
within :active_content do
expect(page).to have_no_css('.controls[data-name=pending_time]')
end
end
end
end