From aaa30b2b904466f8b73b5ac9d5a36a640dbf2bc6 Mon Sep 17 00:00:00 2001 From: Mantas Date: Wed, 18 Nov 2020 17:40:09 +0200 Subject: [PATCH] Fixes #2671 - Pending till can be changed by customer via web interface --- .rubocop/todo.rspec.yml | 18 ++--------------- ...pending_till_can_be_changed_by_customer.rb | 10 ++++++++++ db/seeds/object_manager_attributes.rb | 1 + ...ng_till_can_be_changed_by_customer_spec.rb | 20 +++++++++++++++++++ spec/system/ticket/zoom_spec.rb | 15 ++++++++++++++ 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20201118140850_issue_2671_pending_till_can_be_changed_by_customer.rb create mode 100644 spec/db/migrate/issue_2671_pending_till_can_be_changed_by_customer_spec.rb diff --git a/.rubocop/todo.rspec.yml b/.rubocop/todo.rspec.yml index f166d9c95..d100a4aab 100644 --- a/.rubocop/todo.rspec.yml +++ b/.rubocop/todo.rspec.yml @@ -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: diff --git a/db/migrate/20201118140850_issue_2671_pending_till_can_be_changed_by_customer.rb b/db/migrate/20201118140850_issue_2671_pending_till_can_be_changed_by_customer.rb new file mode 100644 index 000000000..3a058ef03 --- /dev/null +++ b/db/migrate/20201118140850_issue_2671_pending_till_can_be_changed_by_customer.rb @@ -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 diff --git a/db/seeds/object_manager_attributes.rb b/db/seeds/object_manager_attributes.rb index 8eee44333..354e1caa9 100644 --- a/db/seeds/object_manager_attributes.rb +++ b/db/seeds/object_manager_attributes.rb @@ -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, diff --git a/spec/db/migrate/issue_2671_pending_till_can_be_changed_by_customer_spec.rb b/spec/db/migrate/issue_2671_pending_till_can_be_changed_by_customer_spec.rb new file mode 100644 index 000000000..f5d1f9c72 --- /dev/null +++ b/spec/db/migrate/issue_2671_pending_till_can_be_changed_by_customer_spec.rb @@ -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 diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb index d36072304..ae7c297a3 100644 --- a/spec/system/ticket/zoom_spec.rb +++ b/spec/system/ticket/zoom_spec.rb @@ -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