Fix auto-correctable rubocop offenses in test suite
This commit is contained in:
parent
e907c13cbe
commit
2ac28bf906
119 changed files with 1406 additions and 1532 deletions
|
@ -6,41 +6,6 @@
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
# Offense count: 36
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnabledMethods.
|
|
||||||
Capybara/FeatureMethods:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/system/basic/authentication_spec.rb'
|
|
||||||
- 'spec/system/basic/redirects_spec.rb'
|
|
||||||
- 'spec/system/basic/richtext_spec.rb'
|
|
||||||
- 'spec/system/js/q_unit_spec.rb'
|
|
||||||
- 'spec/system/setup/auto_wizard_spec.rb'
|
|
||||||
- 'spec/system/setup/mail_accounts_spec.rb'
|
|
||||||
- 'spec/system/setup/system_spec.rb'
|
|
||||||
- 'spec/system/ticket/create_spec.rb'
|
|
||||||
- 'spec/system/ticket/update_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 39
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
|
||||||
Layout/ExtraSpacing:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/factories/job.rb'
|
|
||||||
- 'spec/factories/postmaster_filter.rb'
|
|
||||||
- 'spec/factories/ticket.rb'
|
|
||||||
- 'spec/factories/ticket/article.rb'
|
|
||||||
- 'spec/lib/sequencer/unit/import/zendesk/sub_sequence/base_examples.rb'
|
|
||||||
- 'spec/models/calendar_spec.rb'
|
|
||||||
- 'spec/models/channel/email_parser_spec.rb'
|
|
||||||
- 'spec/models/cti/caller_id_spec.rb'
|
|
||||||
- 'spec/models/job_spec.rb'
|
|
||||||
- 'spec/models/recent_view_spec.rb'
|
|
||||||
- 'spec/models/role_spec.rb'
|
|
||||||
- 'spec/models/ticket_spec.rb'
|
|
||||||
- 'spec/models/trigger_spec.rb'
|
|
||||||
- 'spec/requests/ticket_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 43
|
# Offense count: 43
|
||||||
Lint/UselessAssignment:
|
Lint/UselessAssignment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -53,7 +18,7 @@ Lint/UselessAssignment:
|
||||||
# Configuration parameters: CountComments, ExcludedMethods.
|
# Configuration parameters: CountComments, ExcludedMethods.
|
||||||
# ExcludedMethods: refine
|
# ExcludedMethods: refine
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Max: 1969
|
Max: 1987
|
||||||
|
|
||||||
# Offense count: 16
|
# Offense count: 16
|
||||||
RSpec/AnyInstance:
|
RSpec/AnyInstance:
|
||||||
|
@ -84,48 +49,6 @@ RSpec/BeforeAfterAll:
|
||||||
RSpec/ContextWording:
|
RSpec/ContextWording:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
RSpec/DescribeClass:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/scripts/websocket_server_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 207
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
|
||||||
# SupportedStyles: described_class, explicit
|
|
||||||
RSpec/DescribedClass:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 15
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/EmptyLineAfterFinalLet:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/db/migrate/issue_1905_exchange_login_from_remote_id_spec.rb'
|
|
||||||
- 'spec/db/migrate/issue_2541_fix_notification_email_without_body_spec.rb'
|
|
||||||
- 'spec/lib/import/zendesk/object_attribute/base_examples.rb'
|
|
||||||
- 'spec/models/cti/log_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation/future_past_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation/required_spec.rb'
|
|
||||||
- 'spec/models/ticket_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
- 'spec/requests/integration/twitter_webhook_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 25
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/EmptyLineAfterHook:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/lib/notification_factory/slack_spec.rb'
|
|
||||||
- 'spec/lib/notification_factory_spec.rb'
|
|
||||||
- 'spec/models/role_spec.rb'
|
|
||||||
- 'spec/models/ticket_spec.rb'
|
|
||||||
- 'spec/models/trigger_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 34
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/EmptyLineAfterSubject:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 540
|
# Offense count: 540
|
||||||
# Configuration parameters: Max.
|
# Configuration parameters: Max.
|
||||||
RSpec/ExampleLength:
|
RSpec/ExampleLength:
|
||||||
|
@ -144,13 +67,6 @@ RSpec/ExpectActual:
|
||||||
- 'spec/requests/user/organization_spec.rb'
|
- 'spec/requests/user/organization_spec.rb'
|
||||||
- 'spec/requests/user_spec.rb'
|
- 'spec/requests/user_spec.rb'
|
||||||
|
|
||||||
# Offense count: 99
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: method_call, block
|
|
||||||
RSpec/ExpectChange:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 3
|
||||||
RSpec/ExpectInHook:
|
RSpec/ExpectInHook:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
@ -175,20 +91,6 @@ RSpec/FilePath:
|
||||||
- 'spec/db/migrate/issue_2541_fix_notification_email_without_body_spec.rb'
|
- 'spec/db/migrate/issue_2541_fix_notification_email_without_body_spec.rb'
|
||||||
- 'spec/lib/import/base_factory_spec.rb'
|
- 'spec/lib/import/base_factory_spec.rb'
|
||||||
|
|
||||||
# Offense count: 30
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: implicit, each, example
|
|
||||||
RSpec/HookArgument:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/HooksBeforeExamples:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/models/concerns/has_groups_examples.rb'
|
|
||||||
- 'spec/models/trigger_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 60
|
# Offense count: 60
|
||||||
# Configuration parameters: AssignmentOnly.
|
# Configuration parameters: AssignmentOnly.
|
||||||
RSpec/InstanceVariable:
|
RSpec/InstanceVariable:
|
||||||
|
@ -205,36 +107,6 @@ RSpec/InstanceVariable:
|
||||||
- 'spec/requests/ticket/article_attachments_spec.rb'
|
- 'spec/requests/ticket/article_attachments_spec.rb'
|
||||||
- 'spec/requests/user_spec.rb'
|
- 'spec/requests/user_spec.rb'
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
RSpec/IteratedExpectation:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/jobs/update_cti_logs_by_caller_job_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 10
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/LeadingSubject:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/lib/notification_factory/slack_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation/backend_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation/future_past_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation/required_spec.rb'
|
|
||||||
- 'spec/models/role_spec.rb'
|
|
||||||
- 'spec/models/ticket/article_spec.rb'
|
|
||||||
- 'spec/models/trigger_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 15
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
RSpec/LetBeforeExamples:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/lib/import/otrs/article/attachment_factory_spec.rb'
|
|
||||||
- 'spec/lib/import/otrs/dynamic_field_factory_spec.rb'
|
|
||||||
- 'spec/lib/import/otrs/dynamic_field_spec.rb'
|
|
||||||
- 'spec/lib/ldap/group_spec.rb'
|
|
||||||
- 'spec/lib/ldap/user_spec.rb'
|
|
||||||
- 'spec/lib/ldap_spec.rb'
|
|
||||||
- 'spec/models/user_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 34
|
# Offense count: 34
|
||||||
RSpec/LetSetup:
|
RSpec/LetSetup:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -274,40 +146,6 @@ RSpec/NamedSubject:
|
||||||
RSpec/NestedGroups:
|
RSpec/NestedGroups:
|
||||||
Max: 8
|
Max: 8
|
||||||
|
|
||||||
# Offense count: 28
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: not_to, to_not
|
|
||||||
RSpec/NotToNot:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/db/migrate/object_manager_attribute_date_remove_future_past_spec.rb'
|
|
||||||
- 'spec/lib/import/otrs/user_factory_spec.rb'
|
|
||||||
- 'spec/lib/migration_job/ldap_samaccountname_to_uid_spec.rb'
|
|
||||||
- 'spec/lib/report/ticket_generic_time_spec.rb'
|
|
||||||
- 'spec/lib/stats_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute/validation_spec.rb'
|
|
||||||
- 'spec/models/object_manager/attribute_spec.rb'
|
|
||||||
- 'spec/requests/integration/idoit_spec.rb'
|
|
||||||
- 'spec/requests/integration/twilio_sms_spec.rb'
|
|
||||||
- 'spec/requests/integration/user_device_spec.rb'
|
|
||||||
- 'spec/requests/search_spec.rb'
|
|
||||||
- 'spec/requests/text_module_spec.rb'
|
|
||||||
- 'spec/requests/ticket/article_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 81
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: Strict, EnforcedStyle.
|
|
||||||
# SupportedStyles: inflected, explicit
|
|
||||||
RSpec/PredicateMatcher:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/lib/password_hash_spec.rb'
|
|
||||||
- 'spec/models/trigger/sms_spec.rb'
|
|
||||||
- 'spec/requests/api_auth_on_behalf_of_spec.rb'
|
|
||||||
- 'spec/requests/api_auth_spec.rb'
|
|
||||||
- 'spec/requests/integration/monitoring_spec.rb'
|
|
||||||
- 'spec/requests/organization_spec.rb'
|
|
||||||
- 'spec/requests/user_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 12
|
# Offense count: 12
|
||||||
RSpec/RepeatedDescription:
|
RSpec/RepeatedDescription:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
@ -315,11 +153,6 @@ RSpec/RepeatedDescription:
|
||||||
- 'spec/requests/form_spec.rb'
|
- 'spec/requests/form_spec.rb'
|
||||||
- 'spec/requests/ticket_spec.rb'
|
- 'spec/requests/ticket_spec.rb'
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
RSpec/RepeatedExample:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/models/translation_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 3
|
||||||
RSpec/ScatteredLet:
|
RSpec/ScatteredLet:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
@ -347,16 +180,3 @@ RSpec/SubjectStub:
|
||||||
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
||||||
RSpec/VerifiedDoubles:
|
RSpec/VerifiedDoubles:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
RSpec/VoidExpect:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/lib/ldap/group_spec.rb'
|
|
||||||
- 'spec/lib/ldap/user_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 741
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle.
|
|
||||||
# SupportedStyles: numeric, symbolic
|
|
||||||
Rails/HttpStatus:
|
|
||||||
Enabled: false
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Issue1219ZhtwLocaleTypo, type: :db_migration do
|
||||||
let(:translation) { create(:translation, locale: premigrate_locale) }
|
let(:translation) { create(:translation, locale: premigrate_locale) }
|
||||||
let(:user) { create(:user, preferences: { locale: premigrate_locale }) }
|
let(:user) { create(:user, preferences: { locale: premigrate_locale }) }
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Locale.find_by(name: 'Chinese (Tradi.) (正體中文)')&.destroy
|
Locale.find_by(name: 'Chinese (Tradi.) (正體中文)')&.destroy
|
||||||
stub_const("#{described_class}::CURRENT_VERSION", version)
|
stub_const("#{described_class}::CURRENT_VERSION", version)
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,7 @@ RSpec.describe Issue1905ExchangeLoginFromRemoteId, type: :db_migration do
|
||||||
|
|
||||||
context 'blank config' do
|
context 'blank config' do
|
||||||
let(:config) { nil }
|
let(:config) { nil }
|
||||||
|
|
||||||
it_behaves_like 'irrelevant config'
|
it_behaves_like 'irrelevant config'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ RSpec.describe Issue1905ExchangeLoginFromRemoteId, type: :db_migration do
|
||||||
some: 'config'
|
some: 'config'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'irrelevant config'
|
it_behaves_like 'irrelevant config'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,6 +66,7 @@ RSpec.describe Issue1905ExchangeLoginFromRemoteId, type: :db_migration do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'irrelevant config'
|
it_behaves_like 'irrelevant config'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,6 +79,7 @@ RSpec.describe Issue1905ExchangeLoginFromRemoteId, type: :db_migration do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'irrelevant config'
|
it_behaves_like 'irrelevant config'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,9 +16,7 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
migrate
|
migrate
|
||||||
end.to change {
|
end.to change(OnlineNotification, :count).by(-1)
|
||||||
OnlineNotification.count
|
|
||||||
}.by(-1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cleans up RecentView#created_by_id', db_strategy: :reset do
|
it 'cleans up RecentView#created_by_id', db_strategy: :reset do
|
||||||
|
@ -30,9 +28,7 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
migrate
|
migrate
|
||||||
end.to change {
|
end.to change(RecentView, :count).by(-1)
|
||||||
RecentView.count
|
|
||||||
}.by(-1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cleans up Avatar#o_id', db_strategy: :reset do
|
it 'cleans up Avatar#o_id', db_strategy: :reset do
|
||||||
|
@ -44,9 +40,7 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
migrate
|
migrate
|
||||||
end.to change {
|
end.to change(Avatar, :count).by(-1)
|
||||||
Avatar.count
|
|
||||||
}.by(-1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AddCountryAttributeToUsers, type: :db_migration do
|
RSpec.describe AddCountryAttributeToUsers, type: :db_migration do
|
||||||
|
|
||||||
context 'AddCountryAttributeToUsers migration' do
|
context 'AddCountryAttributeToUsers migration' do
|
||||||
|
|
||||||
def country_attribute
|
|
||||||
ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'preserves the existing country attribute' do
|
it 'preserves the existing country attribute' do
|
||||||
expect { migrate }
|
expect { migrate }
|
||||||
.not_to(change { country_attribute.present? })
|
.not_to change { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when country attribute is not present' do
|
||||||
|
before { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country').delete }
|
||||||
|
|
||||||
it 'adds the country attribute when it is not present' do
|
it 'adds the country attribute when it is not present' do
|
||||||
country_attribute.delete
|
|
||||||
expect { migrate }
|
expect { migrate }
|
||||||
.to change { country_attribute.present? }
|
.to change { ObjectManager::Attribute.exists?(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
|
||||||
.from(false).to(true)
|
.from(false).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -38,6 +38,7 @@ RSpec.describe Issue2541FixNotificationEmailWithoutBody, type: :db_migration do
|
||||||
|
|
||||||
context 'when migrating Jobs' do
|
context 'when migrating Jobs' do
|
||||||
subject(:job) { create(:job) }
|
subject(:job) { create(:job) }
|
||||||
|
|
||||||
let(:type) { 'notification.email' }
|
let(:type) { 'notification.email' }
|
||||||
|
|
||||||
it "updates empty perform['notification.email']['body'] attribute" do
|
it "updates empty perform['notification.email']['body'] attribute" do
|
||||||
|
@ -48,6 +49,7 @@ RSpec.describe Issue2541FixNotificationEmailWithoutBody, type: :db_migration do
|
||||||
|
|
||||||
describe 'scheduler management' do
|
describe 'scheduler management' do
|
||||||
let(:scheduler) { Scheduler.find_by(method: 'Job.run') }
|
let(:scheduler) { Scheduler.find_by(method: 'Job.run') }
|
||||||
|
|
||||||
before { scheduler.update!(active: false) }
|
before { scheduler.update!(active: false) }
|
||||||
|
|
||||||
it "re-enables 'Job.run' Scheduler" do
|
it "re-enables 'Job.run' Scheduler" do
|
||||||
|
|
|
@ -19,7 +19,7 @@ RSpec.describe ObjectManagerAttributeDateRemoveFuturePast, type: :db_migration d
|
||||||
|
|
||||||
migrate
|
migrate
|
||||||
|
|
||||||
expect(subject.data_option).to_not include(:past, :future)
|
expect(subject.data_option).not_to include(:past, :future)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when incomplete data_option is given' do
|
context 'when incomplete data_option is given' do
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe UpdateCtiLogsByCallerJob, type: :job do
|
||||||
it 'updates Cti::Logs from that number with "preferences" => {}' do
|
it 'updates Cti::Logs from that number with "preferences" => {}' do
|
||||||
described_class.perform_now(phone)
|
described_class.perform_now(phone)
|
||||||
|
|
||||||
log_prefs.each { |p| expect(p).to be_empty }
|
expect(log_prefs).to all(be_empty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ RSpec.describe UpdateCtiLogsByCallerJob, type: :job do
|
||||||
it 'updates Cti::Logs from that number with valid "preferences" hash' do
|
it 'updates Cti::Logs from that number with valid "preferences" hash' do
|
||||||
described_class.perform_now(phone)
|
described_class.perform_now(phone)
|
||||||
|
|
||||||
log_prefs.each { |p| expect(p).to include('from' => a_kind_of(Array)) }
|
expect(log_prefs).to all(include('from' => a_kind_of(Array)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,30 +3,30 @@ require 'rails_helper'
|
||||||
RSpec.describe ApplicationHandleInfo do
|
RSpec.describe ApplicationHandleInfo do
|
||||||
describe '.use' do
|
describe '.use' do
|
||||||
it 'requires a block' do
|
it 'requires a block' do
|
||||||
expect { ApplicationHandleInfo.use('foo') }
|
expect { described_class.use('foo') }
|
||||||
.to raise_error(ArgumentError)
|
.to raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for a given starting ApplicationHandleInfo' do
|
context 'for a given starting ApplicationHandleInfo' do
|
||||||
before { ApplicationHandleInfo.current = 'foo' }
|
before { described_class.current = 'foo' }
|
||||||
|
|
||||||
it 'runs the block using the given ApplicationHandleInfo' do
|
it 'runs the block using the given ApplicationHandleInfo' do
|
||||||
ApplicationHandleInfo.use('bar') do
|
described_class.use('bar') do
|
||||||
expect(ApplicationHandleInfo.current).to eq('bar')
|
expect(described_class.current).to eq('bar')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'resets ApplicationHandleInfo to its original value' do
|
it 'resets ApplicationHandleInfo to its original value' do
|
||||||
ApplicationHandleInfo.use('bar') {}
|
described_class.use('bar') {}
|
||||||
|
|
||||||
expect(ApplicationHandleInfo.current).to eq('foo')
|
expect(described_class.current).to eq('foo')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an error is raised in the given block' do
|
context 'when an error is raised in the given block' do
|
||||||
it 'does not rescue the error, and still resets ApplicationHandleInfo' do
|
it 'does not rescue the error, and still resets ApplicationHandleInfo' do
|
||||||
expect { ApplicationHandleInfo.use('bar') { raise } }
|
expect { described_class.use('bar') { raise } }
|
||||||
.to raise_error(StandardError)
|
.to raise_error(StandardError)
|
||||||
.and not_change { ApplicationHandleInfo.current }
|
.and not_change { described_class.current }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,14 @@ RSpec.describe Cache do
|
||||||
before { allow(Rails.cache).to receive(:read) }
|
before { allow(Rails.cache).to receive(:read) }
|
||||||
|
|
||||||
it 'wraps Rails.cache.read' do
|
it 'wraps Rails.cache.read' do
|
||||||
Cache.get('foo')
|
described_class.get('foo')
|
||||||
|
|
||||||
expect(Rails.cache).to have_received(:read).with('foo')
|
expect(Rails.cache).to have_received(:read).with('foo')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a non-string argument' do
|
context 'with a non-string argument' do
|
||||||
it 'passes a string' do
|
it 'passes a string' do
|
||||||
Cache.get(:foo)
|
described_class.get(:foo)
|
||||||
|
|
||||||
expect(Rails.cache).to have_received(:read).with('foo')
|
expect(Rails.cache).to have_received(:read).with('foo')
|
||||||
end
|
end
|
||||||
|
@ -21,25 +21,25 @@ RSpec.describe Cache do
|
||||||
|
|
||||||
describe '.write' do
|
describe '.write' do
|
||||||
it 'stores string values' do
|
it 'stores string values' do
|
||||||
expect { Cache.write('123', 'some value') }
|
expect { described_class.write('123', 'some value') }
|
||||||
.to change { Cache.get('123') }.to('some value')
|
.to change { described_class.get('123') }.to('some value')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'stores hash values' do
|
it 'stores hash values' do
|
||||||
expect { Cache.write('123', { key: 'some value' }) }
|
expect { described_class.write('123', { key: 'some value' }) }
|
||||||
.to change { Cache.get('123') }.to({ key: 'some value' })
|
.to change { described_class.get('123') }.to({ key: 'some value' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overwrites previous values' do
|
it 'overwrites previous values' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
|
|
||||||
expect { Cache.write('123', { key: 'some value' }) }
|
expect { described_class.write('123', { key: 'some value' }) }
|
||||||
.to change { Cache.get('123') }.to({ key: 'some value' })
|
.to change { described_class.get('123') }.to({ key: 'some value' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'stores hash values with non-ASCII content' do
|
it 'stores hash values with non-ASCII content' do
|
||||||
expect { Cache.write('123', { key: 'some valueöäüß' }) }
|
expect { described_class.write('123', { key: 'some valueöäüß' }) }
|
||||||
.to change { Cache.get('123') }.to({ key: 'some valueöäüß' })
|
.to change { described_class.get('123') }.to({ key: 'some valueöäüß' })
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when expiring' do
|
context 'when expiring' do
|
||||||
|
@ -51,58 +51,58 @@ RSpec.describe Cache do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'defaults to expires_in: 7.days' do
|
it 'defaults to expires_in: 7.days' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
|
|
||||||
expect { travel 7.days - 1.second }.not_to change { Cache.get('123') }
|
expect { travel 7.days - 1.second }.not_to change { described_class.get('123') }
|
||||||
expect { travel 2.seconds }.to change { Cache.get('123') }.to(nil)
|
expect { travel 2.seconds }.to change { described_class.get('123') }.to(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts a custom :expires_in option' do
|
it 'accepts a custom :expires_in option' do
|
||||||
Cache.write('123', 'some value', expires_in: 3.seconds)
|
described_class.write('123', 'some value', expires_in: 3.seconds)
|
||||||
|
|
||||||
expect { travel 4.seconds }.to change { Cache.get('123') }.to(nil)
|
expect { travel 4.seconds }.to change { described_class.get('123') }.to(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.delete' do
|
describe '.delete' do
|
||||||
it 'deletes stored values' do
|
it 'deletes stored values' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
|
|
||||||
expect { Cache.delete('123') }
|
expect { described_class.delete('123') }
|
||||||
.to change { Cache.get('123') }.to(nil)
|
.to change { described_class.get('123') }.to(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is idempotent' do
|
it 'is idempotent' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
Cache.delete('123')
|
described_class.delete('123')
|
||||||
|
|
||||||
expect { Cache.delete('123') }.not_to raise_error
|
expect { described_class.delete('123') }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.clear' do
|
describe '.clear' do
|
||||||
it 'deletes all stored values' do
|
it 'deletes all stored values' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
Cache.write('456', 'some value')
|
described_class.write('456', 'some value')
|
||||||
|
|
||||||
expect { Cache.clear }
|
expect { described_class.clear }
|
||||||
.to change { Cache.get('123') }.to(nil)
|
.to change { described_class.get('123') }.to(nil)
|
||||||
.and change { Cache.get('456') }.to(nil)
|
.and change { described_class.get('456') }.to(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is idempotent' do
|
it 'is idempotent' do
|
||||||
Cache.write('123', 'some value')
|
described_class.write('123', 'some value')
|
||||||
Cache.clear
|
described_class.clear
|
||||||
|
|
||||||
expect { Cache.clear }.not_to raise_error
|
expect { described_class.clear }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when cache directory is not present on disk' do
|
context 'when cache directory is not present on disk' do
|
||||||
before { FileUtils.rm_rf(Rails.cache.cache_path) }
|
before { FileUtils.rm_rf(Rails.cache.cache_path) }
|
||||||
|
|
||||||
it 'does not raise an error' do
|
it 'does not raise an error' do
|
||||||
expect { Cache.clear }.not_to raise_error
|
expect { described_class.clear }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,8 +25,8 @@ RSpec.describe String do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not break on non-unicode strings' do
|
it 'does not break on non-unicode strings' do
|
||||||
expect(String.new("\xC2\xA92011 Z ", encoding: 'ASCII-8BIT').strip)
|
expect(described_class.new("\xC2\xA92011 Z ", encoding: 'ASCII-8BIT').strip)
|
||||||
.to eq(String.new("\xC2\xA92011 Z", encoding: 'ASCII-8BIT'))
|
.to eq(described_class.new("\xC2\xA92011 Z", encoding: 'ASCII-8BIT'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,9 +56,9 @@ RSpec.describe String do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not break on invalid-unicode strings (in place)' do
|
it 'does not break on invalid-unicode strings (in place)' do
|
||||||
str = String.new("\xC2\xA92011 Z ", encoding: 'ASCII-8BIT')
|
str = described_class.new("\xC2\xA92011 Z ", encoding: 'ASCII-8BIT')
|
||||||
expect(str.strip!)
|
expect(str.strip!)
|
||||||
.to be(str).and eq(String.new("\xC2\xA92011 Z", encoding: 'ASCII-8BIT'))
|
.to be(str).and eq(described_class.new("\xC2\xA92011 Z", encoding: 'ASCII-8BIT'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1844,7 +1844,7 @@ RSpec.describe String do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'which are incorrectly set to other, technically valid encodings' do
|
context 'which are incorrectly set to other, technically valid encodings' do
|
||||||
let(:subject) { String.new('ö', encoding: 'tis-620') }
|
let(:subject) { described_class.new('ö', encoding: 'tis-620') }
|
||||||
|
|
||||||
it 'sets input encoding to UTF-8 instead of attempting conversion' do
|
it 'sets input encoding to UTF-8 instead of attempting conversion' do
|
||||||
expect(subject.utf8_encode).to eq(subject.dup.force_encoding('utf-8'))
|
expect(subject.utf8_encode).to eq(subject.dup.force_encoding('utf-8'))
|
||||||
|
|
|
@ -4,8 +4,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe HtmlSanitizer do
|
RSpec.describe HtmlSanitizer do
|
||||||
describe '.replace_inline_images' do
|
describe '.replace_inline_images' do
|
||||||
let(:body) { HtmlSanitizer.replace_inline_images(html).first }
|
let(:body) { described_class.replace_inline_images(html).first }
|
||||||
let(:inline_attachments) { HtmlSanitizer.replace_inline_images(html).last }
|
let(:inline_attachments) { described_class.replace_inline_images(html).last }
|
||||||
|
|
||||||
context 'for image at absolute path' do
|
context 'for image at absolute path' do
|
||||||
let(:html) { '<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">' }
|
let(:html) { '<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">' }
|
||||||
|
@ -142,7 +142,7 @@ RSpec.describe HtmlSanitizer do
|
||||||
context 'for image at absolute path' do
|
context 'for image at absolute path' do
|
||||||
context 'with src attr last' do
|
context 'with src attr last' do
|
||||||
it 'add max-width: 100% rule to style attr' do
|
it 'add max-width: 100% rule to style attr' do
|
||||||
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
||||||
<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">
|
<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">
|
||||||
HTML
|
HTML
|
||||||
<img style="max-width:100%;width: 181px;max-height: 125px;" src="data:image.+?">
|
<img style="max-width:100%;width: 181px;max-height: 125px;" src="data:image.+?">
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe HtmlSanitizer do
|
||||||
|
|
||||||
context 'with src attr first' do
|
context 'with src attr first' do
|
||||||
it 'add max-width: 100% rule to style attr' do
|
it 'add max-width: 100% rule to style attr' do
|
||||||
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
||||||
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc">
|
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc">
|
||||||
HTML
|
HTML
|
||||||
<img src="data:image.+?" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">
|
<img src="data:image.+?" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">
|
||||||
|
@ -164,7 +164,7 @@ RSpec.describe HtmlSanitizer do
|
||||||
context 'for base64-encoded inline images' do
|
context 'for base64-encoded inline images' do
|
||||||
context 'with src attr last' do
|
context 'with src attr last' do
|
||||||
it 'add max-width: 100% rule to style attr' do
|
it 'add max-width: 100% rule to style attr' do
|
||||||
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
||||||
<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">
|
<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">
|
||||||
HTML
|
HTML
|
||||||
<img src="/some_one.png" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">
|
<img src="/some_one.png" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">
|
||||||
|
@ -174,7 +174,7 @@ RSpec.describe HtmlSanitizer do
|
||||||
|
|
||||||
context 'with src attr first' do
|
context 'with src attr first' do
|
||||||
it 'add max-width: 100% rule to style attr' do
|
it 'add max-width: 100% rule to style attr' do
|
||||||
expect(HtmlSanitizer.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
|
||||||
<img src="/some_one.png" alt="abc">
|
<img src="/some_one.png" alt="abc">
|
||||||
HTML
|
HTML
|
||||||
<img src="/some_one.png" alt="abc" style="max-width:100%;">
|
<img src="/some_one.png" alt="abc" style="max-width:100%;">
|
||||||
|
@ -190,14 +190,14 @@ RSpec.describe HtmlSanitizer do
|
||||||
before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) }
|
before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) }
|
||||||
|
|
||||||
it 'returns a timeout error message for the user' do
|
it 'returns a timeout error message for the user' do
|
||||||
expect(HtmlSanitizer.strict(+'<img src="/some_one.png">', true))
|
expect(described_class.strict(+'<img src="/some_one.png">', true))
|
||||||
.to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
|
.to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with href links that contain square brackets' do
|
context 'with href links that contain square brackets' do
|
||||||
it 'correctly URL encodes them' do
|
it 'correctly URL encodes them' do
|
||||||
expect(HtmlSanitizer.strict(+'<a href="https://example.com/?foo=bar&baz[x]=y">example</a>', true))
|
expect(described_class.strict(+'<a href="https://example.com/?foo=bar&baz[x]=y">example</a>', true))
|
||||||
.to eq('<a href="https://example.com/?foo=bar&baz%5Bx%5D=y" rel="nofollow noreferrer noopener" target="_blank" title="https://example.com/?foo=bar&baz[x]=y">example</a>')
|
.to eq('<a href="https://example.com/?foo=bar&baz%5Bx%5D=y" rel="nofollow noreferrer noopener" target="_blank" title="https://example.com/?foo=bar&baz[x]=y">example</a>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -208,7 +208,7 @@ RSpec.describe HtmlSanitizer do
|
||||||
before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) }
|
before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) }
|
||||||
|
|
||||||
it 'returns a timeout error message for the user' do
|
it 'returns a timeout error message for the user' do
|
||||||
expect(HtmlSanitizer.cleanup(+'<img src="/some_one.png">'))
|
expect(described_class.cleanup(+'<img src="/some_one.png">'))
|
||||||
.to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
|
.to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,13 @@ require 'rails_helper'
|
||||||
require 'lib/import/import_factory_examples'
|
require 'lib/import/import_factory_examples'
|
||||||
|
|
||||||
RSpec.describe Import::OTRS::Article::AttachmentFactory do
|
RSpec.describe Import::OTRS::Article::AttachmentFactory do
|
||||||
it_behaves_like 'Import factory'
|
let(:start_import) do
|
||||||
|
described_class.import(
|
||||||
def load_attachment_json(file)
|
attachments: attachments,
|
||||||
json_fixture("import/otrs/article/attachment/#{file}")
|
local_article: local_article
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:local_article) { instance_double(Ticket::Article, ticket_id: 1337, id: 42) }
|
|
||||||
let(:attachments) do
|
let(:attachments) do
|
||||||
[
|
[
|
||||||
load_attachment_json('default'),
|
load_attachment_json('default'),
|
||||||
|
@ -16,11 +16,11 @@ RSpec.describe Import::OTRS::Article::AttachmentFactory do
|
||||||
load_attachment_json('default')
|
load_attachment_json('default')
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
let(:start_import) do
|
|
||||||
described_class.import(
|
let(:local_article) { instance_double(Ticket::Article, ticket_id: 1337, id: 42) }
|
||||||
attachments: attachments,
|
|
||||||
local_article: local_article
|
def load_attachment_json(file)
|
||||||
)
|
json_fixture("import/otrs/article/attachment/#{file}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_expectations
|
def import_expectations
|
||||||
|
@ -34,6 +34,8 @@ RSpec.describe Import::OTRS::Article::AttachmentFactory do
|
||||||
expect(local_article).to receive(:attachments).and_return(article_attachments)
|
expect(local_article).to receive(:attachments).and_return(article_attachments)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'Import factory'
|
||||||
|
|
||||||
it 'imports' do
|
it 'imports' do
|
||||||
article_attachment_expectations([])
|
article_attachment_expectations([])
|
||||||
import_expectations
|
import_expectations
|
||||||
|
|
|
@ -32,18 +32,18 @@ RSpec.describe Import::OTRS::ArticleCustomer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates customers with special encoding in name' do
|
it 'creates customers with special encoding in name' do
|
||||||
expect { described_class.new(load_article_json('customer_special_chars')) }.to change { User.count }.by(1)
|
expect { described_class.new(load_article_json('customer_special_chars')) }.to change(User, :count).by(1)
|
||||||
expect(User.last.login).to eq('user.hernandez@example.com')
|
expect(User.last.login).to eq('user.hernandez@example.com')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates customers with special from email syntax' do
|
it 'creates customers with special from email syntax' do
|
||||||
expect { described_class.new(load_article_json('from_bracket_email_syntax')) }.to change { User.count }.by(1)
|
expect { described_class.new(load_article_json('from_bracket_email_syntax')) }.to change(User, :count).by(1)
|
||||||
expect(User.last.login).to eq('user@example.com')
|
expect(User.last.login).to eq('user@example.com')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'converts emails to downcase' do
|
it 'converts emails to downcase' do
|
||||||
Setting.set('import_mode', true)
|
Setting.set('import_mode', true)
|
||||||
expect { described_class.new(load_article_json('from_capital_case')) }.to change { User.count }.by(1)
|
expect { described_class.new(load_article_json('from_capital_case')) }.to change(User, :count).by(1)
|
||||||
expect(User.last.email).to eq('user@example.com')
|
expect(User.last.email).to eq('user@example.com')
|
||||||
expect(User.last.login).to eq('user@example.com')
|
expect(User.last.login).to eq('user@example.com')
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,7 +104,7 @@ RSpec.describe Import::OTRS::CustomerUser do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
travel_to DateTime.current
|
travel_to DateTime.current
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ require 'lib/import/factory_examples'
|
||||||
require 'lib/import/otrs/dynamic_field_examples'
|
require 'lib/import/otrs/dynamic_field_examples'
|
||||||
|
|
||||||
RSpec.describe Import::OTRS::DynamicFieldFactory do
|
RSpec.describe Import::OTRS::DynamicFieldFactory do
|
||||||
it_behaves_like 'Import::Factory'
|
|
||||||
|
|
||||||
let(:start_import_test) { described_class.import(object_structure) }
|
|
||||||
let(:object_structure) { [load_dynamic_field_json('text/default')] }
|
let(:object_structure) { [load_dynamic_field_json('text/default')] }
|
||||||
|
let(:start_import_test) { described_class.import(object_structure) }
|
||||||
|
|
||||||
|
it_behaves_like 'Import::Factory'
|
||||||
|
|
||||||
it 'responds to skip_field?' do
|
it 'responds to skip_field?' do
|
||||||
expect(described_class).to respond_to('skip_field?')
|
expect(described_class).to respond_to('skip_field?')
|
||||||
|
|
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
||||||
require 'lib/import/otrs/dynamic_field_examples'
|
require 'lib/import/otrs/dynamic_field_examples'
|
||||||
|
|
||||||
RSpec.describe Import::OTRS::DynamicField do
|
RSpec.describe Import::OTRS::DynamicField do
|
||||||
it_behaves_like 'Import::OTRS::DynamicField'
|
|
||||||
|
|
||||||
let(:start_import_test) { described_class.new(object_structure) }
|
|
||||||
let(:object_structure) { load_dynamic_field_json('text/default') }
|
let(:object_structure) { load_dynamic_field_json('text/default') }
|
||||||
|
let(:start_import_test) { described_class.new(object_structure) }
|
||||||
|
|
||||||
|
it_behaves_like 'Import::OTRS::DynamicField'
|
||||||
|
|
||||||
it 'requires an implementation of init_callback' do
|
it 'requires an implementation of init_callback' do
|
||||||
expect(ObjectManager::Attribute).to receive(:get).and_return(false)
|
expect(ObjectManager::Attribute).to receive(:get).and_return(false)
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Import::OTRS::UserFactory do
|
||||||
it 'skips root@localhost' do
|
it 'skips root@localhost' do
|
||||||
|
|
||||||
root_data = json_fixture('import/otrs/user/default')
|
root_data = json_fixture('import/otrs/user/default')
|
||||||
expect(Import::OTRS::User).to_not receive(:new)
|
expect(Import::OTRS::User).not_to receive(:new)
|
||||||
|
|
||||||
described_class.import([root_data])
|
described_class.import([root_data])
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,7 @@ RSpec.shared_examples Import::Zendesk::ObjectAttribute::Base do
|
||||||
|
|
||||||
describe 'exception handling' do
|
describe 'exception handling' do
|
||||||
let(:error_text) { Faker::Lorem.sentence }
|
let(:error_text) { Faker::Lorem.sentence }
|
||||||
|
|
||||||
it 'extends ObjectManager Attribute exception message' do
|
it 'extends ObjectManager Attribute exception message' do
|
||||||
expect(ObjectManager::Attribute).to receive(:add).and_raise(RuntimeError, error_text)
|
expect(ObjectManager::Attribute).to receive(:add).and_raise(RuntimeError, error_text)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,11 @@ require 'ldap/group'
|
||||||
|
|
||||||
RSpec.describe Ldap::Group do
|
RSpec.describe Ldap::Group do
|
||||||
|
|
||||||
|
# required as 'let' to perform test based
|
||||||
|
# expectations and reuse it in 'let' instance
|
||||||
|
# as additional parameter
|
||||||
|
let(:mocked_ldap) { double() }
|
||||||
|
|
||||||
context '.uid_attribute' do
|
context '.uid_attribute' do
|
||||||
|
|
||||||
it 'responds to .uid_attribute' do
|
it 'responds to .uid_attribute' do
|
||||||
|
@ -16,17 +21,12 @@ RSpec.describe Ldap::Group do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# required as 'let' to perform test based
|
|
||||||
# expectations and reuse it in 'let' instance
|
|
||||||
# as additional parameter
|
|
||||||
let(:mocked_ldap) { double() }
|
|
||||||
|
|
||||||
context 'initialization config parameters' do
|
context 'initialization config parameters' do
|
||||||
|
|
||||||
it 'reuses given Ldap instance if given' do
|
it 'reuses given Ldap instance if given' do
|
||||||
config = {}
|
config = {}
|
||||||
expect(Ldap).not_to receive(:new).with(config)
|
expect(Ldap).not_to receive(:new).with(config)
|
||||||
instance = described_class.new(config, ldap: mocked_ldap)
|
described_class.new(config, ldap: mocked_ldap)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'takes optional filter' do
|
it 'takes optional filter' do
|
||||||
|
@ -55,7 +55,8 @@ RSpec.describe Ldap::Group do
|
||||||
|
|
||||||
it 'creates own Ldap instance if none given' do
|
it 'creates own Ldap instance if none given' do
|
||||||
expect(Ldap).to receive(:new)
|
expect(Ldap).to receive(:new)
|
||||||
expect(described_class.new())
|
|
||||||
|
described_class.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ require 'tcr/net/ldap'
|
||||||
|
|
||||||
RSpec.describe Ldap::User do
|
RSpec.describe Ldap::User do
|
||||||
|
|
||||||
|
let(:mocked_ldap) { double() }
|
||||||
|
|
||||||
context '.uid_attribute' do
|
context '.uid_attribute' do
|
||||||
|
|
||||||
it 'responds to .uid_attribute' do
|
it 'responds to .uid_attribute' do
|
||||||
|
@ -32,13 +34,12 @@ RSpec.describe Ldap::User do
|
||||||
# required as 'let' to perform test based
|
# required as 'let' to perform test based
|
||||||
# expectations and reuse it in 'let' instance
|
# expectations and reuse it in 'let' instance
|
||||||
# as additional parameter
|
# as additional parameter
|
||||||
let(:mocked_ldap) { double() }
|
|
||||||
|
|
||||||
context 'initialization config parameters' do
|
context 'initialization config parameters' do
|
||||||
|
|
||||||
it 'reuses given Ldap instance if given' do
|
it 'reuses given Ldap instance if given' do
|
||||||
expect(Ldap).not_to receive(:new)
|
expect(Ldap).not_to receive(:new)
|
||||||
instance = described_class.new(ldap: mocked_ldap)
|
described_class.new(ldap: mocked_ldap)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'takes optional filter' do
|
it 'takes optional filter' do
|
||||||
|
@ -67,7 +68,8 @@ RSpec.describe Ldap::User do
|
||||||
|
|
||||||
it 'creates own Ldap instance if none given' do
|
it 'creates own Ldap instance if none given' do
|
||||||
expect(Ldap).to receive(:new)
|
expect(Ldap).to receive(:new)
|
||||||
expect(described_class.new())
|
|
||||||
|
described_class.new()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -233,13 +233,13 @@ RSpec.describe Ldap do
|
||||||
|
|
||||||
context '#search' do
|
context '#search' do
|
||||||
|
|
||||||
|
let(:base) { 'DC=domain,DC=tld' }
|
||||||
|
let(:filter) { '(objectClass=user)' }
|
||||||
|
|
||||||
it 'responds to #search' do
|
it 'responds to #search' do
|
||||||
expect(instance).to respond_to(:search)
|
expect(instance).to respond_to(:search)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:filter) { '(objectClass=user)' }
|
|
||||||
let(:base) { 'DC=domain,DC=tld' }
|
|
||||||
|
|
||||||
it 'performs search for a filter, base and scope and yields of returned entries' do
|
it 'performs search for a filter, base and scope and yields of returned entries' do
|
||||||
|
|
||||||
scope = Net::LDAP::SearchScope_BaseObject
|
scope = Net::LDAP::SearchScope_BaseObject
|
||||||
|
@ -309,12 +309,12 @@ RSpec.describe Ldap do
|
||||||
|
|
||||||
context '#entries?' do
|
context '#entries?' do
|
||||||
|
|
||||||
|
let(:filter) { '(objectClass=user)' }
|
||||||
|
|
||||||
it 'responds to #entries?' do
|
it 'responds to #entries?' do
|
||||||
expect(instance).to respond_to(:entries?)
|
expect(instance).to respond_to(:entries?)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:filter) { '(objectClass=user)' }
|
|
||||||
|
|
||||||
it 'returns true if entries are present' do
|
it 'returns true if entries are present' do
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
|
|
@ -6,12 +6,12 @@ RSpec.describe Mail::Encodings do
|
||||||
# Then, upstream was fixed, whereas our patch broke.)
|
# Then, upstream was fixed, whereas our patch broke.)
|
||||||
describe '.value_decode' do
|
describe '.value_decode' do
|
||||||
it 'decodes us-ascii encoded strings' do
|
it 'decodes us-ascii encoded strings' do
|
||||||
expect(Mail::Encodings.value_decode('=?us-ascii?Q?Test?='))
|
expect(described_class.value_decode('=?us-ascii?Q?Test?='))
|
||||||
.to eql('Test')
|
.to eql('Test')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'decodes utf-8 encoded strings' do
|
it 'decodes utf-8 encoded strings' do
|
||||||
expect(Mail::Encodings.value_decode('=?UTF-8?Q? Personal=C3=A4nderung?='))
|
expect(described_class.value_decode('=?UTF-8?Q? Personal=C3=A4nderung?='))
|
||||||
.to eql(' Personaländerung')
|
.to eql(' Personaländerung')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,14 +3,14 @@ require 'rails_helper'
|
||||||
RSpec.describe MigrationJob::LdapSamaccountnameToUid do
|
RSpec.describe MigrationJob::LdapSamaccountnameToUid do
|
||||||
|
|
||||||
it 'performs no changes if no LDAP config present' do
|
it 'performs no changes if no LDAP config present' do
|
||||||
expect(Setting).to_not receive(:set)
|
expect(Setting).not_to receive(:set)
|
||||||
expect(Import::Ldap).to receive(:config).and_return(nil)
|
expect(Import::Ldap).to receive(:config).and_return(nil)
|
||||||
|
|
||||||
described_class.new.perform
|
described_class.new.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'performs no changes if uid attributes equals' do
|
it 'performs no changes if uid attributes equals' do
|
||||||
expect(Setting).to_not receive(:set)
|
expect(Setting).not_to receive(:set)
|
||||||
|
|
||||||
ldap_config = {
|
ldap_config = {
|
||||||
'user_uid' => 'samaccountname'
|
'user_uid' => 'samaccountname'
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe NotificationFactory::Slack do
|
RSpec.describe NotificationFactory::Slack do
|
||||||
describe '.template' do
|
describe '.template' do
|
||||||
subject(:template) do
|
subject(:template) do
|
||||||
NotificationFactory::Slack.template(
|
described_class.template(
|
||||||
template: action,
|
template: action,
|
||||||
locale: 'en-us',
|
locale: 'en-us',
|
||||||
timezone: 'Europe/Berlin',
|
timezone: 'Europe/Berlin',
|
||||||
|
@ -64,11 +64,8 @@ RSpec.describe NotificationFactory::Slack do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for "ticket_escalate"' do
|
context 'for "ticket_escalate"' do
|
||||||
before { ticket.escalation_at = escalation_time }
|
|
||||||
let(:escalation_time) { Time.zone.parse('2019-04-01T10:00:00Z') }
|
|
||||||
|
|
||||||
subject(:template) do
|
subject(:template) do
|
||||||
NotificationFactory::Slack.template(
|
described_class.template(
|
||||||
template: 'ticket_escalation',
|
template: 'ticket_escalation',
|
||||||
locale: 'en-us',
|
locale: 'en-us',
|
||||||
timezone: 'Europe/Berlin',
|
timezone: 'Europe/Berlin',
|
||||||
|
@ -80,6 +77,10 @@ RSpec.describe NotificationFactory::Slack do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before { ticket.escalation_at = escalation_time }
|
||||||
|
|
||||||
|
let(:escalation_time) { Time.zone.parse('2019-04-01T10:00:00Z') }
|
||||||
|
|
||||||
it 'returns a hash with subject: <ticket title> (as Markdown heading)' do
|
it 'returns a hash with subject: <ticket title> (as Markdown heading)' do
|
||||||
expect(template).to include(subject: "# #{ticket.title}")
|
expect(template).to include(subject: "# #{ticket.title}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe NotificationFactory::Template do
|
RSpec.describe NotificationFactory::Template do
|
||||||
subject(:template) do
|
subject(:template) do
|
||||||
NotificationFactory::Template.new(template_string, escape)
|
described_class.new(template_string, escape)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#to_s' do
|
describe '#to_s' do
|
||||||
|
|
|
@ -47,6 +47,7 @@ RSpec.describe NotificationFactory do
|
||||||
|
|
||||||
context 'if no locale given in arguments, but default locale is set' do
|
context 'if no locale given in arguments, but default locale is set' do
|
||||||
before { Setting.set('locale_default', 'de-de') }
|
before { Setting.set('locale_default', 'de-de') }
|
||||||
|
|
||||||
let(:rendered_locale) { 'de' }
|
let(:rendered_locale) { 'de' }
|
||||||
|
|
||||||
it 'tries template for default locale' do
|
it 'tries template for default locale' do
|
||||||
|
@ -56,6 +57,7 @@ RSpec.describe NotificationFactory do
|
||||||
|
|
||||||
context 'and no such template exists' do
|
context 'and no such template exists' do
|
||||||
before { Setting.set('locale_default', 'xx') }
|
before { Setting.set('locale_default', 'xx') }
|
||||||
|
|
||||||
let(:rendered_locale) { 'en' }
|
let(:rendered_locale) { 'en' }
|
||||||
|
|
||||||
it 'falls back to en template' do
|
it 'falls back to en template' do
|
||||||
|
|
|
@ -57,12 +57,12 @@ RSpec.describe PasswordHash do
|
||||||
let(:zammad_sha2) { '{sha2}dd9c764fa7ea18cd992c8600006d3dc3ac983d1ba22e9ba2d71f6207456be0ba' }
|
let(:zammad_sha2) { '{sha2}dd9c764fa7ea18cd992c8600006d3dc3ac983d1ba22e9ba2d71f6207456be0ba' }
|
||||||
|
|
||||||
it 'requires hash to be not blank' do
|
it 'requires hash to be not blank' do
|
||||||
expect(described_class.legacy?(nil, pw_plain)).to be_falsy
|
expect(described_class).not_to be_legacy(nil, pw_plain)
|
||||||
expect(described_class.legacy?('', pw_plain)).to be_falsy
|
expect(described_class).not_to be_legacy('', pw_plain)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'requires password to be not nil' do
|
it 'requires password to be not nil' do
|
||||||
expect(described_class.legacy?(zammad_sha2, nil)).to be_falsy
|
expect(described_class).not_to be_legacy(zammad_sha2, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'detects sha2 hashes' do
|
it 'detects sha2 hashes' do
|
||||||
|
|
|
@ -34,7 +34,7 @@ returns
|
||||||
selector: {}, # ticket selector to get only a collection of tickets
|
selector: {}, # ticket selector to get only a collection of tickets
|
||||||
params: { field: 'created_at' },
|
params: { field: 'created_at' },
|
||||||
)
|
)
|
||||||
end.to_not raise_error
|
end.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe SearchIndexBackend do
|
RSpec.describe SearchIndexBackend do
|
||||||
describe '.build_query' do
|
describe '.build_query' do
|
||||||
subject(:query) { SearchIndexBackend.build_query('', query_extension: params) }
|
subject(:query) { described_class.build_query('', query_extension: params) }
|
||||||
|
|
||||||
let(:params) { { 'bool' => { 'filter' => { 'term' => { 'a' => 'b' } } } } }
|
let(:params) { { 'bool' => { 'filter' => { 'term' => { 'a' => 'b' } } } } }
|
||||||
|
|
||||||
it 'coerces :query_extension hash keys to symbols' do
|
it 'coerces :query_extension hash keys to symbols' do
|
||||||
|
@ -11,7 +12,7 @@ RSpec.describe SearchIndexBackend do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.search' do
|
describe '.search' do
|
||||||
subject(:search) { SearchIndexBackend.search(query, index, limit: 3000) }
|
subject(:search) { described_class.search(query, index, limit: 3000) }
|
||||||
|
|
||||||
context 'for query with no results' do
|
context 'for query with no results' do
|
||||||
let(:query) { 'preferences.notification_sound.enabled:*' }
|
let(:query) { 'preferences.notification_sound.enabled:*' }
|
||||||
|
@ -51,7 +52,7 @@ RSpec.describe SearchIndexBackend do
|
||||||
QUERIES
|
QUERIES
|
||||||
|
|
||||||
it 'appends a * to the original query' do
|
it 'appends a * to the original query' do
|
||||||
expect(queries.map(&SearchIndexBackend.method(:append_wildcard_to_simple_query)))
|
expect(queries.map(&described_class.method(:append_wildcard_to_simple_query)))
|
||||||
.to eq(queries.map { |q| "#{q}*" })
|
.to eq(queries.map { |q| "#{q}*" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,7 +94,7 @@ RSpec.describe SearchIndexBackend do
|
||||||
QUERIES
|
QUERIES
|
||||||
|
|
||||||
it 'returns the original query verbatim' do
|
it 'returns the original query verbatim' do
|
||||||
expect(queries.map(&SearchIndexBackend.method(:append_wildcard_to_simple_query)))
|
expect(queries.map(&described_class.method(:append_wildcard_to_simple_query)))
|
||||||
.to eq(queries)
|
.to eq(queries)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,9 +54,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Ldap::Users, sequencer: :sequence
|
||||||
ldap_connection: connection,
|
ldap_connection: connection,
|
||||||
import_job: import_job,
|
import_job: import_job,
|
||||||
)
|
)
|
||||||
end.to change {
|
end.to change(User, :count).by(1)
|
||||||
User.count
|
|
||||||
}.by(1)
|
|
||||||
|
|
||||||
imported_user = User.last
|
imported_user = User.last
|
||||||
|
|
||||||
|
@ -87,9 +85,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Ldap::Users, sequencer: :sequence
|
||||||
ldap_connection: connection,
|
ldap_connection: connection,
|
||||||
import_job: import_job,
|
import_job: import_job,
|
||||||
)
|
)
|
||||||
end.not_to change {
|
end.not_to change(User, :count)
|
||||||
User.count
|
|
||||||
}
|
|
||||||
|
|
||||||
imported_user.reload
|
imported_user.reload
|
||||||
|
|
||||||
|
@ -148,9 +144,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Ldap::Users, sequencer: :sequence
|
||||||
ldap_connection: connection,
|
ldap_connection: connection,
|
||||||
import_job: import_job,
|
import_job: import_job,
|
||||||
)
|
)
|
||||||
end.to change {
|
end.to change(User, :count).by(1)
|
||||||
User.count
|
|
||||||
}.by(1)
|
|
||||||
|
|
||||||
imported_user = User.last
|
imported_user = User.last
|
||||||
|
|
||||||
|
@ -181,9 +175,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Ldap::Users, sequencer: :sequence
|
||||||
ldap_connection: connection,
|
ldap_connection: connection,
|
||||||
import_job: import_job,
|
import_job: import_job,
|
||||||
)
|
)
|
||||||
end.not_to change {
|
end.not_to change(User, :count)
|
||||||
User.count
|
|
||||||
}
|
|
||||||
|
|
||||||
imported_user.reload
|
imported_user.reload
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::Users::Lost::Deactivate, sequencer
|
||||||
|
|
||||||
it 'enforces created_by_id => 1 in newly created History logs' do
|
it 'enforces created_by_id => 1 in newly created History logs' do
|
||||||
expect { process(lost_ids: lost_users.pluck(:id), dry_run: false) }
|
expect { process(lost_ids: lost_users.pluck(:id), dry_run: false) }
|
||||||
.to change { History.count }.by(sample_length)
|
.to change(History, :count).by(sample_length)
|
||||||
|
|
||||||
expect(History.last(sample_length).pluck(:created_by_id))
|
expect(History.last(sample_length).pluck(:created_by_id))
|
||||||
.to eq(Array.new(sample_length, 1))
|
.to eq(Array.new(sample_length, 1))
|
||||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe SignatureDetection do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the first 5–10-line substring they share in common' do
|
it 'returns the first 5–10-line substring they share in common' do
|
||||||
expect(SignatureDetection.find_signature(messages)).to eq(<<~SIG.chomp)
|
expect(described_class.find_signature(messages)).to eq(<<~SIG.chomp)
|
||||||
|
|
||||||
Mit freundlichen Grüßen
|
Mit freundlichen Grüßen
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe SignatureDetection do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the first 5–10-line substring they share in common' do
|
it 'returns the first 5–10-line substring they share in common' do
|
||||||
expect(SignatureDetection.find_signature(messages)).to eq(<<~SIG.chomp)
|
expect(described_class.find_signature(messages)).to eq(<<~SIG.chomp)
|
||||||
|
|
||||||
Freundliche Grüße
|
Freundliche Grüße
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe SignatureDetection do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'converts messages (via #html2text) then returns the first 5–10-line substring they share in common' do
|
it 'converts messages (via #html2text) then returns the first 5–10-line substring they share in common' do
|
||||||
expect(SignatureDetection.find_signature(messages)).to eq(<<~SIG.chomp)
|
expect(described_class.find_signature(messages)).to eq(<<~SIG.chomp)
|
||||||
|
|
||||||
ChristianSmith
|
ChristianSmith
|
||||||
Technik
|
Technik
|
||||||
|
@ -112,7 +112,7 @@ RSpec.describe SignatureDetection do
|
||||||
SIG
|
SIG
|
||||||
|
|
||||||
it 'returns the line of the message where the signature begins' do
|
it 'returns the line of the message where the signature begins' do
|
||||||
expect(SignatureDetection.find_signature_line(signature, content, content_type)).to eq(10)
|
expect(described_class.find_signature_line(signature, content, content_type)).to eq(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ RSpec.describe SignatureDetection do
|
||||||
SIG
|
SIG
|
||||||
|
|
||||||
it 'converts messages (via #html2text) then returns the line of the message where the signature begins' do
|
it 'converts messages (via #html2text) then returns the line of the message where the signature begins' do
|
||||||
expect(SignatureDetection.find_signature_line(signature, content, content_type)).to eq(11)
|
expect(described_class.find_signature_line(signature, content, content_type)).to eq(11)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe SignatureDetection do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the signature-line data of all articles' do
|
it 'updates the signature-line data of all articles' do
|
||||||
expect { SignatureDetection.rebuild_all_articles }
|
expect { described_class.rebuild_all_articles }
|
||||||
.to change { articles.first.reload.preferences[:signature_detection] }.to(3)
|
.to change { articles.first.reload.preferences[:signature_detection] }.to(3)
|
||||||
.and change { articles.second.reload.preferences[:signature_detection] }.to(2)
|
.and change { articles.second.reload.preferences[:signature_detection] }.to(2)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,19 +7,19 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
|
|
||||||
context 'when given an agent with no tickets' do
|
context 'when given an agent with no tickets' do
|
||||||
it 'returns a hash with 1-day average ticket wait time for user (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time for user (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(handling_time: 0)
|
expect(described_class.generate(user)).to include(handling_time: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(average_per_agent: 0)
|
expect(described_class.generate(user)).to include(average_per_agent: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with verbal grade for average ticket wait time' do
|
it 'returns a hash with verbal grade for average ticket wait time' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(state: 'supergood')
|
expect(described_class.generate(user)).to include(state: 'supergood')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with decimal score (0–1) of user’s risk of falling to a lower grade' do
|
it 'returns a hash with decimal score (0–1) of user’s risk of falling to a lower grade' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(percent: 0.0)
|
expect(described_class.generate(user)).to include(percent: 0.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and who belongs to a group with other tickets' do
|
context 'and who belongs to a group with other tickets' do
|
||||||
|
@ -31,7 +31,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(average_per_agent: 60)
|
expect(described_class.generate(user)).to include(average_per_agent: 60)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,19 +45,19 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with 1-day average ticket wait time for user (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time for user (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(handling_time: 60)
|
expect(described_class.generate(user)).to include(handling_time: 60)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(average_per_agent: 60)
|
expect(described_class.generate(user)).to include(average_per_agent: 60)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with verbal grade for average ticket wait time' do
|
it 'returns a hash with verbal grade for average ticket wait time' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(state: 'supergood')
|
expect(described_class.generate(user)).to include(state: 'supergood')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with decimal score (0–1) of user’s risk of falling to a lower grade' do
|
it 'returns a hash with decimal score (0–1) of user’s risk of falling to a lower grade' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(percent: 1.0)
|
expect(described_class.generate(user)).to include(percent: 1.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and who belongs to a group with other tickets' do
|
context 'and who belongs to a group with other tickets' do
|
||||||
|
@ -69,7 +69,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
it 'returns a hash with 1-day average ticket wait time across user’s groups (in minutes)' do
|
||||||
expect(Stats::TicketWaitingTime.generate(user)).to include(average_per_agent: 90)
|
expect(described_class.generate(user)).to include(average_per_agent: 90)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
|
|
||||||
context 'with empty tickets (no articles)' do
|
context 'with empty tickets (no articles)' do
|
||||||
it 'returns 0' do
|
it 'returns 0' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(0)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns 0' do
|
it 'returns 0' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(0)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns elapsed time' do
|
it 'returns elapsed time' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(1.minute)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(1.minute)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ignores them (and measures time to actual response)' do
|
it 'ignores them (and measures time to actual response)' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(2.minutes)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(2.minutes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns average of elapsed times' do
|
it 'returns average of elapsed times' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(3.minutes)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(3.minutes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe Stats::TicketWaitingTime do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ignores all edge cases and returns only specified average response time' do
|
it 'ignores all edge cases and returns only specified average response time' do
|
||||||
expect(Stats::TicketWaitingTime.calculate_average(ticket.id, start_time)).to eq(3.minutes)
|
expect(described_class.calculate_average(ticket.id, start_time)).to eq(3.minutes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,19 +10,19 @@ RSpec.describe Stats do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates stats' do
|
it 'generates stats' do
|
||||||
expect { Stats.generate }.to_not raise_error
|
expect { described_class.generate }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when backend registration is invalid' do
|
context 'when backend registration is invalid' do
|
||||||
|
|
||||||
it 'fails for empty registration' do
|
it 'fails for empty registration' do
|
||||||
Setting.set('Stats::TicketWaitingTime', nil)
|
Setting.set('Stats::TicketWaitingTime', nil)
|
||||||
expect { Stats.generate }.to raise_error(RuntimeError)
|
expect { described_class.generate }.to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for unknown backend' do
|
it 'fails for unknown backend' do
|
||||||
Setting.set('Stats::TicketWaitingTime', 'Stats::UNKNOWN')
|
Setting.set('Stats::TicketWaitingTime', 'Stats::UNKNOWN')
|
||||||
expect { Stats.generate }.to raise_error(LoadError)
|
expect { described_class.generate }.to raise_error(LoadError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ RSpec.describe UploadCache do
|
||||||
'Content-Disposition' => 'attached',
|
'Content-Disposition' => 'attached',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
end.to change { Store.count }.by(1)
|
end.to change(Store, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ RSpec.describe UploadCache do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes all added Store items' do
|
it 'removes all added Store items' do
|
||||||
expect { subject.destroy }.to change { Store.count }.by(-2)
|
expect { subject.destroy }.to change(Store, :count).by(-2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ RSpec.describe UploadCache do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes the Store item matching the given ID' do
|
it 'removes the Store item matching the given ID' do
|
||||||
expect { subject.remove_item(Store.last.id) }.to change { Store.count }.by(-1)
|
expect { subject.remove_item(Store.last.id) }.to change(Store, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prevents removage of non UploadCache Store items' do
|
it 'prevents removage of non UploadCache Store items' do
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
RSpec.shared_examples 'ApplicationModel::CanAssets' do |associations: [], selectors: [], own_attributes: true|
|
RSpec.shared_examples 'ApplicationModel::CanAssets' do |associations: [], selectors: [], own_attributes: true|
|
||||||
subject { create(described_class.name.underscore, updated_by_id: admin.id) }
|
subject { create(described_class.name.underscore, updated_by_id: admin.id) }
|
||||||
|
|
||||||
let(:admin) { create(:admin_user) }
|
let(:admin) { create(:admin_user) }
|
||||||
|
|
||||||
describe '#assets (for supplying model data to front-end framework)' do
|
describe '#assets (for supplying model data to front-end framework)' do
|
||||||
|
@ -37,6 +38,7 @@ RSpec.shared_examples 'ApplicationModel::CanAssets' do |associations: [], select
|
||||||
|
|
||||||
shared_examples 'single association' do
|
shared_examples 'single association' do
|
||||||
subject { create(described_class.name.underscore, association => single) }
|
subject { create(described_class.name.underscore, association => single) }
|
||||||
|
|
||||||
let(:single) { create(reflection.class_name.underscore) }
|
let(:single) { create(reflection.class_name.underscore) }
|
||||||
|
|
||||||
it 'returns a hash with its asset attributes' do
|
it 'returns a hash with its asset attributes' do
|
||||||
|
@ -56,6 +58,7 @@ RSpec.shared_examples 'ApplicationModel::CanAssets' do |associations: [], select
|
||||||
|
|
||||||
shared_examples 'collection association' do
|
shared_examples 'collection association' do
|
||||||
subject { create(described_class.name.underscore, association => collection) }
|
subject { create(described_class.name.underscore, association => collection) }
|
||||||
|
|
||||||
let(:collection) { create_list(reflection.class_name.underscore, 5) }
|
let(:collection) { create_list(reflection.class_name.underscore, 5) }
|
||||||
let(:collection_assets) { collection.reduce({}) { |assets_hash, single| single.assets(assets_hash) } }
|
let(:collection_assets) { collection.reduce({}) { |assets_hash, single| single.assets(assets_hash) } }
|
||||||
|
|
||||||
|
@ -84,6 +87,7 @@ RSpec.shared_examples 'ApplicationModel::CanAssets' do |associations: [], select
|
||||||
|
|
||||||
Array(selectors).each do |s|
|
Array(selectors).each do |s|
|
||||||
subject { create(described_class.name.underscore, s => selector) }
|
subject { create(described_class.name.underscore, s => selector) }
|
||||||
|
|
||||||
let(:selector) { { 'ticket.priority_id' => { operator: 'is', value: [1, 2] } } }
|
let(:selector) { { 'ticket.priority_id' => { operator: 'is', value: [1, 2] } } }
|
||||||
let(:priorities_assets) { Ticket::Priority.first(2).reduce({}) { |asset_hash, priority| priority.assets(asset_hash) } }
|
let(:priorities_assets) { Ticket::Priority.first(2).reduce({}) { |asset_hash, priority| priority.assets(asset_hash) } }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ RSpec.shared_examples 'ApplicationModel::ChecksImport' do
|
||||||
before { Setting.set('system_init_done', false) }
|
before { Setting.set('system_init_done', false) }
|
||||||
|
|
||||||
it 'allows explicit setting of #id attribute' do
|
it 'allows explicit setting of #id attribute' do
|
||||||
expect { subject.save }.not_to change { subject.id }
|
expect { subject.save }.not_to change(subject, :id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ RSpec.shared_examples 'ApplicationModel::ChecksImport' do
|
||||||
before { Setting.set('import_mode', false) }
|
before { Setting.set('import_mode', false) }
|
||||||
|
|
||||||
it 'prevents explicit setting of #id attribute' do
|
it 'prevents explicit setting of #id attribute' do
|
||||||
expect { subject.save }.to change { subject.id }
|
expect { subject.save }.to change(subject, :id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@ RSpec.shared_examples 'ApplicationModel::ChecksImport' do
|
||||||
|
|
||||||
shared_examples 'importable classes' do
|
shared_examples 'importable classes' do
|
||||||
it 'allows explicit setting of #id attribute' do
|
it 'allows explicit setting of #id attribute' do
|
||||||
expect { subject.save }.not_to change { subject.id }
|
expect { subject.save }.not_to change(subject, :id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'non-importable classes' do
|
shared_examples 'non-importable classes' do
|
||||||
it 'prevents explicit setting of #id attribute' do
|
it 'prevents explicit setting of #id attribute' do
|
||||||
expect { subject.save }.to change { subject.id }
|
expect { subject.save }.to change(subject, :id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,18 @@ RSpec.describe Calendar, type: :model do
|
||||||
subject(:calendar) { build(:calendar, default: true) }
|
subject(:calendar) { build(:calendar, default: true) }
|
||||||
|
|
||||||
it 'stays true and sets all other calendars to default: false' do
|
it 'stays true and sets all other calendars to default: false' do
|
||||||
expect { calendar.tap(&:save).reload }.not_to change { calendar.default }
|
expect { calendar.tap(&:save).reload }.not_to change(calendar, :default)
|
||||||
expect(Calendar.where(default: true) - [calendar]).to be_empty
|
expect(Calendar.where(default: true) - [calendar]).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when set to true on update' do
|
context 'when set to true on update' do
|
||||||
subject(:calendar) { create(:calendar, default: false) }
|
subject(:calendar) { create(:calendar, default: false) }
|
||||||
|
|
||||||
before { calendar.default = true }
|
before { calendar.default = true }
|
||||||
|
|
||||||
it 'stays true and sets all other calendars to default: false' do
|
it 'stays true and sets all other calendars to default: false' do
|
||||||
expect { calendar.tap(&:save).reload }.not_to change { calendar.default }
|
expect { calendar.tap(&:save).reload }.not_to change(calendar, :default)
|
||||||
expect(Calendar.where(default: true) - [calendar]).to be_empty
|
expect(Calendar.where(default: true) - [calendar]).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -103,7 +104,7 @@ RSpec.describe Calendar, type: :model do
|
||||||
context 'and neither current date nor iCal URL have changed' do
|
context 'and neither current date nor iCal URL have changed' do
|
||||||
it 'is idempotent' do
|
it 'is idempotent' do
|
||||||
expect { calendar.sync }
|
expect { calendar.sync }
|
||||||
.not_to change { calendar.public_holidays }
|
.not_to change(calendar, :public_holidays)
|
||||||
end
|
end
|
||||||
it 'does not create a background job for escalation rebuild' do
|
it 'does not create a background job for escalation rebuild' do
|
||||||
calendar # create and sync (1 inital background job is created)
|
calendar # create and sync (1 inital background job is created)
|
||||||
|
@ -120,7 +121,7 @@ RSpec.describe Calendar, type: :model do
|
||||||
|
|
||||||
it 'is idempotent' do
|
it 'is idempotent' do
|
||||||
expect { calendar.sync }
|
expect { calendar.sync }
|
||||||
.not_to change { calendar.public_holidays }
|
.not_to change(calendar, :public_holidays)
|
||||||
end
|
end
|
||||||
it 'does not create a background job for escalation rebuild' do
|
it 'does not create a background job for escalation rebuild' do
|
||||||
expect { calendar.sync }
|
expect { calendar.sync }
|
||||||
|
@ -135,7 +136,7 @@ RSpec.describe Calendar, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'appends newly computed event data to #public_holidays' do
|
it 'appends newly computed event data to #public_holidays' do
|
||||||
expect { calendar.sync }.to change { calendar.public_holidays }.to(
|
expect { calendar.sync }.to change(calendar, :public_holidays).to(
|
||||||
'2016-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2016-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
'2017-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2017-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
'2018-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2018-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
|
@ -154,7 +155,7 @@ RSpec.describe Calendar, type: :model do
|
||||||
|
|
||||||
it 'replaces #public_holidays with event data computed from new iCal URL' do
|
it 'replaces #public_holidays with event data computed from new iCal URL' do
|
||||||
expect { calendar.save }
|
expect { calendar.save }
|
||||||
.to change { calendar.public_holidays }.to(
|
.to change(calendar, :public_holidays).to(
|
||||||
'2016-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2016-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
'2016-12-25' => { 'active' => true, 'summary' => 'Christmas2', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2016-12-25' => { 'active' => true, 'summary' => 'Christmas2', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
'2017-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
'2017-12-24' => { 'active' => true, 'summary' => 'Christmas1', 'feed' => Digest::MD5.hexdigest(calendar.ical_url) },
|
||||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
describe 'auto-creating new users' do
|
describe 'auto-creating new users' do
|
||||||
context 'with one unrecognized email address' do
|
context 'with one unrecognized email address' do
|
||||||
it 'creates one new user' do
|
it 'creates one new user' do
|
||||||
expect { Channel::EmailParser.new.process({}, <<~RAW) }.to change { User.count }.by(1)
|
expect { Channel::EmailParser.new.process({}, <<~RAW) }.to change(User, :count).by(1)
|
||||||
From: #{Faker::Internet.unique.email}
|
From: #{Faker::Internet.unique.email}
|
||||||
RAW
|
RAW
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
context 'with a large number of unrecognized recipient addresses' do
|
context 'with a large number of unrecognized recipient addresses' do
|
||||||
it 'never creates more than 40 users' do
|
it 'never creates more than 40 users' do
|
||||||
expect { Channel::EmailParser.new.process({}, <<~RAW) }.to change { User.count }.by(40)
|
expect { Channel::EmailParser.new.process({}, <<~RAW) }.to change(User, :count).by(40)
|
||||||
From: nicole.braun@zammad.org
|
From: nicole.braun@zammad.org
|
||||||
To: #{Array.new(20) { Faker::Internet.unique.email }.join(', ')}
|
To: #{Array.new(20) { Faker::Internet.unique.email }.join(', ')}
|
||||||
Cc: #{Array.new(21) { Faker::Internet.unique.email }.join(', ')}
|
Cc: #{Array.new(21) { Faker::Internet.unique.email }.join(', ')}
|
||||||
|
@ -99,8 +99,8 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
it 'creates a ticket and article' do
|
it 'creates a ticket and article' do
|
||||||
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
.and change { Ticket::Article.count }.by_at_least(1)
|
.and change(Ticket::Article, :count).by_at_least(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets #title to email subject' do
|
it 'sets #title to email subject' do
|
||||||
|
@ -260,7 +260,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
shared_examples 'creates a new ticket' do
|
shared_examples 'creates a new ticket' do
|
||||||
it 'creates a new ticket' do
|
it 'creates a new ticket' do
|
||||||
expect { described_class.new.process({}, raw_mail) }
|
expect { described_class.new.process({}, raw_mail) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
.and not_change { ticket.articles.length }
|
.and not_change { ticket.articles.length }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -656,7 +656,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
context 'when "postmaster_sender_is_agent_search_for_customer" setting is true (default)' do
|
context 'when "postmaster_sender_is_agent_search_for_customer" setting is true (default)' do
|
||||||
it 'sets ticket.customer to user with To: email' do
|
it 'sets ticket.customer to user with To: email' do
|
||||||
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.customer).to eq(customer)
|
expect(Ticket.last.customer).to eq(customer)
|
||||||
end
|
end
|
||||||
|
@ -667,7 +667,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
it 'sets ticket.customer to user with To: email' do
|
it 'sets ticket.customer to user with To: email' do
|
||||||
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
expect { Channel::EmailParser.new.process({}, raw_mail) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.customer).to eq(agent)
|
expect(Ticket.last.customer).to eq(agent)
|
||||||
end
|
end
|
||||||
|
@ -959,7 +959,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
it 're-opens a closed ticket' do
|
it 're-opens a closed ticket' do
|
||||||
expect { described_class.new.process({}, raw_mail) }
|
expect { described_class.new.process({}, raw_mail) }
|
||||||
.to not_change { Ticket.count }
|
.to not_change(Ticket, :count)
|
||||||
.and change { ticket.reload.state.name }.to('open')
|
.and change { ticket.reload.state.name }.to('open')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -972,7 +972,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
it 'does not re-open a closed ticket' do
|
it 'does not re-open a closed ticket' do
|
||||||
expect { described_class.new.process({}, raw_mail) }
|
expect { described_class.new.process({}, raw_mail) }
|
||||||
.to not_change { Ticket.count }
|
.to not_change(Ticket, :count)
|
||||||
.and not_change { ticket.reload.state.name }
|
.and not_change { ticket.reload.state.name }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Channel::Filter::Match::EmailRegex do
|
RSpec.describe Channel::Filter::Match::EmailRegex do
|
||||||
describe '.match' do
|
describe '.match' do
|
||||||
subject(:match) { Channel::Filter::Match::EmailRegex.match(value: from, match_rule: sender, check_mode: check_mode) }
|
subject(:match) { described_class.match(value: from, match_rule: sender, check_mode: check_mode) }
|
||||||
|
|
||||||
let(:from) { 'foobar@foo.bar' }
|
let(:from) { 'foobar@foo.bar' }
|
||||||
|
|
||||||
context 'in normal (error-suppressing) mode (default)' do
|
context 'in normal (error-suppressing) mode (default)' do
|
||||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe Channel do
|
||||||
|
|
||||||
it 'adds tickets as appropriate' do
|
it 'adds tickets as appropriate' do
|
||||||
expect { twitter_channel.fetch(true) }
|
expect { twitter_channel.fetch(true) }
|
||||||
.to change { Ticket.count }.by(26)
|
.to change(Ticket, :count).by(26)
|
||||||
|
|
||||||
expect(Ticket.last.attributes).to include(
|
expect(Ticket.last.attributes).to include(
|
||||||
'title' => 'Wir haben unsere DMs deaktiviert. ' \
|
'title' => 'Wir haben unsere DMs deaktiviert. ' \
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
||||||
context 'group' do
|
context 'group' do
|
||||||
subject { create(group_access_factory) }
|
subject { create(group_access_factory) }
|
||||||
|
|
||||||
let(:group_full) { create(:group) }
|
let(:group_full) { create(:group) }
|
||||||
let(:group_read) { create(:group) }
|
let(:group_read) { create(:group) }
|
||||||
let(:group_inactive) { create(:group, active: false) }
|
let(:group_inactive) { create(:group, active: false) }
|
||||||
|
@ -45,7 +46,7 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
||||||
|
|
||||||
context 'result' do
|
context 'result' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_full.name => 'full',
|
group_full.name => 'full',
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
|
@ -78,16 +79,16 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
||||||
|
|
||||||
context '#group_access?' do
|
context '#group_access?' do
|
||||||
|
|
||||||
it 'responds to group_access?' do
|
before do
|
||||||
expect(subject).to respond_to(:group_access?)
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'responds to group_access?' do
|
||||||
|
expect(subject).to respond_to(:group_access?)
|
||||||
|
end
|
||||||
|
|
||||||
context 'Group ID parameter' do
|
context 'Group ID parameter' do
|
||||||
include_examples '#group_access? call' do
|
include_examples '#group_access? call' do
|
||||||
let(:group_parameter) { group_read.id }
|
let(:group_parameter) { group_read.id }
|
||||||
|
@ -121,16 +122,16 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
||||||
|
|
||||||
context '#group_ids_access' do
|
context '#group_ids_access' do
|
||||||
|
|
||||||
it 'responds to group_ids_access' do
|
before do
|
||||||
expect(subject).to respond_to(:group_ids_access)
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'responds to group_ids_access' do
|
||||||
|
expect(subject).to respond_to(:group_ids_access)
|
||||||
|
end
|
||||||
|
|
||||||
it 'lists only active Group IDs' do
|
it 'lists only active Group IDs' do
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
|
@ -531,16 +532,16 @@ RSpec.shared_examples 'HasGroups' do |group_access_factory:|
|
||||||
|
|
||||||
context '.group_access' do
|
context '.group_access' do
|
||||||
|
|
||||||
it 'responds to group_access' do
|
before do
|
||||||
expect(described_class).to respond_to(:group_access)
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'responds to group_access' do
|
||||||
|
expect(described_class).to respond_to(:group_access)
|
||||||
|
end
|
||||||
|
|
||||||
it 'lists only active instances' do
|
it 'lists only active instances' do
|
||||||
subject.update!(active: false)
|
subject.update!(active: false)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
RSpec.shared_examples 'HasGroups and Permissions' do |group_access_no_permission_factory:|
|
RSpec.shared_examples 'HasGroups and Permissions' do |group_access_no_permission_factory:|
|
||||||
context 'group' do
|
context 'group' do
|
||||||
subject { build(group_access_no_permission_factory) }
|
subject { build(group_access_no_permission_factory) }
|
||||||
|
|
||||||
let(:group_read) { create(:group) }
|
let(:group_read) { create(:group) }
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
subject.group_names_access_map = {
|
subject.group_names_access_map = {
|
||||||
group_read.name => 'read',
|
group_read.name => 'read',
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
||||||
context 'role' do
|
context 'role' do
|
||||||
subject { create(group_access_factory) }
|
subject { create(group_access_factory) }
|
||||||
|
|
||||||
let(:role) { create(:role) }
|
let(:role) { create(:role) }
|
||||||
let(:group_instance) { create(:group) }
|
let(:group_instance) { create(:group) }
|
||||||
let(:group_role) { create(:group) }
|
let(:group_role) { create(:group) }
|
||||||
|
@ -13,7 +14,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'active Role' do
|
context 'active Role' do
|
||||||
before(:each) do
|
before do
|
||||||
role.group_names_access_map = {
|
role.group_names_access_map = {
|
||||||
group_role.name => 'read',
|
group_role.name => 'read',
|
||||||
}
|
}
|
||||||
|
@ -58,7 +59,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
||||||
|
|
||||||
context '.role_access_ids' do
|
context '.role_access_ids' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
role.group_names_access_map = {
|
role.group_names_access_map = {
|
||||||
group_role.name => 'read',
|
group_role.name => 'read',
|
||||||
}
|
}
|
||||||
|
@ -101,7 +102,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
||||||
|
|
||||||
context 'group' do
|
context 'group' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
role.group_names_access_map = {
|
role.group_names_access_map = {
|
||||||
group_role.name => 'read',
|
group_role.name => 'read',
|
||||||
}
|
}
|
||||||
|
@ -129,7 +130,7 @@ RSpec.shared_examples 'HasRoles' do |group_access_factory:|
|
||||||
|
|
||||||
context '#group_ids_access' do
|
context '#group_ids_access' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
role.group_names_access_map = {
|
role.group_names_access_map = {
|
||||||
group_role.name => 'read',
|
group_role.name => 'read',
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
|
||||||
context '#search_index_update', performs_jobs: true do
|
context '#search_index_update', performs_jobs: true do
|
||||||
subject { create(indexed_factory) }
|
subject { create(indexed_factory) }
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
allow(SearchIndexBackend).to receive(:enabled?).and_return(true)
|
allow(SearchIndexBackend).to receive(:enabled?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'record indexing' do
|
context 'record indexing' do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
expect(subject).to be_present
|
expect(subject).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ RSpec.shared_examples 'HasXssSanitizedNote' do |model_factory:|
|
||||||
describe 'XSS prevention' do
|
describe 'XSS prevention' do
|
||||||
context 'with injected JS' do
|
context 'with injected JS' do
|
||||||
subject { create(model_factory, note: 'test 123 <script type="text/javascript">alert("XSS!");</script> <b>some text</b>') }
|
subject { create(model_factory, note: 'test 123 <script type="text/javascript">alert("XSS!");</script> <b>some text</b>') }
|
||||||
|
|
||||||
it 'strips out <script> tag' do
|
it 'strips out <script> tag' do
|
||||||
expect(subject.note).to eq('test 123 alert("XSS!"); <b>some text</b>')
|
expect(subject.note).to eq('test 123 alert("XSS!"); <b>some text</b>')
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,16 +97,17 @@ RSpec.describe Cti::CallerId do
|
||||||
describe '.lookup' do
|
describe '.lookup' do
|
||||||
context 'when given an unrecognized number' do
|
context 'when given an unrecognized number' do
|
||||||
it 'returns an empty array' do
|
it 'returns an empty array' do
|
||||||
expect(Cti::CallerId.lookup('1')).to eq([])
|
expect(described_class.lookup('1')).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given a recognized number' do
|
context 'when given a recognized number' do
|
||||||
subject!(:caller_id) { create(:caller_id, caller_id: number) }
|
subject!(:caller_id) { create(:caller_id, caller_id: number) }
|
||||||
|
|
||||||
let(:number) { '1234567890' }
|
let(:number) { '1234567890' }
|
||||||
|
|
||||||
it 'returns an array with the corresponding CallerId' do
|
it 'returns an array with the corresponding CallerId' do
|
||||||
expect(Cti::CallerId.lookup(number)).to match_array([caller_id])
|
expect(described_class.lookup(number)).to match_array([caller_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'shared by multiple CallerIds' do
|
context 'shared by multiple CallerIds' do
|
||||||
|
@ -117,7 +118,7 @@ RSpec.describe Cti::CallerId do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns all corresponding CallerId records' do
|
it 'returns all corresponding CallerId records' do
|
||||||
expect(Cti::CallerId.lookup(number)).to match_array(caller_ids)
|
expect(described_class.lookup(number)).to match_array(caller_ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ RSpec.describe Cti::CallerId do
|
||||||
subject!(:caller_ids) { create_list(:caller_id, 2, caller_id: number) }
|
subject!(:caller_ids) { create_list(:caller_id, 2, caller_id: number) }
|
||||||
|
|
||||||
it 'returns one corresponding CallerId record by MAX(id)' do
|
it 'returns one corresponding CallerId record by MAX(id)' do
|
||||||
expect(Cti::CallerId.lookup(number)).to match_array(caller_ids.last(1))
|
expect(described_class.lookup(number)).to match_array(caller_ids.last(1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,7 +138,7 @@ RSpec.describe Cti::CallerId do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns one CallerId record per unique #user_id, by MAX(id)' do
|
it 'returns one CallerId record per unique #user_id, by MAX(id)' do
|
||||||
expect(Cti::CallerId.lookup(number)).to match_array(caller_ids.last(2))
|
expect(described_class.lookup(number)).to match_array(caller_ids.last(2))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -150,16 +151,16 @@ RSpec.describe Cti::CallerId do
|
||||||
|
|
||||||
context 'and no corresponding CallerId exists' do
|
context 'and no corresponding CallerId exists' do
|
||||||
it 'generates a CallerId record (with #level "known")' do
|
it 'generates a CallerId record (with #level "known")' do
|
||||||
Cti::CallerId.destroy_all # CallerId already generated in User callback
|
described_class.destroy_all # CallerId already generated in User callback
|
||||||
|
|
||||||
expect { Cti::CallerId.rebuild }
|
expect { described_class.rebuild }
|
||||||
.to change { Cti::CallerId.exists?(user_id: user.id, caller_id: '49123456', level: 'known') }
|
.to change { described_class.exists?(user_id: user.id, caller_id: '49123456', level: 'known') }
|
||||||
.to(true)
|
.to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create duplicate CallerId records' do
|
it 'does not create duplicate CallerId records' do
|
||||||
expect { Cti::CallerId.rebuild }.not_to change { Cti::CallerId.count }
|
expect { described_class.rebuild }.not_to change(described_class, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,8 +168,8 @@ RSpec.describe Cti::CallerId do
|
||||||
subject!(:caller_id) { create(:caller_id) }
|
subject!(:caller_id) { create(:caller_id) }
|
||||||
|
|
||||||
it 'deletes the CallerId record' do
|
it 'deletes the CallerId record' do
|
||||||
expect { Cti::CallerId.rebuild }
|
expect { described_class.rebuild }
|
||||||
.to change { Cti::CallerId.exists?(caller_id.id) }.to(false)
|
.to change { described_class.exists?(caller_id.id) }.to(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -176,12 +177,12 @@ RSpec.describe Cti::CallerId do
|
||||||
let!(:users) { create_list(:agent_user, 2, phone: '+49 123 456') }
|
let!(:users) { create_list(:agent_user, 2, phone: '+49 123 456') }
|
||||||
|
|
||||||
it 'generates two corresponding CallerId records (with #level "known")' do
|
it 'generates two corresponding CallerId records (with #level "known")' do
|
||||||
Cti::CallerId.destroy_all # CallerId already generated in User callback
|
described_class.destroy_all # CallerId already generated in User callback
|
||||||
|
|
||||||
expect { Cti::CallerId.rebuild }
|
expect { described_class.rebuild }
|
||||||
.to change { Cti::CallerId.exists?(user_id: users.first.id, caller_id: '49123456', level: 'known') }
|
.to change { described_class.exists?(user_id: users.first.id, caller_id: '49123456', level: 'known') }
|
||||||
.to(true)
|
.to(true)
|
||||||
.and change { Cti::CallerId.exists?(user_id: users.last.id, caller_id: '49123456', level: 'known') }
|
.and change { described_class.exists?(user_id: users.last.id, caller_id: '49123456', level: 'known') }
|
||||||
.to(true)
|
.to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -196,10 +197,10 @@ RSpec.describe Cti::CallerId do
|
||||||
let(:sender_name) { 'Customer' }
|
let(:sender_name) { 'Customer' }
|
||||||
|
|
||||||
it 'generates a CallerId record (with #level "maybe")' do
|
it 'generates a CallerId record (with #level "maybe")' do
|
||||||
Cti::CallerId.destroy_all # CallerId already generated in Article observer job
|
described_class.destroy_all # CallerId already generated in Article observer job
|
||||||
|
|
||||||
expect { Cti::CallerId.rebuild }
|
expect { described_class.rebuild }
|
||||||
.to change { Cti::CallerId.exists?(user_id: article.created_by_id, caller_id: '49123456', level: 'maybe') }
|
.to change { described_class.exists?(user_id: article.created_by_id, caller_id: '49123456', level: 'maybe') }
|
||||||
.to(true)
|
.to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -208,8 +209,8 @@ RSpec.describe Cti::CallerId do
|
||||||
let(:sender_name) { 'Agent' }
|
let(:sender_name) { 'Agent' }
|
||||||
|
|
||||||
it 'does not generate a CallerId record' do
|
it 'does not generate a CallerId record' do
|
||||||
expect { Cti::CallerId.rebuild }
|
expect { described_class.rebuild }
|
||||||
.not_to change { Cti::CallerId.exists?(caller_id: '49123456') }
|
.not_to change { described_class.exists?(caller_id: '49123456') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -219,20 +220,20 @@ RSpec.describe Cti::CallerId do
|
||||||
let(:attributes) { attributes_for(:caller_id) }
|
let(:attributes) { attributes_for(:caller_id) }
|
||||||
|
|
||||||
it 'wraps .find_or_initialize_by (passing only five defining attributes)' do
|
it 'wraps .find_or_initialize_by (passing only five defining attributes)' do
|
||||||
expect(Cti::CallerId)
|
expect(described_class)
|
||||||
.to receive(:find_or_initialize_by)
|
.to receive(:find_or_initialize_by)
|
||||||
.with(attributes.slice(:caller_id, :level, :object, :o_id, :user_id))
|
.with(attributes.slice(:caller_id, :level, :object, :o_id, :user_id))
|
||||||
.and_call_original
|
.and_call_original
|
||||||
|
|
||||||
Cti::CallerId.maybe_add(attributes)
|
described_class.maybe_add(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if no matching record found' do
|
context 'if no matching record found' do
|
||||||
it 'adds given #comment attribute' do
|
it 'adds given #comment attribute' do
|
||||||
expect { Cti::CallerId.maybe_add(attributes.merge(comment: 'foo')) }
|
expect { described_class.maybe_add(attributes.merge(comment: 'foo')) }
|
||||||
.to change { Cti::CallerId.count }.by(1)
|
.to change(described_class, :count).by(1)
|
||||||
|
|
||||||
expect(Cti::CallerId.last.comment).to eq('foo')
|
expect(described_class.last.comment).to eq('foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ RSpec.describe Cti::CallerId do
|
||||||
let(:caller_id) { create(:caller_id) }
|
let(:caller_id) { create(:caller_id) }
|
||||||
|
|
||||||
it 'ignores given #comment attribute' do
|
it 'ignores given #comment attribute' do
|
||||||
expect(Cti::CallerId.maybe_add(attributes.merge(comment: 'foo')))
|
expect(described_class.maybe_add(attributes.merge(comment: 'foo')))
|
||||||
.to eq(caller_id)
|
.to eq(caller_id)
|
||||||
|
|
||||||
expect(caller_id.comment).to be_blank
|
expect(caller_id.comment).to be_blank
|
||||||
|
@ -251,6 +252,7 @@ RSpec.describe Cti::CallerId do
|
||||||
|
|
||||||
describe 'callbacks' do
|
describe 'callbacks' do
|
||||||
subject!(:caller_id) { build(:cti_caller_id, caller_id: phone) }
|
subject!(:caller_id) { build(:cti_caller_id, caller_id: phone) }
|
||||||
|
|
||||||
let(:phone) { '1234567890' }
|
let(:phone) { '1234567890' }
|
||||||
|
|
||||||
describe 'on creation' do
|
describe 'on creation' do
|
||||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Cti::Log do
|
||||||
|
|
||||||
describe '.log' do
|
describe '.log' do
|
||||||
it 'returns a hash with :list and :assets keys' do
|
it 'returns a hash with :list and :assets keys' do
|
||||||
expect(Cti::Log.log).to be_a(Hash).and include(:list, :assets)
|
expect(described_class.log).to be_a(Hash).and include(:list, :assets)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when over 60 Log records exist' do
|
context 'when over 60 Log records exist' do
|
||||||
|
@ -17,17 +17,18 @@ RSpec.describe Cti::Log do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the 60 latest ones in the :list key' do
|
it 'returns the 60 latest ones in the :list key' do
|
||||||
expect(Cti::Log.log[:list]).to match_array(cti_logs.last(60))
|
expect(described_class.log[:list]).to match_array(cti_logs.last(60))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Log records have arrays of CallerId attributes in #preferences[:to] / #preferences[:from]' do
|
context 'when Log records have arrays of CallerId attributes in #preferences[:to] / #preferences[:from]' do
|
||||||
subject!(:cti_log) { create(:'cti/log', preferences: { from: [caller_id] }) }
|
subject!(:cti_log) { create(:'cti/log', preferences: { from: [caller_id] }) }
|
||||||
|
|
||||||
let(:caller_id) { create(:caller_id) }
|
let(:caller_id) { create(:caller_id) }
|
||||||
let(:user) { User.find_by(id: caller_id.user_id) }
|
let(:user) { User.find_by(id: caller_id.user_id) }
|
||||||
|
|
||||||
it 'returns a hash of the CallerId Users and their assets in the :assets key' do
|
it 'returns a hash of the CallerId Users and their assets in the :assets key' do
|
||||||
expect(Cti::Log.log[:assets]).to eq(user.assets({}))
|
expect(described_class.log[:assets]).to eq(user.assets({}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,33 +53,35 @@ RSpec.describe Cti::Log do
|
||||||
|
|
||||||
context 'with unrecognized "call_id"' do
|
context 'with unrecognized "call_id"' do
|
||||||
it 'creates a new Log record (#state: "newCall", #done: false)' do
|
it 'creates a new Log record (#state: "newCall", #done: false)' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { Cti::Log.count }.by(1)
|
.to change(described_class, :count).by(1)
|
||||||
|
|
||||||
expect(Cti::Log.last.attributes)
|
expect(described_class.last.attributes)
|
||||||
.to include('state' => 'newCall', 'done' => false)
|
.to include('state' => 'newCall', 'done' => false)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for direction "in", with a CallerId record matching the "from" number' do
|
context 'for direction "in", with a CallerId record matching the "from" number' do
|
||||||
let!(:caller_id) { create(:caller_id, caller_id: '49123456') }
|
let!(:caller_id) { create(:caller_id, caller_id: '49123456') }
|
||||||
|
|
||||||
before { attributes.merge!('direction' => 'in') }
|
before { attributes.merge!('direction' => 'in') }
|
||||||
|
|
||||||
it 'saves that CallerId’s attributes in the new Log’s #preferences[:from] attribute' do
|
it 'saves that CallerId’s attributes in the new Log’s #preferences[:from] attribute' do
|
||||||
Cti::Log.process(attributes)
|
described_class.process(attributes)
|
||||||
|
|
||||||
expect(Cti::Log.last.preferences[:from].first)
|
expect(described_class.last.preferences[:from].first)
|
||||||
.to include(caller_id.attributes.except('created_at')) # Checking equality of Time objects is error-prone
|
.to include(caller_id.attributes.except('created_at')) # Checking equality of Time objects is error-prone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for direction "out", with a CallerId record matching the "to" number' do
|
context 'for direction "out", with a CallerId record matching the "to" number' do
|
||||||
let!(:caller_id) { create(:caller_id, caller_id: '49123457') }
|
let!(:caller_id) { create(:caller_id, caller_id: '49123457') }
|
||||||
|
|
||||||
before { attributes.merge!('direction' => 'out') }
|
before { attributes.merge!('direction' => 'out') }
|
||||||
|
|
||||||
it 'saves that CallerId’s attributes in the new Log’s #preferences[:to] attribute' do
|
it 'saves that CallerId’s attributes in the new Log’s #preferences[:to] attribute' do
|
||||||
Cti::Log.process(attributes)
|
described_class.process(attributes)
|
||||||
|
|
||||||
expect(Cti::Log.last.preferences[:to].first)
|
expect(described_class.last.preferences[:to].first)
|
||||||
.to include(caller_id.attributes.except('created_at')) # Checking equality of Time objects is error-prone
|
.to include(caller_id.attributes.except('created_at')) # Checking equality of Time objects is error-prone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -88,7 +91,7 @@ RSpec.describe Cti::Log do
|
||||||
before { create(:'cti/log', call_id: '1') }
|
before { create(:'cti/log', call_id: '1') }
|
||||||
|
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
expect { Cti::Log.process(attributes) }.to raise_error(/call_id \S+ already exists!/)
|
expect { described_class.process(attributes) }.to raise_error(/call_id \S+ already exists!/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -98,7 +101,7 @@ RSpec.describe Cti::Log do
|
||||||
|
|
||||||
context 'with unrecognized "call_id"' do
|
context 'with unrecognized "call_id"' do
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
expect { Cti::Log.process(attributes) }.to raise_error(/No such call_id/)
|
expect { described_class.process(attributes) }.to raise_error(/No such call_id/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,7 +110,7 @@ RSpec.describe Cti::Log do
|
||||||
let(:log) { create(:'cti/log', call_id: 1, state: 'newCall', done: false) }
|
let(:log) { create(:'cti/log', call_id: 1, state: 'newCall', done: false) }
|
||||||
|
|
||||||
it 'returns early with no changes' do
|
it 'returns early with no changes' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { log.reload.state }.to('answer')
|
.to change { log.reload.state }.to('answer')
|
||||||
.and change { log.reload.done }.to(true)
|
.and change { log.reload.done }.to(true)
|
||||||
end
|
end
|
||||||
|
@ -117,8 +120,8 @@ RSpec.describe Cti::Log do
|
||||||
let(:log) { create(:'cti/log', call_id: 1, state: 'hangup', done: false) }
|
let(:log) { create(:'cti/log', call_id: 1, state: 'hangup', done: false) }
|
||||||
|
|
||||||
it 'returns early with no changes' do
|
it 'returns early with no changes' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.not_to change { log.reload }
|
.not_to change(log, :reload)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -129,7 +132,7 @@ RSpec.describe Cti::Log do
|
||||||
|
|
||||||
context 'with unrecognized "call_id"' do
|
context 'with unrecognized "call_id"' do
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
expect { Cti::Log.process(attributes) }.to raise_error(/No such call_id/)
|
expect { described_class.process(attributes) }.to raise_error(/No such call_id/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,7 +141,7 @@ RSpec.describe Cti::Log do
|
||||||
let(:log) { create(:'cti/log', call_id: 1, state: 'newCall', done: false) }
|
let(:log) { create(:'cti/log', call_id: 1, state: 'newCall', done: false) }
|
||||||
|
|
||||||
it 'sets attributes #state: "hangup", #done: false' do
|
it 'sets attributes #state: "hangup", #done: false' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { log.reload.state }.to('hangup')
|
.to change { log.reload.state }.to('hangup')
|
||||||
.and not_change { log.reload.done }
|
.and not_change { log.reload.done }
|
||||||
end
|
end
|
||||||
|
@ -147,7 +150,7 @@ RSpec.describe Cti::Log do
|
||||||
let(:cause) { 'forwarded' }
|
let(:cause) { 'forwarded' }
|
||||||
|
|
||||||
it 'sets attributes #state: "hangup", #done: true' do
|
it 'sets attributes #state: "hangup", #done: true' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { log.reload.state }.to('hangup')
|
.to change { log.reload.state }.to('hangup')
|
||||||
.and change { log.reload.done }.to(true)
|
.and change { log.reload.done }.to(true)
|
||||||
end
|
end
|
||||||
|
@ -158,7 +161,7 @@ RSpec.describe Cti::Log do
|
||||||
let(:log) { create(:'cti/log', call_id: 1, state: 'answer', done: true) }
|
let(:log) { create(:'cti/log', call_id: 1, state: 'answer', done: true) }
|
||||||
|
|
||||||
it 'sets attributes #state: "hangup"' do
|
it 'sets attributes #state: "hangup"' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { log.reload.state }.to('hangup')
|
.to change { log.reload.state }.to('hangup')
|
||||||
.and not_change { log.reload.done }
|
.and not_change { log.reload.done }
|
||||||
end
|
end
|
||||||
|
@ -167,7 +170,7 @@ RSpec.describe Cti::Log do
|
||||||
before { log.update(to_comment: 'voicemail') }
|
before { log.update(to_comment: 'voicemail') }
|
||||||
|
|
||||||
it 'sets attributes #state: "hangup", #done: false' do
|
it 'sets attributes #state: "hangup", #done: false' do
|
||||||
expect { Cti::Log.process(attributes) }
|
expect { described_class.process(attributes) }
|
||||||
.to change { log.reload.state }.to('hangup')
|
.to change { log.reload.state }.to('hangup')
|
||||||
.and change { log.reload.done }.to(false)
|
.and change { log.reload.done }.to(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,6 +43,7 @@ RSpec.describe EmailAddress, type: :model do
|
||||||
|
|
||||||
describe '#channel' do
|
describe '#channel' do
|
||||||
subject(:email_addresses) { create_list(:email_address, 2, channel: channel) }
|
subject(:email_addresses) { create_list(:email_address, 2, channel: channel) }
|
||||||
|
|
||||||
let(:channel) { create(:channel) }
|
let(:channel) { create(:channel) }
|
||||||
|
|
||||||
context 'when a Channel is destroyed' do
|
context 'when a Channel is destroyed' do
|
||||||
|
|
|
@ -515,7 +515,7 @@ RSpec.describe Job, type: :model do
|
||||||
it 'is set automatically on save (cannot be set manually)' do
|
it 'is set automatically on save (cannot be set manually)' do
|
||||||
job.next_run_at = 1.day.from_now
|
job.next_run_at = 1.day.from_now
|
||||||
|
|
||||||
expect { job.save }.to change { job.next_run_at }
|
expect { job.save }.to change(job, :next_run_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for an inactive Job' do
|
context 'for an inactive Job' do
|
||||||
|
@ -523,7 +523,7 @@ RSpec.describe Job, type: :model do
|
||||||
|
|
||||||
it 'is nil' do
|
it 'is nil' do
|
||||||
expect { job.save }
|
expect { job.save }
|
||||||
.not_to change { job.next_run_at }.from(nil)
|
.not_to change(job, :next_run_at).from(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -532,12 +532,13 @@ RSpec.describe Job, type: :model do
|
||||||
|
|
||||||
it 'is nil' do
|
it 'is nil' do
|
||||||
expect { job.save }
|
expect { job.save }
|
||||||
.not_to change { job.next_run_at }.from(nil)
|
.not_to change(job, :next_run_at).from(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when #timeplan contains at least one true value for :day, :hour, and :minute' do
|
context 'when #timeplan contains at least one true value for :day, :hour, and :minute' do
|
||||||
subject(:job) { build(:job, :never_on) }
|
subject(:job) { build(:job, :never_on) }
|
||||||
|
|
||||||
let(:base_time) { Time.current.beginning_of_week }
|
let(:base_time) { Time.current.beginning_of_week }
|
||||||
|
|
||||||
# Tuesday & Thursday @ 12:00a, 12:30a, 6:00p, and 6:30p
|
# Tuesday & Thursday @ 12:00a, 12:30a, 6:00p, and 6:30p
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe ObjectLookup, type: :model do
|
||||||
|
|
||||||
it 'creates a new one with that name' do
|
it 'creates a new one with that name' do
|
||||||
expect { ObjectLookup.by_name(name) }
|
expect { ObjectLookup.by_name(name) }
|
||||||
.to change { ObjectLookup.count }.by(1)
|
.to change(ObjectLookup, :count).by(1)
|
||||||
|
|
||||||
expect(ObjectLookup.last.name).to eq(name)
|
expect(ObjectLookup.last.name).to eq(name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,9 +11,6 @@ RSpec.describe ObjectManager::Attribute::Validation::Backend do
|
||||||
|
|
||||||
describe 'backend interface' do
|
describe 'backend interface' do
|
||||||
|
|
||||||
let(:record) { build(:user) }
|
|
||||||
let(:attribute) { ::ObjectManager::Attribute.find_by(name: 'firstname') }
|
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
described_class.new(
|
described_class.new(
|
||||||
record: record,
|
record: record,
|
||||||
|
@ -21,6 +18,9 @@ RSpec.describe ObjectManager::Attribute::Validation::Backend do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:record) { build(:user) }
|
||||||
|
let(:attribute) { ::ObjectManager::Attribute.find_by(name: 'firstname') }
|
||||||
|
|
||||||
it 'has attr_accessor for record' do
|
it 'has attr_accessor for record' do
|
||||||
expect(subject.record).to eq(record)
|
expect(subject.record).to eq(record)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,6 @@ require 'models/object_manager/attribute/validation/backend_examples'
|
||||||
|
|
||||||
RSpec.describe ::ObjectManager::Attribute::Validation::FuturePast do
|
RSpec.describe ::ObjectManager::Attribute::Validation::FuturePast do
|
||||||
|
|
||||||
let(:record) { build(:user) }
|
|
||||||
let(:attribute) { build(:object_manager_attribute_datetime) }
|
|
||||||
subject do
|
subject do
|
||||||
described_class.new(
|
described_class.new(
|
||||||
record: record,
|
record: record,
|
||||||
|
@ -12,6 +10,9 @@ RSpec.describe ::ObjectManager::Attribute::Validation::FuturePast do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:record) { build(:user) }
|
||||||
|
let(:attribute) { build(:object_manager_attribute_datetime) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(subject).to receive(:value).and_return(value)
|
allow(subject).to receive(:value).and_return(value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,6 @@ require 'models/object_manager/attribute/validation/backend_examples'
|
||||||
|
|
||||||
RSpec.describe ::ObjectManager::Attribute::Validation::Required do
|
RSpec.describe ::ObjectManager::Attribute::Validation::Required do
|
||||||
|
|
||||||
let(:record) { build(:user) }
|
|
||||||
let(:attribute) { build(:object_manager_attribute_date) }
|
|
||||||
subject do
|
subject do
|
||||||
described_class.new(
|
described_class.new(
|
||||||
record: record,
|
record: record,
|
||||||
|
@ -12,6 +10,9 @@ RSpec.describe ::ObjectManager::Attribute::Validation::Required do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:record) { build(:user) }
|
||||||
|
let(:attribute) { build(:object_manager_attribute_date) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(subject).to receive(:value).and_return(value)
|
allow(subject).to receive(:value).and_return(value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ RSpec.describe ObjectManager::Attribute::Validation, application_handle: 'applic
|
||||||
describe '#validate' do
|
describe '#validate' do
|
||||||
|
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:record) { build(:user) }
|
let(:record) { build(:user) }
|
||||||
let(:backend) { spy }
|
let(:backend) { spy }
|
||||||
|
|
||||||
|
@ -63,13 +64,13 @@ RSpec.describe ObjectManager::Attribute::Validation, application_handle: 'applic
|
||||||
|
|
||||||
it 'is skipped because of irrelevant ApplicationHandleInfo', application_handle: 'non_application_server' do
|
it 'is skipped because of irrelevant ApplicationHandleInfo', application_handle: 'non_application_server' do
|
||||||
subject.validate(record)
|
subject.validate(record)
|
||||||
expect(backend).to_not have_received(:validate)
|
expect(backend).not_to have_received(:validate)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is skipped because of import_mode is active' do
|
it 'is skipped because of import_mode is active' do
|
||||||
expect(Setting).to receive(:get).with('import_mode').and_return(true)
|
expect(Setting).to receive(:get).with('import_mode').and_return(true)
|
||||||
subject.validate(record)
|
subject.validate(record)
|
||||||
expect(backend).to_not have_received(:validate)
|
expect(backend).not_to have_received(:validate)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is skipped because of unchanged attributes' do
|
it 'is skipped because of unchanged attributes' do
|
||||||
|
|
|
@ -77,7 +77,7 @@ RSpec.describe ObjectManager::Attribute, type: :model do
|
||||||
ObjectManager::Attribute.add attribute
|
ObjectManager::Attribute.add attribute
|
||||||
expect do
|
expect do
|
||||||
ObjectManager::Attribute.add attribute
|
ObjectManager::Attribute.add attribute
|
||||||
end.to_not raise_error
|
end.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts duplicate attribute name on compatible types (editing the type of an existing attribute)' do
|
it 'accepts duplicate attribute name on compatible types (editing the type of an existing attribute)' do
|
||||||
|
@ -87,13 +87,13 @@ RSpec.describe ObjectManager::Attribute, type: :model do
|
||||||
attribute[:data_option_new] = { default: '', options: { 'a' => 'a' } }
|
attribute[:data_option_new] = { default: '', options: { 'a' => 'a' } }
|
||||||
expect do
|
expect do
|
||||||
ObjectManager::Attribute.add attribute
|
ObjectManager::Attribute.add attribute
|
||||||
end.to_not raise_error
|
end.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts valid attribute names' do
|
it 'accepts valid attribute names' do
|
||||||
expect do
|
expect do
|
||||||
ObjectManager::Attribute.add attributes_for :object_manager_attribute_text
|
ObjectManager::Attribute.add attributes_for :object_manager_attribute_text
|
||||||
end.to_not raise_error
|
end.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -138,7 +138,7 @@ RSpec.describe RecentView, type: :model do
|
||||||
it 'wraps RecentView.create' do
|
it 'wraps RecentView.create' do
|
||||||
expect do
|
expect do
|
||||||
described_class.log(viewed_object.class.name, viewed_object.id, admin)
|
described_class.log(viewed_object.class.name, viewed_object.id, admin)
|
||||||
end.to change { RecentView.count }.by(1)
|
end.to change(RecentView, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'access privileges' do
|
describe 'access privileges' do
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe RecentView, type: :model do
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
described_class.log(viewed_object.class.name, viewed_object.id, agent)
|
described_class.log(viewed_object.class.name, viewed_object.id, agent)
|
||||||
end.not_to change { RecentView.count }
|
end.not_to change(RecentView, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -160,19 +160,19 @@ RSpec.describe RecentView, type: :model do
|
||||||
it 'does not create RecentView for non-existent record' do
|
it 'does not create RecentView for non-existent record' do
|
||||||
expect do
|
expect do
|
||||||
described_class.log('User', 99_999_999, admin)
|
described_class.log('User', 99_999_999, admin)
|
||||||
end.not_to change { RecentView.count }
|
end.not_to change(RecentView, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create RecentView for instance of non-ObjectLookup class' do
|
it 'does not create RecentView for instance of non-ObjectLookup class' do
|
||||||
expect do
|
expect do
|
||||||
described_class.log('Overview', 1, admin)
|
described_class.log('Overview', 1, admin)
|
||||||
end.not_to change { RecentView.count }
|
end.not_to change(RecentView, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create RecentView for instance of non-existent class' do
|
it 'does not create RecentView for instance of non-existent class' do
|
||||||
expect do
|
expect do
|
||||||
described_class.log('NonExistentClass', 1, admin)
|
described_class.log('NonExistentClass', 1, admin)
|
||||||
end.not_to change { RecentView.count }
|
end.not_to change(RecentView, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,27 +13,27 @@ RSpec.describe Role do
|
||||||
describe 'Default state' do
|
describe 'Default state' do
|
||||||
describe 'of whole table:' do
|
describe 'of whole table:' do
|
||||||
it 'has three records ("Admin", "Agent", and "Customer")' do
|
it 'has three records ("Admin", "Agent", and "Customer")' do
|
||||||
expect(Role.pluck(:name)).to match_array(%w[Admin Agent Customer])
|
expect(described_class.pluck(:name)).to match_array(%w[Admin Agent Customer])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'of "Admin" role:' do
|
describe 'of "Admin" role:' do
|
||||||
it 'has default admin permissions' do
|
it 'has default admin permissions' do
|
||||||
expect(Role.find_by(name: 'Admin').permissions.pluck(:name))
|
expect(described_class.find_by(name: 'Admin').permissions.pluck(:name))
|
||||||
.to match_array(%w[admin user_preferences report])
|
.to match_array(%w[admin user_preferences report])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'of "Agent" role:' do
|
describe 'of "Agent" role:' do
|
||||||
it 'has default agent permissions' do
|
it 'has default agent permissions' do
|
||||||
expect(Role.find_by(name: 'Agent').permissions.pluck(:name))
|
expect(described_class.find_by(name: 'Agent').permissions.pluck(:name))
|
||||||
.to match_array(%w[ticket.agent chat.agent cti.agent user_preferences])
|
.to match_array(%w[ticket.agent chat.agent cti.agent user_preferences])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'of "Customer" role:' do
|
describe 'of "Customer" role:' do
|
||||||
it 'has default customer permissions' do
|
it 'has default customer permissions' do
|
||||||
expect(Role.find_by(name: 'Customer').permissions.pluck(:name))
|
expect(described_class.find_by(name: 'Customer').permissions.pluck(:name))
|
||||||
.to match_array(
|
.to match_array(
|
||||||
%w[
|
%w[
|
||||||
user_preferences.password
|
user_preferences.password
|
||||||
|
@ -54,7 +54,7 @@ RSpec.describe Role do
|
||||||
|
|
||||||
it 'can be created' do
|
it 'can be created' do
|
||||||
expect { create(:role, permissions: [permission]) }
|
expect { create(:role, permissions: [permission]) }
|
||||||
.to change { Role.count }.by(1)
|
.to change(described_class, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can be added' do
|
it 'can be added' do
|
||||||
|
@ -69,7 +69,7 @@ RSpec.describe Role do
|
||||||
it 'cannot be created' do
|
it 'cannot be created' do
|
||||||
expect { create(:role, permissions: [permission]) }
|
expect { create(:role, permissions: [permission]) }
|
||||||
.to raise_error(/is disabled/)
|
.to raise_error(/is disabled/)
|
||||||
.and change { Role.count }.by(0)
|
.and change(described_class, :count).by(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cannot be added' do
|
it 'cannot be added' do
|
||||||
|
@ -85,7 +85,7 @@ RSpec.describe Role do
|
||||||
it 'cannot be created' do
|
it 'cannot be created' do
|
||||||
expect { create(:role, permissions: [Permission.first, permission]) }
|
expect { create(:role, permissions: [Permission.first, permission]) }
|
||||||
.to raise_error(/conflicts with/)
|
.to raise_error(/conflicts with/)
|
||||||
.and change { Role.count }.by(0)
|
.and change(described_class, :count).by(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cannot be added' do
|
it 'cannot be added' do
|
||||||
|
@ -102,7 +102,7 @@ RSpec.describe Role do
|
||||||
|
|
||||||
it 'can be created' do
|
it 'can be created' do
|
||||||
expect { create(:role, permissions: [Permission.first, permission]) }
|
expect { create(:role, permissions: [Permission.first, permission]) }
|
||||||
.to change { Role.count }.by(1)
|
.to change(described_class, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can be added' do
|
it 'can be added' do
|
||||||
|
@ -119,16 +119,17 @@ RSpec.describe Role do
|
||||||
|
|
||||||
describe '#validate_agent_limit_by_attributes' do
|
describe '#validate_agent_limit_by_attributes' do
|
||||||
context 'when reactivating a role adds new agents' do
|
context 'when reactivating a role adds new agents' do
|
||||||
before { create(:user, roles: [role]) }
|
|
||||||
subject(:role) { create(:agent_role, active: false) }
|
subject(:role) { create(:agent_role, active: false) }
|
||||||
|
|
||||||
|
before { create(:user, roles: [role]) }
|
||||||
|
|
||||||
context 'exceeding the system limit' do
|
context 'exceeding the system limit' do
|
||||||
before { Setting.set('system_agent_limit', agents.count) }
|
before { Setting.set('system_agent_limit', agents.count) }
|
||||||
|
|
||||||
it 'fails and raises an error' do
|
it 'fails and raises an error' do
|
||||||
expect { role.update!(active: true) }
|
expect { role.update!(active: true) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { agents.count }.by(0)
|
.and change(agents, :count).by(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -156,6 +157,7 @@ RSpec.describe Role do
|
||||||
|
|
||||||
context 'for roles with permissions that are children of "admin"' do
|
context 'for roles with permissions that are children of "admin"' do
|
||||||
subject(:role) { build(:role, permissions: [permission]) }
|
subject(:role) { build(:role, permissions: [permission]) }
|
||||||
|
|
||||||
let(:permission) { create(:permission, name: 'admin.foo') }
|
let(:permission) { create(:permission, name: 'admin.foo') }
|
||||||
|
|
||||||
it 'cannot be set to true on creation' do
|
it 'cannot be set to true on creation' do
|
||||||
|
@ -199,40 +201,40 @@ RSpec.describe Role do
|
||||||
let(:result) { [] }
|
let(:result) { [] }
|
||||||
|
|
||||||
it 'returns an empty array' do
|
it 'returns an empty array' do
|
||||||
expect(Role.with_permissions(permission)).to match_array(result)
|
expect(described_class.with_permissions(permission)).to match_array(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given the name of a top-level permission' do
|
context 'when given the name of a top-level permission' do
|
||||||
let(:permission) { 'user_preferences' }
|
let(:permission) { 'user_preferences' }
|
||||||
let(:result) { Role.where(name: %w[Admin Agent]) }
|
let(:result) { described_class.where(name: %w[Admin Agent]) }
|
||||||
|
|
||||||
it 'returns an array of roles with that permission' do
|
it 'returns an array of roles with that permission' do
|
||||||
expect(Role.with_permissions(permission)).to match_array(result)
|
expect(described_class.with_permissions(permission)).to match_array(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given the name of a child permission' do
|
context 'when given the name of a child permission' do
|
||||||
let(:permission) { 'user_preferences.language' }
|
let(:permission) { 'user_preferences.language' }
|
||||||
let(:result) { Role.all }
|
let(:result) { described_class.all }
|
||||||
|
|
||||||
it 'returns an array of roles with either that permission or an ancestor' do
|
it 'returns an array of roles with either that permission or an ancestor' do
|
||||||
expect(Role.with_permissions(permission)).to match_array(result)
|
expect(described_class.with_permissions(permission)).to match_array(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given the names of multiple permissions' do
|
context 'when given the names of multiple permissions' do
|
||||||
let(:permissions) { %w[ticket.agent ticket.customer] }
|
let(:permissions) { %w[ticket.agent ticket.customer] }
|
||||||
let(:result) { Role.where(name: %w[Agent Customer]) }
|
let(:result) { described_class.where(name: %w[Agent Customer]) }
|
||||||
|
|
||||||
it 'returns an array of roles matching ANY given permission' do
|
it 'returns an array of roles matching ANY given permission' do
|
||||||
expect(Role.with_permissions(permissions)).to match_array(result)
|
expect(described_class.with_permissions(permissions)).to match_array(result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#with_permission?' do
|
describe '#with_permission?' do
|
||||||
subject(:role) { Role.find_by(name: 'Admin') }
|
subject(:role) { described_class.find_by(name: 'Admin') }
|
||||||
|
|
||||||
context 'when given the name of a permission it has' do
|
context 'when given the name of a permission it has' do
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
|
|
|
@ -22,6 +22,7 @@ RSpec.describe Setting, type: :model do
|
||||||
|
|
||||||
context 'when #preferences hash includes a :cache key' do
|
context 'when #preferences hash includes a :cache key' do
|
||||||
subject(:setting) { create(:setting, preferences: { cache: ['foo'] }) }
|
subject(:setting) { create(:setting, preferences: { cache: ['foo'] }) }
|
||||||
|
|
||||||
before { Cache.write('foo', 'bar') }
|
before { Cache.write('foo', 'bar') }
|
||||||
|
|
||||||
it 'resets the cache key' do
|
it 'resets the cache key' do
|
||||||
|
@ -49,7 +50,7 @@ RSpec.describe Setting, type: :model do
|
||||||
|
|
||||||
it 'is set on creation, based on #state' do
|
it 'is set on creation, based on #state' do
|
||||||
expect { setting.save }
|
expect { setting.save }
|
||||||
.to change { setting.state_initial }.from({}).to({ value: 'foo' })
|
.to change(setting, :state_initial).from({}).to({ value: 'foo' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe Tag do
|
RSpec.describe Tag do
|
||||||
|
|
||||||
context 'rename' do
|
context 'rename' do
|
||||||
before(:each) do
|
before do
|
||||||
Tag::Item.lookup_by_name_and_create('test1')
|
Tag::Item.lookup_by_name_and_create('test1')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Taskbar do
|
||||||
|
|
||||||
let(:taskbar) do
|
let(:taskbar) do
|
||||||
|
|
||||||
Taskbar.destroy_all
|
described_class.destroy_all
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
|
||||||
create(:taskbar, params: {
|
create(:taskbar, params: {
|
||||||
|
@ -81,9 +81,9 @@ RSpec.describe Taskbar do
|
||||||
|
|
||||||
it 'create tasks' do
|
it 'create tasks' do
|
||||||
|
|
||||||
Taskbar.destroy_all
|
described_class.destroy_all
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
taskbar1 = Taskbar.create(
|
taskbar1 = described_class.create(
|
||||||
client_id: 123,
|
client_id: 123,
|
||||||
key: 'Ticket-1234',
|
key: 'Ticket-1234',
|
||||||
callback: 'TicketZoom',
|
callback: 'TicketZoom',
|
||||||
|
@ -96,7 +96,7 @@ RSpec.describe Taskbar do
|
||||||
)
|
)
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
taskbar2 = Taskbar.create(
|
taskbar2 = described_class.create(
|
||||||
client_id: 123,
|
client_id: 123,
|
||||||
key: 'Ticket-1234',
|
key: 'Ticket-1234',
|
||||||
callback: 'TicketZoom',
|
callback: 'TicketZoom',
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar2.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar2.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar3 = Taskbar.create(
|
taskbar3 = described_class.create(
|
||||||
client_id: 123,
|
client_id: 123,
|
||||||
key: 'Ticket-4444',
|
key: 'Ticket-4444',
|
||||||
callback: 'TicketZoom',
|
callback: 'TicketZoom',
|
||||||
|
@ -156,7 +156,7 @@ RSpec.describe Taskbar do
|
||||||
agent_user_id = create(:agent_user).id
|
agent_user_id = create(:agent_user).id
|
||||||
UserInfo.current_user_id = agent_user_id
|
UserInfo.current_user_id = agent_user_id
|
||||||
|
|
||||||
taskbar4 = Taskbar.create(
|
taskbar4 = described_class.create(
|
||||||
client_id: 123,
|
client_id: 123,
|
||||||
key: 'Ticket-1234',
|
key: 'Ticket-1234',
|
||||||
callback: 'TicketZoom',
|
callback: 'TicketZoom',
|
||||||
|
|
|
@ -40,14 +40,14 @@ RSpec.describe Ticket::Article, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'of subsequent articles on a ticket' do
|
context 'of subsequent articles on a ticket' do
|
||||||
let!(:first_article) do
|
|
||||||
create(:ticket_article, ticket: ticket, sender_name: 'Agent', type_name: 'email')
|
|
||||||
end
|
|
||||||
|
|
||||||
subject(:article) do
|
subject(:article) do
|
||||||
create(:ticket_article, ticket: ticket, sender_name: 'Customer', type_name: 'twitter status')
|
create(:ticket_article, ticket: ticket, sender_name: 'Customer', type_name: 'twitter status')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let!(:first_article) do
|
||||||
|
create(:ticket_article, ticket: ticket, sender_name: 'Agent', type_name: 'email')
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not modify ticket’s sender/type attributes' do
|
it 'does not modify ticket’s sender/type attributes' do
|
||||||
expect { article }
|
expect { article }
|
||||||
.to not_change { ticket.reload.create_article_sender.name }
|
.to not_change { ticket.reload.create_article_sender.name }
|
||||||
|
@ -243,6 +243,7 @@ RSpec.describe Ticket::Article, type: :model do
|
||||||
describe 'DoS protection:' do
|
describe 'DoS protection:' do
|
||||||
context 'when #body exceeds 1.5MB' do
|
context 'when #body exceeds 1.5MB' do
|
||||||
subject(:article) { create(:ticket_article, body: body) }
|
subject(:article) { create(:ticket_article, body: body) }
|
||||||
|
|
||||||
let(:body) { 'a' * 2_000_000 }
|
let(:body) { 'a' * 2_000_000 }
|
||||||
|
|
||||||
context 'for "web" thread', application_handle: 'web' do
|
context 'for "web" thread', application_handle: 'web' do
|
||||||
|
@ -296,6 +297,7 @@ RSpec.describe Ticket::Article, type: :model do
|
||||||
|
|
||||||
describe 'Auto-setting of outgoing Twitter article attributes (via bg jobs):' do
|
describe 'Auto-setting of outgoing Twitter article attributes (via bg jobs):' do
|
||||||
subject!(:twitter_article) { create(:twitter_article, sender_name: 'Agent') }
|
subject!(:twitter_article) { create(:twitter_article, sender_name: 'Agent') }
|
||||||
|
|
||||||
let(:channel) { Channel.find(twitter_article.ticket.preferences[:channel_id]) }
|
let(:channel) { Channel.find(twitter_article.ticket.preferences[:channel_id]) }
|
||||||
|
|
||||||
let(:run_bg_jobs) do
|
let(:run_bg_jobs) do
|
||||||
|
|
|
@ -26,7 +26,7 @@ RSpec.describe Ticket::Overviews do
|
||||||
}
|
}
|
||||||
overview = create(:overview, condition: condition)
|
overview = create(:overview, condition: condition)
|
||||||
|
|
||||||
result = Ticket::Overviews.index(user)
|
result = described_class.index(user)
|
||||||
result = result.select { |x| x[:overview][:name] == overview.name }
|
result = result.select { |x| x[:overview][:name] == overview.name }
|
||||||
|
|
||||||
expect(result.count).to be == 1
|
expect(result.count).to be == 1
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Ticket::TimeAccounting, type: :model do
|
||||||
context 'when destroyed' do
|
context 'when destroyed' do
|
||||||
it 'destroys self' do
|
it 'destroys self' do
|
||||||
expect { time_accounting.ticket_article.destroy }
|
expect { time_accounting.ticket_article.destroy }
|
||||||
.to change { time_accounting.persisted? }.to(false)
|
.to change(time_accounting, :persisted?).to(false)
|
||||||
.and change { Ticket::TimeAccounting.count }.by(-1)
|
.and change { Ticket::TimeAccounting.count }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
it 'performs a ticket deletion on a ticket' do
|
it 'performs a ticket deletion on a ticket' do
|
||||||
expect { ticket.perform_changes(perform, 'trigger', ticket, User.first) }
|
expect { ticket.perform_changes(perform, 'trigger', ticket, User.first) }
|
||||||
.to change { ticket.destroyed? }.to(true)
|
.to change(ticket, :destroyed?).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -242,6 +242,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'but the user is a customer from the same organization as ticket’s customer' do
|
context 'but the user is a customer from the same organization as ticket’s customer' do
|
||||||
subject(:ticket) { create(:ticket, customer: customer) }
|
subject(:ticket) { create(:ticket, customer: customer) }
|
||||||
|
|
||||||
let(:customer) { create(:customer_user, organization: create(:organization)) }
|
let(:customer) { create(:customer_user, organization: create(:organization)) }
|
||||||
let(:colleague) { create(:customer_user, organization: customer.organization) }
|
let(:colleague) { create(:customer_user, organization: customer.organization) }
|
||||||
|
|
||||||
|
@ -469,7 +470,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
context 'when #state is updated to any non-"pending" value' do
|
context 'when #state is updated to any non-"pending" value' do
|
||||||
it 'is reset to nil' do
|
it 'is reset to nil' do
|
||||||
expect { ticket.update!(state: Ticket::State.lookup(name: 'open')) }
|
expect { ticket.update!(state: Ticket::State.lookup(name: 'open')) }
|
||||||
.to change { ticket.pending_time }.to(nil)
|
.to change(ticket, :pending_time).to(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -484,6 +485,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe '#escalation_at' do
|
describe '#escalation_at' do
|
||||||
before { travel_to(Time.current) } # freeze time
|
before { travel_to(Time.current) } # freeze time
|
||||||
|
|
||||||
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
||||||
let(:calendar) { create(:calendar, :'24/7') }
|
let(:calendar) { create(:calendar, :'24/7') }
|
||||||
|
|
||||||
|
@ -503,6 +505,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'after first agent’s response' do
|
context 'after first agent’s response' do
|
||||||
before { ticket } # create ticket
|
before { ticket } # create ticket
|
||||||
|
|
||||||
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
||||||
|
|
||||||
it 'is updated based on the SLA’s #update_time' do
|
it 'is updated based on the SLA’s #update_time' do
|
||||||
|
@ -526,8 +529,10 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when updated after an SLA has been added to the system' do
|
context 'when updated after an SLA has been added to the system' do
|
||||||
before { ticket } # create ticket
|
before do
|
||||||
before { sla } # create sla
|
ticket # create ticket
|
||||||
|
sla # create sla
|
||||||
|
end
|
||||||
|
|
||||||
it 'is updated based on the new SLA’s #first_response_time' do
|
it 'is updated based on the new SLA’s #first_response_time' do
|
||||||
expect { ticket.save! }
|
expect { ticket.save! }
|
||||||
|
@ -536,19 +541,22 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when updated after all SLAs have been removed from the system' do
|
context 'when updated after all SLAs have been removed from the system' do
|
||||||
before { sla } # create sla
|
before do
|
||||||
before { ticket } # create ticket
|
sla # create sla
|
||||||
before { sla.destroy }
|
ticket # create ticket
|
||||||
|
sla.destroy
|
||||||
|
end
|
||||||
|
|
||||||
it 'is set to nil' do
|
it 'is set to nil' do
|
||||||
expect { ticket.save! }
|
expect { ticket.save! }
|
||||||
.to change { ticket.escalation_at }.to(nil)
|
.to change(ticket, :escalation_at).to(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#first_response_escalation_at' do
|
describe '#first_response_escalation_at' do
|
||||||
before { travel_to(Time.current) } # freeze time
|
before { travel_to(Time.current) } # freeze time
|
||||||
|
|
||||||
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
||||||
let(:calendar) { create(:calendar, :'24/7') }
|
let(:calendar) { create(:calendar, :'24/7') }
|
||||||
|
|
||||||
|
@ -568,10 +576,11 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'after first agent’s response' do
|
context 'after first agent’s response' do
|
||||||
before { ticket } # create ticket
|
before { ticket } # create ticket
|
||||||
|
|
||||||
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
||||||
|
|
||||||
it 'does not change' do
|
it 'does not change' do
|
||||||
expect { article }.not_to change { ticket.first_response_escalation_at }
|
expect { article }.not_to change(ticket, :first_response_escalation_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -579,6 +588,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe '#update_escalation_at' do
|
describe '#update_escalation_at' do
|
||||||
before { travel_to(Time.current) } # freeze time
|
before { travel_to(Time.current) } # freeze time
|
||||||
|
|
||||||
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
||||||
let(:calendar) { create(:calendar, :'24/7') }
|
let(:calendar) { create(:calendar, :'24/7') }
|
||||||
|
|
||||||
|
@ -598,6 +608,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'after first agent’s response' do
|
context 'after first agent’s response' do
|
||||||
before { ticket } # create ticket
|
before { ticket } # create ticket
|
||||||
|
|
||||||
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
||||||
|
|
||||||
it 'is updated based on the SLA’s #update_time' do
|
it 'is updated based on the SLA’s #update_time' do
|
||||||
|
@ -613,6 +624,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe '#close_escalation_at' do
|
describe '#close_escalation_at' do
|
||||||
before { travel_to(Time.current) } # freeze time
|
before { travel_to(Time.current) } # freeze time
|
||||||
|
|
||||||
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
let(:sla) { create(:sla, calendar: calendar, first_response_time: 60, update_time: 180, solution_time: 240) }
|
||||||
let(:calendar) { create(:calendar, :'24/7') }
|
let(:calendar) { create(:calendar, :'24/7') }
|
||||||
|
|
||||||
|
@ -632,10 +644,11 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'after first agent’s response' do
|
context 'after first agent’s response' do
|
||||||
before { ticket } # create ticket
|
before { ticket } # create ticket
|
||||||
|
|
||||||
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
let(:article) { create(:ticket_article, ticket: ticket, sender_name: 'Agent') }
|
||||||
|
|
||||||
it 'does not change' do
|
it 'does not change' do
|
||||||
expect { article }.not_to change { ticket.close_escalation_at }
|
expect { article }.not_to change(ticket, :close_escalation_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -645,12 +658,13 @@ RSpec.describe Ticket, type: :model do
|
||||||
describe 'Associations:' do
|
describe 'Associations:' do
|
||||||
describe '#organization' do
|
describe '#organization' do
|
||||||
subject(:ticket) { build(:ticket, customer: customer, organization: nil) }
|
subject(:ticket) { build(:ticket, customer: customer, organization: nil) }
|
||||||
|
|
||||||
let(:customer) { create(:customer, :with_org) }
|
let(:customer) { create(:customer, :with_org) }
|
||||||
|
|
||||||
context 'on creation' do
|
context 'on creation' do
|
||||||
it 'automatically adopts the organization of its #customer' do
|
it 'automatically adopts the organization of its #customer' do
|
||||||
expect { ticket.save }
|
expect { ticket.save }
|
||||||
.to change { ticket.organization }.to(customer.organization)
|
.to change(ticket, :organization).to(customer.organization)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -698,6 +712,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe 'Cti::CallerId syncing:' do
|
describe 'Cti::CallerId syncing:' do
|
||||||
subject(:ticket) { build(:ticket) }
|
subject(:ticket) { build(:ticket) }
|
||||||
|
|
||||||
before { allow(Cti::CallerId).to receive(:build) }
|
before { allow(Cti::CallerId).to receive(:build) }
|
||||||
|
|
||||||
it 'adds numbers in article bodies (via Cti::CallerId.build)' do
|
it 'adds numbers in article bodies (via Cti::CallerId.build)' do
|
||||||
|
@ -711,6 +726,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe 'Touching associations on update:' do
|
describe 'Touching associations on update:' do
|
||||||
subject(:ticket) { create(:ticket, customer: customer) }
|
subject(:ticket) { create(:ticket, customer: customer) }
|
||||||
|
|
||||||
let(:customer) { create(:customer_user, organization: organization) }
|
let(:customer) { create(:customer_user, organization: organization) }
|
||||||
let(:organization) { create(:organization) }
|
let(:organization) { create(:organization) }
|
||||||
let(:other_customer) { create(:customer_user, organization: other_organization) }
|
let(:other_customer) { create(:customer_user, organization: other_organization) }
|
||||||
|
@ -828,11 +844,12 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'when ticket is generated from email (with attachments)' do
|
context 'when ticket is generated from email (with attachments)' do
|
||||||
subject(:ticket) { Channel::EmailParser.new.process({}, raw_email).first }
|
subject(:ticket) { Channel::EmailParser.new.process({}, raw_email).first }
|
||||||
|
|
||||||
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
|
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
|
||||||
|
|
||||||
it 'adds attachments to the Store{::File,::Provider::DB} tables' do
|
it 'adds attachments to the Store{::File,::Provider::DB} tables' do
|
||||||
expect { ticket }
|
expect { ticket }
|
||||||
.to change { Store.count }.by(2)
|
.to change(Store, :count).by(2)
|
||||||
.and change { Store::File.count }.by(2)
|
.and change { Store::File.count }.by(2)
|
||||||
.and change { Store::Provider::DB.count }.by(2)
|
.and change { Store::Provider::DB.count }.by(2)
|
||||||
end
|
end
|
||||||
|
@ -842,7 +859,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
ticket # create ticket
|
ticket # create ticket
|
||||||
|
|
||||||
expect { ticket.destroy }
|
expect { ticket.destroy }
|
||||||
.to change { Store.count }.by(-2)
|
.to change(Store, :count).by(-2)
|
||||||
.and change { Store::File.count }.by(-2)
|
.and change { Store::File.count }.by(-2)
|
||||||
.and change { Store::Provider::DB.count }.by(-2)
|
.and change { Store::Provider::DB.count }.by(-2)
|
||||||
end
|
end
|
||||||
|
@ -850,11 +867,12 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
context 'and a duplicate ticket is generated from the same email' do
|
context 'and a duplicate ticket is generated from the same email' do
|
||||||
before { ticket } # create ticket
|
before { ticket } # create ticket
|
||||||
|
|
||||||
let(:duplicate) { Channel::EmailParser.new.process({}, raw_email).first }
|
let(:duplicate) { Channel::EmailParser.new.process({}, raw_email).first }
|
||||||
|
|
||||||
it 'adds duplicate attachments to the Store table only' do
|
it 'adds duplicate attachments to the Store table only' do
|
||||||
expect { duplicate }
|
expect { duplicate }
|
||||||
.to change { Store.count }.by(2)
|
.to change(Store, :count).by(2)
|
||||||
.and change { Store::File.count }.by(0)
|
.and change { Store::File.count }.by(0)
|
||||||
.and change { Store::Provider::DB.count }.by(0)
|
.and change { Store::Provider::DB.count }.by(0)
|
||||||
end
|
end
|
||||||
|
@ -864,7 +882,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
duplicate # create ticket
|
duplicate # create ticket
|
||||||
|
|
||||||
expect { duplicate.destroy }
|
expect { duplicate.destroy }
|
||||||
.to change { Store.count }.by(-2)
|
.to change(Store, :count).by(-2)
|
||||||
.and change { Store::File.count }.by(0)
|
.and change { Store::File.count }.by(0)
|
||||||
.and change { Store::Provider::DB.count }.by(0)
|
.and change { Store::Provider::DB.count }.by(0)
|
||||||
end
|
end
|
||||||
|
@ -875,7 +893,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
duplicate.destroy
|
duplicate.destroy
|
||||||
|
|
||||||
expect { ticket.destroy }
|
expect { ticket.destroy }
|
||||||
.to change { Store.count }.by(-2)
|
.to change(Store, :count).by(-2)
|
||||||
.and change { Store::File.count }.by(-2)
|
.and change { Store::File.count }.by(-2)
|
||||||
.and change { Store::Provider::DB.count }.by(-2)
|
.and change { Store::Provider::DB.count }.by(-2)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ RSpec.describe Token, type: :model do
|
||||||
token # create token
|
token # create token
|
||||||
|
|
||||||
expect { Token.check(action: token.action, name: token.name) }
|
expect { Token.check(action: token.action, name: token.name) }
|
||||||
.not_to change { Token.count }
|
.not_to change(Token, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe Token, type: :model do
|
||||||
token # create token
|
token # create token
|
||||||
|
|
||||||
expect { Token.check(action: token.action, name: token.name) }
|
expect { Token.check(action: token.action, name: token.name) }
|
||||||
.not_to change { Token.count }
|
.not_to change(Token, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ RSpec.describe Token, type: :model do
|
||||||
token # create token
|
token # create token
|
||||||
|
|
||||||
expect { Token.check(action: token.action, name: token.name) }
|
expect { Token.check(action: token.action, name: token.name) }
|
||||||
.to change { Token.count }.by(-1)
|
.to change(Token, :count).by(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,6 +79,7 @@ RSpec.describe Token, type: :model do
|
||||||
|
|
||||||
describe 'permission matching' do
|
describe 'permission matching' do
|
||||||
subject(:token) { create(:api_token, user: agent, preferences: preferences) }
|
subject(:token) { create(:api_token, user: agent, preferences: preferences) }
|
||||||
|
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent_user) }
|
||||||
let(:preferences) { { permission: %w[admin ticket.agent] } } # agent has no access to admin.*
|
let(:preferences) { { permission: %w[admin ticket.agent] } } # agent has no access to admin.*
|
||||||
|
|
||||||
|
|
|
@ -3,30 +3,30 @@ require 'rails_helper'
|
||||||
RSpec.describe Translation do
|
RSpec.describe Translation do
|
||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
Translation.where(locale: 'de-de').destroy_all
|
described_class.where(locale: 'de-de').destroy_all
|
||||||
Translation.sync('de-de')
|
described_class.sync('de-de')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'default string translations' do
|
context 'default string translations' do
|
||||||
|
|
||||||
it 'en with existing word' do
|
it 'en with existing word' do
|
||||||
expect(Translation.translate('en', 'New')).to eq('New')
|
expect(described_class.translate('en', 'New')).to eq('New')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with existing word' do
|
it 'en-us with existing word' do
|
||||||
expect(Translation.translate('en-us', 'New')).to eq('New')
|
expect(described_class.translate('en-us', 'New')).to eq('New')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en with not existing word' do
|
it 'en with not existing word' do
|
||||||
expect(Translation.translate('en', 'Some Not Existing Word')).to eq('Some Not Existing Word')
|
expect(described_class.translate('en', 'Some Not Existing Word')).to eq('Some Not Existing Word')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with existing word' do
|
it 'de-de with existing word' do
|
||||||
expect(Translation.translate('de-de', 'New')).to eq('Neu')
|
expect(described_class.translate('de-de', 'New')).to eq('Neu')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with existing word' do
|
it 'de-de with not existing word' do
|
||||||
expect(Translation.translate('de-de', 'Some Not Existing Word')).to eq('Some Not Existing Word')
|
expect(described_class.translate('de-de', 'Some Not Existing Word')).to eq('Some Not Existing Word')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -34,39 +34,39 @@ RSpec.describe Translation do
|
||||||
context 'default timestamp translations' do
|
context 'default timestamp translations' do
|
||||||
|
|
||||||
it 'de-de with array' do
|
it 'de-de with array' do
|
||||||
expect(Translation.timestamp('de-de', 'Europe/Berlin', ['some value'])).to eq('["some value"]')
|
expect(described_class.timestamp('de-de', 'Europe/Berlin', ['some value'])).to eq('["some value"]')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with timestamp as string' do
|
it 'not_existing with timestamp as string' do
|
||||||
expect(Translation.timestamp('not_existing', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('2018-10-10 10:00:00 UTC')
|
expect(described_class.timestamp('not_existing', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('2018-10-10 10:00:00 UTC')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with time object' do
|
it 'not_existing with time object' do
|
||||||
expect(Translation.timestamp('not_existing', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('2018-10-10 10:00:00 UTC')
|
expect(described_class.timestamp('not_existing', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('2018-10-10 10:00:00 UTC')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with invalid timestamp string' do
|
it 'not_existing with invalid timestamp string' do
|
||||||
expect(Translation.timestamp('not_existing', 'Europe/Berlin', 'something')).to eq('something')
|
expect(described_class.timestamp('not_existing', 'Europe/Berlin', 'something')).to eq('something')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with invalid time zone' do
|
it 'en-us with invalid time zone' do
|
||||||
expect(Translation.timestamp('en-us', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('10/10/2018 12:00 (Europe/Berlin)')
|
expect(described_class.timestamp('en-us', 'Invalid/TimeZone', '2018-10-10T10:00:00Z0')).to eq(Time.zone.parse('2018-10-10T10:00:00Z0').to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with timestamp as string' do
|
it 'en-us with timestamp as string' do
|
||||||
expect(Translation.timestamp('en-us', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('10/10/2018 12:00 (Europe/Berlin)')
|
expect(described_class.timestamp('en-us', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('10/10/2018 12:00 (Europe/Berlin)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with time object' do
|
it 'en-us with time object' do
|
||||||
expect(Translation.timestamp('en-us', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('10/10/2018 12:00 (Europe/Berlin)')
|
expect(described_class.timestamp('en-us', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('10/10/2018 12:00 (Europe/Berlin)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with timestamp as string' do
|
it 'de-de with timestamp as string' do
|
||||||
expect(Translation.timestamp('de-de', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('10.10.2018 12:00 (Europe/Berlin)')
|
expect(described_class.timestamp('de-de', 'Europe/Berlin', '2018-10-10T10:00:00Z0')).to eq('10.10.2018 12:00 (Europe/Berlin)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with time object' do
|
it 'de-de with time object' do
|
||||||
expect(Translation.timestamp('de-de', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('10.10.2018 12:00 (Europe/Berlin)')
|
expect(described_class.timestamp('de-de', 'Europe/Berlin', Time.zone.parse('2018-10-10T10:00:00Z0'))).to eq('10.10.2018 12:00 (Europe/Berlin)')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -74,35 +74,35 @@ RSpec.describe Translation do
|
||||||
context 'default date translations' do
|
context 'default date translations' do
|
||||||
|
|
||||||
it 'de-de with array' do
|
it 'de-de with array' do
|
||||||
expect(Translation.date('de-de', ['some value'])).to eq('["some value"]')
|
expect(described_class.date('de-de', ['some value'])).to eq('["some value"]')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with date as string' do
|
it 'not_existing with date as string' do
|
||||||
expect(Translation.date('not_existing', '2018-10-10')).to eq('2018-10-10')
|
expect(described_class.date('not_existing', '2018-10-10')).to eq('2018-10-10')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with date object' do
|
it 'not_existing with date object' do
|
||||||
expect(Translation.date('not_existing', Date.parse('2018-10-10'))).to eq('2018-10-10')
|
expect(described_class.date('not_existing', Date.parse('2018-10-10'))).to eq('2018-10-10')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_existing with invalid data as string' do
|
it 'not_existing with invalid data as string' do
|
||||||
expect(Translation.date('not_existing', 'something')).to eq('something')
|
expect(described_class.date('not_existing', 'something')).to eq('something')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with date as string' do
|
it 'en-us with date as string' do
|
||||||
expect(Translation.date('en-us', '2018-10-10')).to eq('10/10/2018')
|
expect(described_class.date('en-us', '2018-10-10')).to eq('10/10/2018')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'en-us with date object' do
|
it 'en-us with date object' do
|
||||||
expect(Translation.date('en-us', Date.parse('2018-10-10'))).to eq('10/10/2018')
|
expect(described_class.date('en-us', Date.parse('2018-10-10'))).to eq('10/10/2018')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with date as string' do
|
it 'de-de with date as string' do
|
||||||
expect(Translation.date('de-de', '2018-10-10')).to eq('10.10.2018')
|
expect(described_class.date('de-de', '2018-10-10')).to eq('10.10.2018')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'de-de with date object' do
|
it 'de-de with date object' do
|
||||||
expect(Translation.date('de-de', Date.parse('2018-10-10'))).to eq('10.10.2018')
|
expect(described_class.date('de-de', Date.parse('2018-10-10'))).to eq('10.10.2018')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -110,10 +110,10 @@ RSpec.describe Translation do
|
||||||
context 'remote_translation_need_update? tests' do
|
context 'remote_translation_need_update? tests' do
|
||||||
|
|
||||||
it 'translation is still the same' do
|
it 'translation is still the same' do
|
||||||
translation = Translation.where(locale: 'de-de', format: 'string').last
|
translation = described_class.where(locale: 'de-de', format: 'string').last
|
||||||
translations = Translation.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
translations = described_class.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
||||||
expect(
|
expect(
|
||||||
Translation.remote_translation_need_update?(
|
described_class.remote_translation_need_update?(
|
||||||
{
|
{
|
||||||
'source' => translation.source,
|
'source' => translation.source,
|
||||||
'format' => translation.format,
|
'format' => translation.format,
|
||||||
|
@ -126,12 +126,12 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'translation target has locally changed' do
|
it 'translation target has locally changed' do
|
||||||
translation = Translation.where(locale: 'de-de', format: 'string').last
|
translation = described_class.where(locale: 'de-de', format: 'string').last
|
||||||
translation.target = 'some new translation'
|
translation.target = 'some new translation'
|
||||||
translation.save!
|
translation.save!
|
||||||
translations = Translation.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
translations = described_class.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
||||||
expect(
|
expect(
|
||||||
Translation.remote_translation_need_update?(
|
described_class.remote_translation_need_update?(
|
||||||
{
|
{
|
||||||
'source' => translation.source,
|
'source' => translation.source,
|
||||||
'format' => translation.format,
|
'format' => translation.format,
|
||||||
|
@ -144,9 +144,9 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'translation target has remotely changed' do
|
it 'translation target has remotely changed' do
|
||||||
translation = Translation.where(locale: 'de-de', format: 'string').last
|
translation = described_class.where(locale: 'de-de', format: 'string').last
|
||||||
translations = Translation.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
translations = described_class.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
||||||
(result, translation_result) = Translation.remote_translation_need_update?(
|
(result, translation_result) = described_class.remote_translation_need_update?(
|
||||||
{
|
{
|
||||||
'source' => translation.source,
|
'source' => translation.source,
|
||||||
'format' => translation.format,
|
'format' => translation.format,
|
||||||
|
@ -160,12 +160,12 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'translation target has remotely and locally changed' do
|
it 'translation target has remotely and locally changed' do
|
||||||
translation = Translation.where(locale: 'de-de', format: 'string').last
|
translation = described_class.where(locale: 'de-de', format: 'string').last
|
||||||
translation.target = 'some new translation'
|
translation.target = 'some new translation'
|
||||||
translation.save!
|
translation.save!
|
||||||
translations = Translation.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
translations = described_class.where(locale: 'de-de').pluck(:id, :locale, :source, :format, :target, :target_initial).to_a
|
||||||
expect(
|
expect(
|
||||||
Translation.remote_translation_need_update?(
|
described_class.remote_translation_need_update?(
|
||||||
{
|
{
|
||||||
'source' => translation.source,
|
'source' => translation.source,
|
||||||
'format' => translation.format,
|
'format' => translation.format,
|
||||||
|
@ -185,26 +185,26 @@ RSpec.describe Translation do
|
||||||
locale = 'de-de'
|
locale = 'de-de'
|
||||||
|
|
||||||
# check for non existing custom changes
|
# check for non existing custom changes
|
||||||
list = Translation.lang(locale)
|
list = described_class.lang(locale)
|
||||||
list['list'].each do |item|
|
list['list'].each do |item|
|
||||||
translation = Translation.find_by(source: item[1], locale: locale)
|
translation = described_class.find_by(source: item[1], locale: locale)
|
||||||
expect(translation.class).to be(Translation)
|
expect(translation.class).to be(described_class)
|
||||||
expect(locale).to eq(translation.locale)
|
expect(locale).to eq(translation.locale)
|
||||||
expect(translation.target).to eq(translation.target_initial)
|
expect(translation.target).to eq(translation.target_initial)
|
||||||
end
|
end
|
||||||
|
|
||||||
# add custom changes
|
# add custom changes
|
||||||
translation = Translation.find_by(locale: locale, source: 'open')
|
translation = described_class.find_by(locale: locale, source: 'open')
|
||||||
expect(translation.class).to be(Translation)
|
expect(translation.class).to be(described_class)
|
||||||
expect(translation.target).to eq('offen')
|
expect(translation.target).to eq('offen')
|
||||||
expect(translation.target_initial).to eq('offen')
|
expect(translation.target_initial).to eq('offen')
|
||||||
translation.target = 'offen2'
|
translation.target = 'offen2'
|
||||||
translation.save!
|
translation.save!
|
||||||
|
|
||||||
list = Translation.lang(locale)
|
list = described_class.lang(locale)
|
||||||
list['list'].each do |item|
|
list['list'].each do |item|
|
||||||
translation = Translation.find_by(source: item[1], locale: locale)
|
translation = described_class.find_by(source: item[1], locale: locale)
|
||||||
expect(translation.class).to be(Translation)
|
expect(translation.class).to be(described_class)
|
||||||
expect(locale).to eq(translation.locale)
|
expect(locale).to eq(translation.locale)
|
||||||
if translation.source == 'open'
|
if translation.source == 'open'
|
||||||
expect(translation.target).to eq('offen2')
|
expect(translation.target).to eq('offen2')
|
||||||
|
@ -215,11 +215,11 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
|
|
||||||
# check for existing custom changes after new translations are loaded
|
# check for existing custom changes after new translations are loaded
|
||||||
Translation.load(locale)
|
described_class.load(locale)
|
||||||
list = Translation.lang(locale)
|
list = described_class.lang(locale)
|
||||||
list['list'].each do |item|
|
list['list'].each do |item|
|
||||||
translation = Translation.find_by(source: item[1], locale: locale)
|
translation = described_class.find_by(source: item[1], locale: locale)
|
||||||
expect(translation.class).to be(Translation)
|
expect(translation.class).to be(described_class)
|
||||||
expect(locale).to eq(translation.locale)
|
expect(locale).to eq(translation.locale)
|
||||||
if translation.source == 'open'
|
if translation.source == 'open'
|
||||||
expect(translation.target).to eq('offen2')
|
expect(translation.target).to eq('offen2')
|
||||||
|
@ -230,11 +230,11 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
|
|
||||||
# reset custom translations and check for non existing custom changes
|
# reset custom translations and check for non existing custom changes
|
||||||
Translation.reset(locale)
|
described_class.reset(locale)
|
||||||
list = Translation.lang(locale)
|
list = described_class.lang(locale)
|
||||||
list['list'].each do |item|
|
list['list'].each do |item|
|
||||||
translation = Translation.find_by(source: item[1], locale: locale)
|
translation = described_class.find_by(source: item[1], locale: locale)
|
||||||
expect(translation.class).to be(Translation)
|
expect(translation.class).to be(described_class)
|
||||||
expect(locale).to eq(translation.locale)
|
expect(locale).to eq(translation.locale)
|
||||||
expect(translation.target).to eq(translation.target_initial)
|
expect(translation.target).to eq(translation.target_initial)
|
||||||
end
|
end
|
||||||
|
@ -265,7 +265,7 @@ RSpec.describe Translation do
|
||||||
end
|
end
|
||||||
file = Rails.root.join(directory, "#{locale}-#{version}.yml")
|
file = Rails.root.join(directory, "#{locale}-#{version}.yml")
|
||||||
expect(File.exist?(file)).to be false
|
expect(File.exist?(file)).to be false
|
||||||
Translation.fetch(locale)
|
described_class.fetch(locale)
|
||||||
expect(File.exist?(file)).to be true
|
expect(File.exist?(file)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -274,12 +274,12 @@ RSpec.describe Translation do
|
||||||
context 'sync duplicate tests' do
|
context 'sync duplicate tests' do
|
||||||
|
|
||||||
it 'check duplication of entries' do
|
it 'check duplication of entries' do
|
||||||
Translation.where(locale: 'de-de').destroy_all
|
described_class.where(locale: 'de-de').destroy_all
|
||||||
Translation.sync('de-de')
|
described_class.sync('de-de')
|
||||||
translation_count = Translation.where(locale: 'de-de').count
|
translation_count = described_class.where(locale: 'de-de').count
|
||||||
Translation.sync('de-de')
|
described_class.sync('de-de')
|
||||||
expect(
|
expect(
|
||||||
Translation.where(locale: 'de-de').count
|
described_class.where(locale: 'de-de').count
|
||||||
).to be translation_count
|
).to be translation_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ RSpec.describe Trigger do
|
||||||
|
|
||||||
triggered_article = Ticket::Article.last
|
triggered_article = Ticket::Article.last
|
||||||
|
|
||||||
expect(triggered_article.body.match?(/space between/)).to be_truthy
|
expect(triggered_article.body).to match(/space between/)
|
||||||
expect(triggered_article.body.match?(ticket.title)).to be_truthy
|
expect(triggered_article.body).to match(ticket.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,23 +2,16 @@ require 'rails_helper'
|
||||||
require 'models/application_model_examples'
|
require 'models/application_model_examples'
|
||||||
|
|
||||||
RSpec.describe Trigger, type: :model do
|
RSpec.describe Trigger, type: :model do
|
||||||
|
subject(:trigger) { create(:trigger, condition: condition, perform: perform) }
|
||||||
|
|
||||||
it_behaves_like 'ApplicationModel', can_assets: { selectors: %i[condition perform] }
|
it_behaves_like 'ApplicationModel', can_assets: { selectors: %i[condition perform] }
|
||||||
|
|
||||||
before { Trigger.destroy_all } # Default DB state includes three sample triggers
|
|
||||||
subject!(:trigger) { create(:trigger, condition: condition, perform: perform) }
|
|
||||||
|
|
||||||
describe '#assets (for supplying model data to front-end framework)' do
|
|
||||||
let(:condition) { { 'ticket.state_id' => { operator: 'is', value: 1 } } }
|
|
||||||
let(:perform) { { 'ticket.priority_id' => { value: 1 } } }
|
|
||||||
|
|
||||||
it 'returns a hash with asset attributes for objects referenced in #condition and #perform' do
|
|
||||||
expect(trigger.assets({}))
|
|
||||||
.to include(Ticket::State.first.assets({}))
|
|
||||||
.and include(Ticket::Priority.first.assets({}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Send-email triggers' do
|
describe 'Send-email triggers' do
|
||||||
|
before do
|
||||||
|
Trigger.destroy_all # Default DB state includes three sample triggers
|
||||||
|
trigger # create subject trigger
|
||||||
|
end
|
||||||
|
|
||||||
let(:perform) do
|
let(:perform) do
|
||||||
{
|
{
|
||||||
'notification.email' => {
|
'notification.email' => {
|
||||||
|
@ -39,18 +32,19 @@ RSpec.describe Trigger, type: :model do
|
||||||
|
|
||||||
it 'fires (without altering ticket state)' do
|
it 'fires (without altering ticket state)' do
|
||||||
expect { Observer::Transaction.commit }
|
expect { Observer::Transaction.commit }
|
||||||
.to change { Ticket::Article.count }.by(1)
|
.to change(Ticket::Article, :count).by(1)
|
||||||
.and not_change { ticket.reload.state.name }.from('new')
|
.and not_change { ticket.reload.state.name }.from('new')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when ticket is created via Channel::EmailParser.process' do
|
context 'when ticket is created via Channel::EmailParser.process' do
|
||||||
before { create(:email_address, groups: [Group.first]) }
|
before { create(:email_address, groups: [Group.first]) }
|
||||||
|
|
||||||
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
|
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail001.box')) }
|
||||||
|
|
||||||
it 'fires (without altering ticket state)' do
|
it 'fires (without altering ticket state)' do
|
||||||
expect { Channel::EmailParser.new.process({}, raw_email) }
|
expect { Channel::EmailParser.new.process({}, raw_email) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
.and change { Ticket::Article.count }.by(2)
|
.and change { Ticket::Article.count }.by(2)
|
||||||
|
|
||||||
expect(Ticket.last.state.name).to eq('new')
|
expect(Ticket.last.state.name).to eq('new')
|
||||||
|
@ -59,11 +53,12 @@ RSpec.describe Trigger, type: :model do
|
||||||
|
|
||||||
context 'when ticket is created via Channel::EmailParser.process with inline image' do
|
context 'when ticket is created via Channel::EmailParser.process with inline image' do
|
||||||
before { create(:email_address, groups: [Group.first]) }
|
before { create(:email_address, groups: [Group.first]) }
|
||||||
|
|
||||||
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
|
let(:raw_email) { File.read(Rails.root.join('test', 'data', 'mail', 'mail010.box')) }
|
||||||
|
|
||||||
it 'fires (without altering ticket state)' do
|
it 'fires (without altering ticket state)' do
|
||||||
expect { Channel::EmailParser.new.process({}, raw_email) }
|
expect { Channel::EmailParser.new.process({}, raw_email) }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
.and change { Ticket::Article.count }.by(2)
|
.and change { Ticket::Article.count }.by(2)
|
||||||
|
|
||||||
expect(Ticket.last.state.name).to eq('new')
|
expect(Ticket.last.state.name).to eq('new')
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe TypeLookup, type: :model do
|
||||||
|
|
||||||
it 'creates a new one with that name' do
|
it 'creates a new one with that name' do
|
||||||
expect { TypeLookup.by_name(name) }
|
expect { TypeLookup.by_name(name) }
|
||||||
.to change { TypeLookup.count }.by(1)
|
.to change(TypeLookup, :count).by(1)
|
||||||
|
|
||||||
expect(TypeLookup.last.name).to eq(name)
|
expect(TypeLookup.last.name).to eq(name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,12 @@ require 'models/concerns/can_lookup_examples'
|
||||||
require 'models/concerns/has_object_manager_attributes_validation_examples'
|
require 'models/concerns/has_object_manager_attributes_validation_examples'
|
||||||
|
|
||||||
RSpec.describe User, type: :model do
|
RSpec.describe User, type: :model do
|
||||||
|
subject(:user) { create(:user) }
|
||||||
|
|
||||||
|
let(:customer) { create(:customer_user) }
|
||||||
|
let(:agent) { create(:agent_user) }
|
||||||
|
let(:admin) { create(:admin_user) }
|
||||||
|
|
||||||
it_behaves_like 'ApplicationModel', can_assets: { associations: :organization }
|
it_behaves_like 'ApplicationModel', can_assets: { associations: :organization }
|
||||||
it_behaves_like 'HasGroups', group_access_factory: :agent_user
|
it_behaves_like 'HasGroups', group_access_factory: :agent_user
|
||||||
it_behaves_like 'HasRoles', group_access_factory: :agent_user
|
it_behaves_like 'HasRoles', group_access_factory: :agent_user
|
||||||
|
@ -18,14 +24,10 @@ RSpec.describe User, type: :model do
|
||||||
it_behaves_like 'CanLookup'
|
it_behaves_like 'CanLookup'
|
||||||
it_behaves_like 'HasObjectManagerAttributesValidation'
|
it_behaves_like 'HasObjectManagerAttributesValidation'
|
||||||
|
|
||||||
subject(:user) { create(:user) }
|
|
||||||
let(:admin) { create(:admin_user) }
|
|
||||||
let(:agent) { create(:agent_user) }
|
|
||||||
let(:customer) { create(:customer_user) }
|
|
||||||
|
|
||||||
describe 'Class methods:' do
|
describe 'Class methods:' do
|
||||||
describe '.authenticate' do
|
describe '.authenticate' do
|
||||||
subject(:user) { create(:user, password: password) }
|
subject(:user) { create(:user, password: password) }
|
||||||
|
|
||||||
let(:password) { Faker::Internet.password }
|
let(:password) { Faker::Internet.password }
|
||||||
|
|
||||||
context 'with valid credentials' do
|
context 'with valid credentials' do
|
||||||
|
@ -153,22 +155,26 @@ RSpec.describe User, type: :model do
|
||||||
it { is_expected.to respond_to(:max_login_failed?) }
|
it { is_expected.to respond_to(:max_login_failed?) }
|
||||||
|
|
||||||
context 'with "password_max_login_failed" setting' do
|
context 'with "password_max_login_failed" setting' do
|
||||||
before { Setting.set('password_max_login_failed', 5) }
|
before do
|
||||||
before { user.update(login_failed: 5) }
|
Setting.set('password_max_login_failed', 5)
|
||||||
|
user.update(login_failed: 5)
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns true once user’s #login_failed count exceeds the setting' do
|
it 'returns true once user’s #login_failed count exceeds the setting' do
|
||||||
expect { user.update(login_failed: 6) }
|
expect { user.update(login_failed: 6) }
|
||||||
.to change { user.max_login_failed? }.to(true)
|
.to change(user, :max_login_failed?).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without password_max_login_failed setting' do
|
context 'without password_max_login_failed setting' do
|
||||||
before { Setting.set('password_max_login_failed', nil) }
|
before do
|
||||||
before { user.update(login_failed: 0) }
|
Setting.set('password_max_login_failed', nil)
|
||||||
|
user.update(login_failed: 0)
|
||||||
|
end
|
||||||
|
|
||||||
it 'defaults to 0' do
|
it 'defaults to 0' do
|
||||||
expect { user.update(login_failed: 1) }
|
expect { user.update(login_failed: 1) }
|
||||||
.to change { user.max_login_failed? }.to(true)
|
.to change(user, :max_login_failed?).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -226,8 +232,6 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has designated substitute' do
|
context 'when user has designated substitute' do
|
||||||
let(:substitute) { create(:user) }
|
|
||||||
|
|
||||||
subject(:user) do
|
subject(:user) do
|
||||||
create(:user,
|
create(:user,
|
||||||
out_of_office: out_of_office,
|
out_of_office: out_of_office,
|
||||||
|
@ -236,6 +240,8 @@ RSpec.describe User, type: :model do
|
||||||
out_of_office_replacement_id: substitute.id,)
|
out_of_office_replacement_id: substitute.id,)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:substitute) { create(:user) }
|
||||||
|
|
||||||
context 'but is not out of office' do
|
context 'but is not out of office' do
|
||||||
let(:out_of_office) { false }
|
let(:out_of_office) { false }
|
||||||
|
|
||||||
|
@ -296,9 +302,10 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#by_reset_token' do
|
describe '#by_reset_token' do
|
||||||
let(:token) { create(:token_password_reset) }
|
|
||||||
subject(:user) { token.user }
|
subject(:user) { token.user }
|
||||||
|
|
||||||
|
let(:token) { create(:token_password_reset) }
|
||||||
|
|
||||||
context 'with a valid token' do
|
context 'with a valid token' do
|
||||||
it 'returns the matching user' do
|
it 'returns the matching user' do
|
||||||
expect(described_class.by_reset_token(token.name)).to eq(user)
|
expect(described_class.by_reset_token(token.name)).to eq(user)
|
||||||
|
@ -313,13 +320,14 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#password_reset_via_token' do
|
describe '#password_reset_via_token' do
|
||||||
let!(:token) { create(:token_password_reset) }
|
|
||||||
subject(:user) { token.user }
|
subject(:user) { token.user }
|
||||||
|
|
||||||
|
let!(:token) { create(:token_password_reset) }
|
||||||
|
|
||||||
it 'changes the password of the token user and destroys the token' do
|
it 'changes the password of the token user and destroys the token' do
|
||||||
expect { described_class.password_reset_via_token(token.name, Faker::Internet.password) }
|
expect { described_class.password_reset_via_token(token.name, Faker::Internet.password) }
|
||||||
.to change { user.reload.password }
|
.to change { user.reload.password }
|
||||||
.and change { Token.count }.by(-1)
|
.and change(Token, :count).by(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -419,6 +427,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'when a customer' do
|
context 'when a customer' do
|
||||||
subject(:user) { create(:customer_user, :with_org) }
|
subject(:user) { create(:customer_user, :with_org) }
|
||||||
|
|
||||||
let(:colleague) { create(:customer_user, organization: user.organization) }
|
let(:colleague) { create(:customer_user, organization: user.organization) }
|
||||||
|
|
||||||
context 'wants to read' do
|
context 'wants to read' do
|
||||||
|
@ -457,6 +466,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
describe '#permissions?' do
|
describe '#permissions?' do
|
||||||
subject(:user) { create(:user, roles: [role]) }
|
subject(:user) { create(:user, roles: [role]) }
|
||||||
|
|
||||||
let(:role) { create(:role, permissions: [permission]) }
|
let(:role) { create(:role, permissions: [permission]) }
|
||||||
let(:permission) { create(:permission, name: permission_name) }
|
let(:permission) { create(:permission, name: permission_name) }
|
||||||
|
|
||||||
|
@ -578,6 +588,7 @@ RSpec.describe User, type: :model do
|
||||||
describe '#permissions_with_child_ids' do
|
describe '#permissions_with_child_ids' do
|
||||||
context 'with privileges for a root permission (e.g., "foo", not "foo.bar")' do
|
context 'with privileges for a root permission (e.g., "foo", not "foo.bar")' do
|
||||||
subject(:user) { create(:user, roles: [role]) }
|
subject(:user) { create(:user, roles: [role]) }
|
||||||
|
|
||||||
let(:role) { create(:role, permissions: [permission]) }
|
let(:role) { create(:role, permissions: [permission]) }
|
||||||
let!(:permission) { create(:permission, name: 'foo') }
|
let!(:permission) { create(:permission, name: 'foo') }
|
||||||
let!(:child_permission) { create(:permission, name: 'foo.bar') }
|
let!(:child_permission) { create(:permission, name: 'foo.bar') }
|
||||||
|
@ -601,6 +612,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'with no #preferences[:locale]' do
|
context 'with no #preferences[:locale]' do
|
||||||
let(:preferences) { {} }
|
let(:preferences) { {} }
|
||||||
|
|
||||||
before { Setting.set('locale_default', 'foo') }
|
before { Setting.set('locale_default', 'foo') }
|
||||||
|
|
||||||
it 'returns the system-wide default locale' do
|
it 'returns the system-wide default locale' do
|
||||||
|
@ -683,7 +695,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
it 'is reset to 0 when password is updated' do
|
it 'is reset to 0 when password is updated' do
|
||||||
expect { user.update(password: Faker::Internet.password) }
|
expect { user.update(password: Faker::Internet.password) }
|
||||||
.to change { user.login_failed }.to(0)
|
.to change(user, :login_failed).to(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -693,7 +705,7 @@ RSpec.describe User, type: :model do
|
||||||
user.password = 'password'
|
user.password = 'password'
|
||||||
|
|
||||||
expect { user.save }
|
expect { user.save }
|
||||||
.to change { user.password }.to(PasswordHash.crypt('password'))
|
.to change(user, :password).to(PasswordHash.crypt('password'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -701,7 +713,7 @@ RSpec.describe User, type: :model do
|
||||||
it 'does not re-hash before saving' do
|
it 'does not re-hash before saving' do
|
||||||
user.password = "{sha2}#{Digest::SHA2.hexdigest('password')}"
|
user.password = "{sha2}#{Digest::SHA2.hexdigest('password')}"
|
||||||
|
|
||||||
expect { user.save }.not_to change { user.password }
|
expect { user.save }.not_to change(user, :password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -709,7 +721,7 @@ RSpec.describe User, type: :model do
|
||||||
it 'does not re-hash before saving' do
|
it 'does not re-hash before saving' do
|
||||||
user.password = PasswordHash.crypt('password')
|
user.password = PasswordHash.crypt('password')
|
||||||
|
|
||||||
expect { user.save }.not_to change { user.password }
|
expect { user.save }.not_to change(user, :password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -817,13 +829,14 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'and #email domain matches an existing Organization#domain' do
|
context 'and #email domain matches an existing Organization#domain' do
|
||||||
before { user.assign_attributes(email: 'user@example.com') }
|
before { user.assign_attributes(email: 'user@example.com') }
|
||||||
|
|
||||||
let(:organization) { create(:organization, domain: 'example.com') }
|
let(:organization) { create(:organization, domain: 'example.com') }
|
||||||
|
|
||||||
context 'and Organization#domain_assignment is false (default)' do
|
context 'and Organization#domain_assignment is false (default)' do
|
||||||
before { organization.update(domain_assignment: false) }
|
before { organization.update(domain_assignment: false) }
|
||||||
|
|
||||||
it 'remains nil' do
|
it 'remains nil' do
|
||||||
expect { user.save }.not_to change { user.organization }
|
expect { user.save }.not_to change(user, :organization)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -832,20 +845,21 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
it 'is automatically set to matching Organization' do
|
it 'is automatically set to matching Organization' do
|
||||||
expect { user.save }
|
expect { user.save }
|
||||||
.to change { user.organization }.to(organization)
|
.to change(user, :organization).to(organization)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and #email domain doesn’t match any Organization#domain' do
|
context 'and #email domain doesn’t match any Organization#domain' do
|
||||||
before { user.assign_attributes(email: 'user@example.net') }
|
before { user.assign_attributes(email: 'user@example.net') }
|
||||||
|
|
||||||
let(:organization) { create(:organization, domain: 'example.com') }
|
let(:organization) { create(:organization, domain: 'example.com') }
|
||||||
|
|
||||||
context 'and Organization#domain_assignment is true' do
|
context 'and Organization#domain_assignment is true' do
|
||||||
before { organization.update(domain_assignment: true) }
|
before { organization.update(domain_assignment: true) }
|
||||||
|
|
||||||
it 'remains nil' do
|
it 'remains nil' do
|
||||||
expect { user.save }.not_to change { user.organization }
|
expect { user.save }.not_to change(user, :organization)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -853,10 +867,12 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'when set on creation' do
|
context 'when set on creation' do
|
||||||
before { user.assign_attributes(organization: specified_organization) }
|
before { user.assign_attributes(organization: specified_organization) }
|
||||||
|
|
||||||
let(:specified_organization) { create(:organization, domain: 'example.net') }
|
let(:specified_organization) { create(:organization, domain: 'example.net') }
|
||||||
|
|
||||||
context 'and #email domain matches a DIFFERENT Organization#domain' do
|
context 'and #email domain matches a DIFFERENT Organization#domain' do
|
||||||
before { user.assign_attributes(email: 'user@example.com') }
|
before { user.assign_attributes(email: 'user@example.com') }
|
||||||
|
|
||||||
let!(:matching_organization) { create(:organization, domain: 'example.com') }
|
let!(:matching_organization) { create(:organization, domain: 'example.com') }
|
||||||
|
|
||||||
context 'and Organization#domain_assignment is true' do
|
context 'and Organization#domain_assignment is true' do
|
||||||
|
@ -864,7 +880,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
it 'is NOT automatically set to matching Organization' do
|
it 'is NOT automatically set to matching Organization' do
|
||||||
expect { user.save }
|
expect { user.save }
|
||||||
.not_to change { user.organization }.from(specified_organization)
|
.not_to change(user, :organization).from(specified_organization)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -886,14 +902,14 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
it 'grants agent creation' do
|
it 'grants agent creation' do
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent_user) }
|
||||||
.to change { current_agents.count }.by(1)
|
.to change(current_agents, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'grants role change' do
|
it 'grants role change' do
|
||||||
future_agent = create(:customer_user)
|
future_agent = create(:customer_user)
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to change { current_agents.count }.by(1)
|
.to change(current_agents, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'role updates' do
|
describe 'role updates' do
|
||||||
|
@ -924,7 +940,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent_user) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prevents role change' do
|
it 'prevents role change' do
|
||||||
|
@ -934,7 +950,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -945,14 +961,14 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
it 'grants agent creation' do
|
it 'grants agent creation' do
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent_user) }
|
||||||
.to change { current_agents.count }.by(1)
|
.to change(current_agents, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'grants role change' do
|
it 'grants role change' do
|
||||||
future_agent = create(:customer_user)
|
future_agent = create(:customer_user)
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to change { current_agents.count }.by(1)
|
.to change(current_agents, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'role updates' do
|
describe 'role updates' do
|
||||||
|
@ -983,7 +999,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent_user) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prevents role change' do
|
it 'prevents role change' do
|
||||||
|
@ -993,7 +1009,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1009,7 +1025,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { inactive_agent.update!(active: true) }
|
expect { inactive_agent.update!(active: true) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1023,7 +1039,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
expect { inactive_agent.update!(active: true) }
|
expect { inactive_agent.update!(active: true) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
.and change { current_agents.count }.by(0)
|
.and change(current_agents, :count).by(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1032,6 +1048,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
describe 'Touching associations on update:' do
|
describe 'Touching associations on update:' do
|
||||||
subject(:user) { create(:customer_user, organization: organization) }
|
subject(:user) { create(:customer_user, organization: organization) }
|
||||||
|
|
||||||
let(:organization) { create(:organization) }
|
let(:organization) { create(:organization) }
|
||||||
let(:other_customer) { create(:customer_user) }
|
let(:other_customer) { create(:customer_user) }
|
||||||
|
|
||||||
|
@ -1139,6 +1156,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'for incoming calls from the given user' do
|
context 'for incoming calls from the given user' do
|
||||||
subject(:user) { create(:user, phone: '1234567890') }
|
subject(:user) { create(:user, phone: '1234567890') }
|
||||||
|
|
||||||
let!(:logs) { create_list(:'cti/log', 5, :with_preferences, from: user.phone, direction: 'in') }
|
let!(:logs) { create_list(:'cti/log', 5, :with_preferences, from: user.phone, direction: 'in') }
|
||||||
|
|
||||||
context 'when updating #phone attribute' do
|
context 'when updating #phone attribute' do
|
||||||
|
|
|
@ -27,7 +27,7 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.id)
|
authenticated_as(admin_user, on_behalf_of: customer_user.id)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(customer_user.id).to eq(json_response['created_by_id'])
|
expect(customer_user.id).to eq(json_response['created_by_id'])
|
||||||
end
|
end
|
||||||
|
@ -47,14 +47,14 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.login)
|
authenticated_as(admin_user, on_behalf_of: customer_user.login)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
json_response_ticket = json_response
|
json_response_ticket = json_response
|
||||||
expect(json_response_ticket).to be_a_kind_of(Hash)
|
expect(json_response_ticket).to be_a_kind_of(Hash)
|
||||||
expect(customer_user.id).to eq(json_response_ticket['created_by_id'])
|
expect(customer_user.id).to eq(json_response_ticket['created_by_id'])
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/activity_stream?full=true', params: {}, as: :json
|
get '/api/v1/activity_stream?full=true', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
json_response_activity = json_response
|
json_response_activity = json_response
|
||||||
expect(json_response_activity).to be_a_kind_of(Hash)
|
expect(json_response_activity).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
expect(customer_user.id).to eq(ticket_created.created_by_id)
|
expect(customer_user.id).to eq(ticket_created.created_by_id)
|
||||||
|
|
||||||
get '/api/v1/activity_stream', params: {}, as: :json
|
get '/api/v1/activity_stream', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
json_response_activity = json_response
|
json_response_activity = json_response
|
||||||
expect(json_response_activity).to be_a_kind_of(Array)
|
expect(json_response_activity).to be_a_kind_of(Array)
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(customer_user.id).to eq(json_response['created_by_id'])
|
expect(customer_user.id).to eq(json_response['created_by_id'])
|
||||||
end
|
end
|
||||||
|
@ -119,8 +119,8 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: 99_449_494_949)
|
authenticated_as(admin_user, on_behalf_of: 99_449_494_949)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq("No such user '99449494949'")
|
expect(json_response['error']).to eq("No such user '99449494949'")
|
||||||
end
|
end
|
||||||
|
@ -138,8 +138,8 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(customer_user, on_behalf_of: admin_user.email)
|
authenticated_as(customer_user, on_behalf_of: admin_user.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq("Current user has no permission to use 'X-On-Behalf-Of'!")
|
expect(json_response['error']).to eq("Current user has no permission to use 'X-On-Behalf-Of'!")
|
||||||
end
|
end
|
||||||
|
@ -157,8 +157,8 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(@response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('No lookup value found for \'group\': "secret1234"')
|
expect(json_response['error']).to eq('No lookup value found for \'group\': "secret1234"')
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Api Auth', type: :request do
|
RSpec.describe 'Api Auth', type: :request do
|
||||||
|
|
||||||
around(:each) do |example|
|
around do |example|
|
||||||
orig = ActionController::Base.allow_forgery_protection
|
orig = ActionController::Base.allow_forgery_protection
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -30,14 +30,14 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API password access disabled!')
|
expect(json_response['error']).to eq('API password access disabled!')
|
||||||
|
|
||||||
Setting.set('api_password_access', true)
|
Setting.set('api_password_access', true)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -48,14 +48,14 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API password access disabled!')
|
expect(json_response['error']).to eq('API password access disabled!')
|
||||||
|
|
||||||
Setting.set('api_password_access', true)
|
Setting.set('api_password_access', true)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -66,14 +66,14 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API password access disabled!')
|
expect(json_response['error']).to eq('API password access disabled!')
|
||||||
|
|
||||||
Setting.set('api_password_access', true)
|
Setting.set('api_password_access', true)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -95,14 +95,14 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
|
|
||||||
Setting.set('api_token_access', false)
|
Setting.set('api_token_access', false)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API token access disabled!')
|
expect(json_response['error']).to eq('API token access disabled!')
|
||||||
|
|
||||||
Setting.set('api_token_access', true)
|
Setting.set('api_token_access', true)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
@ -112,7 +112,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized (token)!')
|
expect(json_response['error']).to eq('Not authorized (token)!')
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized (token)!')
|
expect(json_response['error']).to eq('Not authorized (token)!')
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_user.save!
|
admin_user.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('User is inactive!')
|
expect(json_response['error']).to eq('User is inactive!')
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('User is inactive!')
|
expect(json_response['error']).to eq('User is inactive!')
|
||||||
|
|
||||||
|
@ -144,12 +144,12 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_user.save!
|
admin_user.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
get '/api/v1/roles', params: {}, as: :json
|
get '/api/v1/roles', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized (token)!')
|
expect(json_response['error']).to eq('Not authorized (token)!')
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/roles', params: {}, as: :json
|
get '/api/v1/roles', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
|
@ -165,20 +165,20 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)}"
|
name = "some org name #{rand(999_999_999)}"
|
||||||
post '/api/v1/organizations', params: { name: name }, as: :json
|
post '/api/v1/organizations', params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)} - 2"
|
name = "some org name #{rand(999_999_999)} - 2"
|
||||||
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -187,20 +187,20 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)}"
|
name = "some org name #{rand(999_999_999)}"
|
||||||
post '/api/v1/organizations', params: { name: name }, as: :json
|
post '/api/v1/organizations', params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)} - 2"
|
name = "some org name #{rand(999_999_999)} - 2"
|
||||||
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -209,20 +209,20 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
admin_token.save!
|
admin_token.save!
|
||||||
|
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)}"
|
name = "some org name #{rand(999_999_999)}"
|
||||||
post '/api/v1/organizations', params: { name: name }, as: :json
|
post '/api/v1/organizations', params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)} - 2"
|
name = "some org name #{rand(999_999_999)} - 2"
|
||||||
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
put "/api/v1/organizations/#{json_response['id']}", params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq(name)
|
expect(json_response['name']).to eq(name)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -242,26 +242,26 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
|
|
||||||
Setting.set('api_token_access', false)
|
Setting.set('api_token_access', false)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API token access disabled!')
|
expect(json_response['error']).to eq('API token access disabled!')
|
||||||
|
|
||||||
Setting.set('api_token_access', true)
|
Setting.set('api_token_access', true)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)}"
|
name = "some org name #{rand(999_999_999)}"
|
||||||
post '/api/v1/organizations', params: { name: name }, as: :json
|
post '/api/v1/organizations', params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -278,26 +278,26 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
|
|
||||||
Setting.set('api_token_access', false)
|
Setting.set('api_token_access', false)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API token access disabled!')
|
expect(json_response['error']).to eq('API token access disabled!')
|
||||||
|
|
||||||
Setting.set('api_token_access', true)
|
Setting.set('api_token_access', true)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
|
||||||
name = "some org name #{rand(999_999_999)}"
|
name = "some org name #{rand(999_999_999)}"
|
||||||
post '/api/v1/organizations', params: { name: name }, as: :json
|
post '/api/v1/organizations', params: { name: name }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does token auth - invalid user - admin', last_admin_check: false do
|
it 'does token auth - invalid user - admin', last_admin_check: false do
|
||||||
|
@ -316,15 +316,15 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
|
|
||||||
Setting.set('api_token_access', false)
|
Setting.set('api_token_access', false)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('API token access disabled!')
|
expect(json_response['error']).to eq('API token access disabled!')
|
||||||
|
|
||||||
Setting.set('api_token_access', true)
|
Setting.set('api_token_access', true)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('User is inactive!')
|
expect(json_response['error']).to eq('User is inactive!')
|
||||||
end
|
end
|
||||||
|
@ -344,8 +344,8 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin_user, token: admin_token)
|
||||||
|
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized (token expired)!')
|
expect(json_response['error']).to eq('Not authorized (token expired)!')
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin_user, token: admin_token)
|
||||||
|
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
expect(response.header['Access-Control-Allow-Origin']).to eq('*')
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -384,12 +384,12 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
token = response.headers['CSRF-TOKEN']
|
token = response.headers['CSRF-TOKEN']
|
||||||
|
|
||||||
post '/api/v1/signin', params: { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' }, headers: { 'X-CSRF-Token' => token }
|
post '/api/v1/signin', params: { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' }, headers: { 'X-CSRF-Token' => token }
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}
|
get '/api/v1/sessions', params: {}
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.header.key?('Access-Control-Allow-Origin')).to be_falsey
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,43 +8,43 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 404
|
# 404
|
||||||
get '/not_existing_url', as: :json
|
get '/not_existing_url', as: :json
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('No route matches [GET] /not_existing_url')
|
expect(json_response['error']).to eq('No route matches [GET] /not_existing_url')
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/api/v1/organizations', as: :json
|
get '/api/v1/organizations', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
|
||||||
# 422
|
# 422
|
||||||
get '/tests/unprocessable_entity', as: :json
|
get '/tests/unprocessable_entity', as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('some error message')
|
expect(json_response['error']).to eq('some error message')
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/tests/not_authorized', as: :json
|
get '/tests/not_authorized', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('some error message')
|
expect(json_response['error']).to eq('some error message')
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/tests/ar_not_found', as: :json
|
get '/tests/ar_not_found', as: :json
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('some error message')
|
expect(json_response['error']).to eq('some error message')
|
||||||
|
|
||||||
# 500
|
# 500
|
||||||
get '/tests/standard_error', as: :json
|
get '/tests/standard_error', as: :json
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(:internal_server_error)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('some error message')
|
expect(json_response['error']).to eq('some error message')
|
||||||
|
|
||||||
# 422
|
# 422
|
||||||
get '/tests/argument_error', as: :json
|
get '/tests/argument_error', as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('some error message')
|
expect(json_response['error']).to eq('some error message')
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 404
|
# 404
|
||||||
get '/not_existing_url'
|
get '/not_existing_url'
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>404: Not Found</title>})
|
expect(response.body).to match(%r{<title>404: Not Found</title>})
|
||||||
expect(response.body).to match(%r{<h1>404: Requested resource was not found</h1>})
|
expect(response.body).to match(%r{<h1>404: Requested resource was not found</h1>})
|
||||||
|
@ -61,7 +61,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/api/v1/organizations'
|
get '/api/v1/organizations'
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>401: Unauthorized</title>})
|
expect(response.body).to match(%r{<title>401: Unauthorized</title>})
|
||||||
expect(response.body).to match(%r{<h1>401: Unauthorized</h1>})
|
expect(response.body).to match(%r{<h1>401: Unauthorized</h1>})
|
||||||
|
@ -69,7 +69,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 422
|
# 422
|
||||||
get '/tests/unprocessable_entity'
|
get '/tests/unprocessable_entity'
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>422: Unprocessable Entity</title>})
|
expect(response.body).to match(%r{<title>422: Unprocessable Entity</title>})
|
||||||
expect(response.body).to match(%r{<h1>422: The change you wanted was rejected.</h1>})
|
expect(response.body).to match(%r{<h1>422: The change you wanted was rejected.</h1>})
|
||||||
|
@ -77,7 +77,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/tests/not_authorized'
|
get '/tests/not_authorized'
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>401: Unauthorized</title>})
|
expect(response.body).to match(%r{<title>401: Unauthorized</title>})
|
||||||
expect(response.body).to match(%r{<h1>401: Unauthorized</h1>})
|
expect(response.body).to match(%r{<h1>401: Unauthorized</h1>})
|
||||||
|
@ -85,7 +85,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
get '/tests/ar_not_found'
|
get '/tests/ar_not_found'
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>404: Not Found</title>})
|
expect(response.body).to match(%r{<title>404: Not Found</title>})
|
||||||
expect(response.body).to match(%r{<h1>404: Requested resource was not found</h1>})
|
expect(response.body).to match(%r{<h1>404: Requested resource was not found</h1>})
|
||||||
|
@ -93,7 +93,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 500
|
# 500
|
||||||
get '/tests/standard_error'
|
get '/tests/standard_error'
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(:internal_server_error)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>500: Something went wrong</title>})
|
expect(response.body).to match(%r{<title>500: Something went wrong</title>})
|
||||||
expect(response.body).to match(%r{<h1>500: We're sorry, but something went wrong.</h1>})
|
expect(response.body).to match(%r{<h1>500: We're sorry, but something went wrong.</h1>})
|
||||||
|
@ -101,7 +101,7 @@ RSpec.describe 'Basics', type: :request do
|
||||||
|
|
||||||
# 422
|
# 422
|
||||||
get '/tests/argument_error'
|
get '/tests/argument_error'
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to match(/<html/)
|
expect(response.body).to match(/<html/)
|
||||||
expect(response.body).to match(%r{<title>422: Unprocessable Entity</title>})
|
expect(response.body).to match(%r{<title>422: Unprocessable Entity</title>})
|
||||||
expect(response.body).to match(%r{<h1>422: The change you wanted was rejected.</h1>})
|
expect(response.body).to match(%r{<h1>422: The change you wanted was rejected.</h1>})
|
||||||
|
|
|
@ -10,19 +10,19 @@ RSpec.describe 'Calendars', type: :request do
|
||||||
|
|
||||||
it 'does calendar index with nobody' do
|
it 'does calendar index with nobody' do
|
||||||
get '/api/v1/calendars', as: :json
|
get '/api/v1/calendars', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
|
||||||
get '/api/v1/calendars_init', as: :json
|
get '/api/v1/calendars_init', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
|
||||||
get '/api/v1/calendars/timezones', as: :json
|
get '/api/v1/calendars/timezones', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
@ -31,19 +31,19 @@ RSpec.describe 'Calendars', type: :request do
|
||||||
it 'does calendar index with admin' do
|
it 'does calendar index with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/calendars', as: :json
|
get '/api/v1/calendars', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response.count).to eq(1)
|
expect(json_response.count).to eq(1)
|
||||||
|
|
||||||
get '/api/v1/calendars?expand=true', as: :json
|
get '/api/v1/calendars?expand=true', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response.count).to eq(1)
|
expect(json_response.count).to eq(1)
|
||||||
|
|
||||||
get '/api/v1/calendars?full=true', as: :json
|
get '/api/v1/calendars?full=true', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['record_ids']).to be_truthy
|
expect(json_response['record_ids']).to be_truthy
|
||||||
|
@ -53,7 +53,7 @@ RSpec.describe 'Calendars', type: :request do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
get '/api/v1/calendars_init', as: :json
|
get '/api/v1/calendars_init', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['record_ids']).to be_truthy
|
expect(json_response['record_ids']).to be_truthy
|
||||||
expect(json_response['ical_feeds']).to be_truthy
|
expect(json_response['ical_feeds']).to be_truthy
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe 'Calendars', type: :request do
|
||||||
|
|
||||||
# timezones
|
# timezones
|
||||||
get '/api/v1/calendars/timezones', as: :json
|
get '/api/v1/calendars/timezones', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['timezones']).to be_a_kind_of(Hash)
|
expect(json_response['timezones']).to be_a_kind_of(Hash)
|
||||||
expect(json_response['timezones']['America/New_York']).to be_truthy
|
expect(json_response['timezones']['America/New_York']).to be_truthy
|
||||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 401 unauthorized' do
|
it 'returns 401 unauthorized' do
|
||||||
get '/api/v1/external_credentials', as: :json
|
get '/api/v1/external_credentials', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'authentication failed')
|
expect(json_response).to include('error' => 'authentication failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 401 unauthorized' do
|
it 'returns 401 unauthorized' do
|
||||||
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'authentication failed')
|
expect(json_response).to include('error' => 'authentication failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 401 unauthorized' do
|
it 'returns 401 unauthorized' do
|
||||||
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'authentication failed')
|
expect(json_response).to include('error' => 'authentication failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 401 unauthorized' do
|
it 'returns 401 unauthorized' do
|
||||||
get '/api/v1/external_credentials/facebook/callback', as: :json
|
get '/api/v1/external_credentials/facebook/callback', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'authentication failed')
|
expect(json_response).to include('error' => 'authentication failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'responds with an array of ExternalCredential records' do
|
it 'responds with an array of ExternalCredential records' do
|
||||||
get '/api/v1/external_credentials', as: :json
|
get '/api/v1/external_credentials', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to eq([])
|
expect(json_response).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'responds with an array of ExternalCredential records and their association data' do
|
it 'responds with an array of ExternalCredential records and their association data' do
|
||||||
get '/api/v1/external_credentials?expand=true', as: :json
|
get '/api/v1/external_credentials?expand=true', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to eq([])
|
expect(json_response).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
|
|
||||||
it 'returns 401 unauthorized with internal (Zammad) error' do
|
it 'returns 401 unauthorized with internal (Zammad) error' do
|
||||||
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'Not authorized (user)!')
|
expect(json_response).to include('error' => 'Not authorized (user)!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -83,7 +83,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 200 with internal (Zammad) error' do
|
it 'returns 200 with internal (Zammad) error' do
|
||||||
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => 'No application_id param!')
|
expect(json_response).to include('error' => 'No application_id param!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
post '/api/v1/external_credentials/facebook/app_verify', params: invalid_credentials, as: :json
|
post '/api/v1/external_credentials/facebook/app_verify', params: invalid_credentials, as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -107,7 +107,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
post '/api/v1/external_credentials/facebook/app_verify', as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -120,7 +120,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No facebook app configured!')
|
expect(json_response).to include('error' => 'No facebook app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -129,7 +129,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/facebook/link_account', params: invalid_credentials, as: :json
|
get '/api/v1/external_credentials/facebook/link_account', params: invalid_credentials, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No facebook app configured!')
|
expect(json_response).to include('error' => 'No facebook app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -142,7 +142,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
get '/api/v1/external_credentials/facebook/link_account', as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(:internal_server_error)
|
||||||
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -155,7 +155,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/facebook/callback', as: :json
|
get '/api/v1/external_credentials/facebook/callback', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No facebook app configured!')
|
expect(json_response).to include('error' => 'No facebook app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -164,7 +164,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/facebook/callback', params: invalid_credentials, as: :json
|
get '/api/v1/external_credentials/facebook/callback', params: invalid_credentials, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No facebook app configured!')
|
expect(json_response).to include('error' => 'No facebook app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -177,7 +177,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
get '/api/v1/external_credentials/facebook/callback', as: :json
|
get '/api/v1/external_credentials/facebook/callback', as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(:internal_server_error)
|
||||||
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
expect(json_response).to include('error' => 'type: OAuthException, code: 101, message: Error validating application. Cannot get application info due to a system error. [HTTP 400]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -197,7 +197,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
|
|
||||||
it 'returns 401 unauthorized with internal (Zammad) error' do
|
it 'returns 401 unauthorized with internal (Zammad) error' do
|
||||||
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'Not authorized (user)!')
|
expect(json_response).to include('error' => 'Not authorized (user)!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,7 +206,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 200 with internal (Zammad) error' do
|
it 'returns 200 with internal (Zammad) error' do
|
||||||
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => 'No consumer_key param!')
|
expect(json_response).to include('error' => 'No consumer_key param!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -217,7 +217,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
post '/api/v1/external_credentials/twitter/app_verify', params: invalid_credentials, as: :json
|
post '/api/v1/external_credentials/twitter/app_verify', params: invalid_credentials, as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => '401 Authorization Required')
|
expect(json_response).to include('error' => '401 Authorization Required')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -230,7 +230,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
post '/api/v1/external_credentials/twitter/app_verify', as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('error' => '401 Authorization Required')
|
expect(json_response).to include('error' => '401 Authorization Required')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -243,7 +243,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/twitter/link_account', as: :json
|
get '/api/v1/external_credentials/twitter/link_account', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No twitter app configured!')
|
expect(json_response).to include('error' => 'No twitter app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -252,7 +252,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/twitter/link_account', params: invalid_credentials, as: :json
|
get '/api/v1/external_credentials/twitter/link_account', params: invalid_credentials, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No twitter app configured!')
|
expect(json_response).to include('error' => 'No twitter app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -265,7 +265,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
get '/api/v1/external_credentials/twitter/link_account', as: :json
|
get '/api/v1/external_credentials/twitter/link_account', as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(:internal_server_error)
|
||||||
expect(json_response).to include('error' => '401 Authorization Required')
|
expect(json_response).to include('error' => '401 Authorization Required')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -278,7 +278,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/twitter/callback', as: :json
|
get '/api/v1/external_credentials/twitter/callback', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No twitter app configured!')
|
expect(json_response).to include('error' => 'No twitter app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -287,7 +287,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/twitter/callback', params: invalid_credentials, as: :json
|
get '/api/v1/external_credentials/twitter/callback', params: invalid_credentials, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No twitter app configured!')
|
expect(json_response).to include('error' => 'No twitter app configured!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -298,7 +298,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
it 'returns 422 unprocessable entity with internal (Zammad) error' do
|
||||||
get '/api/v1/external_credentials/twitter/callback', as: :json
|
get '/api/v1/external_credentials/twitter/callback', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => 'No request_token for session found!')
|
expect(json_response).to include('error' => 'No request_token for session found!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Form', type: :request, searchindex: true do
|
RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
configure_elasticsearch
|
configure_elasticsearch
|
||||||
rebuild_searchindex
|
rebuild_searchindex
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
|
|
||||||
it 'does get config call' do
|
it 'does get config call' do
|
||||||
post '/api/v1/form_config', params: {}, as: :json
|
post '/api/v1/form_config', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized')
|
expect(json_response['error']).to eq('Not authorized')
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
it 'does get config call' do
|
it 'does get config call' do
|
||||||
Setting.set('form_ticket_create', true)
|
Setting.set('form_ticket_create', true)
|
||||||
post '/api/v1/form_config', params: {}, as: :json
|
post '/api/v1/form_config', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized')
|
expect(json_response['error']).to eq('Not authorized')
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
fingerprint = SecureRandom.hex(40)
|
fingerprint = SecureRandom.hex(40)
|
||||||
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['enabled']).to eq(true)
|
expect(json_response['enabled']).to eq(true)
|
||||||
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
||||||
|
@ -38,12 +38,12 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
token = json_response['token']
|
token = json_response['token']
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized')
|
expect(json_response['error']).to eq('Not authorized')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_truthy
|
expect(json_response['errors']).to be_truthy
|
||||||
|
@ -53,7 +53,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
expect(json_response['errors']['body']).to eq('required')
|
expect(json_response['errors']['body']).to eq('required')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_truthy
|
expect(json_response['errors']).to be_truthy
|
||||||
|
@ -63,7 +63,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
expect(json_response['errors']['body']).to eq('required')
|
expect(json_response['errors']['body']).to eq('required')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_falsey
|
expect(json_response['errors']).to be_falsey
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_falsey
|
expect(json_response['errors']).to be_falsey
|
||||||
|
@ -86,7 +86,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
travel 20.hours
|
travel 20.hours
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test', body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
fingerprint = SecureRandom.hex(40)
|
fingerprint = SecureRandom.hex(40)
|
||||||
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['enabled']).to eq(true)
|
expect(json_response['enabled']).to eq(true)
|
||||||
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
||||||
|
@ -103,12 +103,12 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
token = json_response['token']
|
token = json_response['token']
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: 'invalid' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not authorized')
|
expect(json_response['error']).to eq('Not authorized')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_truthy
|
expect(json_response['errors']).to be_truthy
|
||||||
|
@ -118,7 +118,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
expect(json_response['errors']['body']).to eq('required')
|
expect(json_response['errors']['body']).to eq('required')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, email: 'some' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_truthy
|
expect(json_response['errors']).to be_truthy
|
||||||
|
@ -128,7 +128,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
expect(json_response['errors']['body']).to eq('required')
|
expect(json_response['errors']['body']).to eq('required')
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'somebody@somedomainthatisinvalid.com', title: 'test', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'somebody@somedomainthatisinvalid.com', title: 'test', body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_truthy
|
expect(json_response['errors']).to be_truthy
|
||||||
|
@ -143,7 +143,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
fingerprint = SecureRandom.hex(40)
|
fingerprint = SecureRandom.hex(40)
|
||||||
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
post '/api/v1/form_config', params: { fingerprint: fingerprint }, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['enabled']).to eq(true)
|
expect(json_response['enabled']).to eq(true)
|
||||||
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
expect(json_response['endpoint']).to eq('http://zammad.example.com/api/v1/form_submit')
|
||||||
|
@ -153,7 +153,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
(1..20).each do |count|
|
(1..20).each do |count|
|
||||||
travel 10.seconds
|
travel 10.seconds
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test#{count}", body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test#{count}", body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_falsey
|
expect(json_response['errors']).to be_falsey
|
||||||
|
@ -168,7 +168,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
sleep 10 # wait until elasticsearch is index
|
sleep 10 # wait until elasticsearch is index
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-last', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-last', body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_truthy
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
(1..20).each do |count|
|
(1..20).each do |count|
|
||||||
travel 10.seconds
|
travel 10.seconds
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test-2-#{count}", body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: "test-2-#{count}", body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['errors']).to be_falsey
|
expect(json_response['errors']).to be_falsey
|
||||||
|
@ -191,7 +191,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
sleep 10 # wait until elasticsearch is index
|
sleep 10 # wait until elasticsearch is index
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-2-last', body: 'hello' }, as: :json
|
post '/api/v1/form_submit', params: { fingerprint: fingerprint, token: token, name: 'Bob Smith', email: 'discard@znuny.com', title: 'test-2-last', body: 'hello' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_truthy
|
||||||
end
|
end
|
||||||
|
@ -216,7 +216,7 @@ RSpec.describe 'Form', type: :request, searchindex: true do
|
||||||
|
|
||||||
post '/api/v1/form_submit', params: params, as: :json
|
post '/api/v1/form_submit', params: params, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration Check MK', type: :request do
|
RSpec.describe 'Integration Check MK', type: :request do
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
token = SecureRandom.urlsafe_base64(16)
|
token = SecureRandom.urlsafe_base64(16)
|
||||||
Setting.set('check_mk_token', token)
|
Setting.set('check_mk_token', token)
|
||||||
Setting.set('check_mk_integration', true)
|
Setting.set('check_mk_integration', true)
|
||||||
|
@ -11,12 +11,12 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
it 'does fail without a token' do
|
it 'does fail without a token' do
|
||||||
post '/api/v1/integration/check_mk/', params: {}
|
post '/api/v1/integration/check_mk/', params: {}
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does fail with invalid token and feature enabled' do
|
it 'does fail with invalid token and feature enabled' do
|
||||||
post '/api/v1/integration/check_mk/invalid_token', params: {}
|
post '/api/v1/integration/check_mk/invalid_token', params: {}
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid token!')
|
expect(json_response['error']).to eq('Invalid token!')
|
||||||
|
@ -30,7 +30,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).not_to be_empty
|
expect(json_response['result']).not_to be_empty
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
@ -85,7 +85,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to eq('ticket already open, added note')
|
expect(json_response['result']).to eq('ticket already open, added note')
|
||||||
|
@ -102,7 +102,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
@ -121,7 +121,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to eq('no open tickets found, ignore action')
|
expect(json_response['result']).to eq('no open tickets found, ignore action')
|
||||||
|
@ -136,7 +136,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
@ -154,7 +154,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to eq('ticket already open, added note')
|
expect(json_response['result']).to eq('ticket already open, added note')
|
||||||
|
@ -171,7 +171,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to eq('ticket already open, added note')
|
expect(json_response['result']).to eq('ticket already open, added note')
|
||||||
|
@ -189,7 +189,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
host: 'some host',
|
host: 'some host',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
@ -206,7 +206,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
host: 'some host',
|
host: 'some host',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to eq('ticket already open, added note')
|
expect(json_response['result']).to eq('ticket already open, added note')
|
||||||
|
@ -222,7 +222,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
host: 'some host',
|
host: 'some host',
|
||||||
}
|
}
|
||||||
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
post "/api/v1/integration/check_mk/#{Setting.get('check_mk_token')}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result']).to be_truthy
|
expect(json_response['result']).to be_truthy
|
||||||
|
|
|
@ -36,7 +36,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Cti::Log.destroy_all
|
Cti::Log.destroy_all
|
||||||
|
|
||||||
Setting.set('cti_integration', true)
|
Setting.set('cti_integration', true)
|
||||||
|
@ -76,7 +76,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
it 'does token check' do
|
it 'does token check' do
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post '/api/v1/cti/not_existing_token', params: params
|
post '/api/v1/cti/not_existing_token', params: params
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid token, please contact your admin!')
|
expect(json_response['error']).to eq('Invalid token, please contact your admin!')
|
||||||
end
|
end
|
||||||
|
@ -87,7 +87,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - I
|
# inbound - I
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_blank
|
expect(json_response).to be_blank
|
||||||
|
@ -95,7 +95,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - II - block caller
|
# inbound - II - block caller
|
||||||
params = 'event=newCall&direction=in&from=491715000000&to=4930600000000&call_id=4991155921769858278-2&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=491715000000&to=4930600000000&call_id=4991155921769858278-2&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['action']).to eq('reject')
|
expect(json_response['action']).to eq('reject')
|
||||||
|
@ -104,7 +104,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - I - set default_caller_id
|
# outbound - I - set default_caller_id
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=8621106404543334274-3&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=8621106404543334274-3&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['action']).to eq('dial')
|
expect(json_response['action']).to eq('dial')
|
||||||
expect(json_response['number']).to eq('4912347114711')
|
expect(json_response['number']).to eq('4912347114711')
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - II - set caller_id based on routing_table by explicite number
|
# outbound - II - set caller_id based on routing_table by explicite number
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=491714000000&call_id=8621106404543334274-4&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=491714000000&call_id=8621106404543334274-4&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['action']).to eq('dial')
|
expect(json_response['action']).to eq('dial')
|
||||||
expect(json_response['number']).to eq('491714000000')
|
expect(json_response['number']).to eq('491714000000')
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - III - set caller_id based on routing_table by 41*
|
# outbound - III - set caller_id based on routing_table by 41*
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4147110000000&call_id=8621106404543334274-5&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4147110000000&call_id=8621106404543334274-5&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['action']).to eq('dial')
|
expect(json_response['action']).to eq('dial')
|
||||||
expect(json_response['number']).to eq('4147110000000')
|
expect(json_response['number']).to eq('4147110000000')
|
||||||
|
@ -132,7 +132,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
Setting.set('cti_config', {})
|
Setting.set('cti_config', {})
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-6&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&call_id=4991155921769858278-6&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Feature not configured, please contact your admin!')
|
expect(json_response['error']).to eq('Feature not configured, please contact your admin!')
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - I - new call
|
# outbound - I - new call
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=1234567890-1&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=1234567890-1&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -167,7 +167,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - I - hangup by agent
|
# outbound - I - hangup by agent
|
||||||
params = 'event=hangup&direction=out&call_id=1234567890-1&cause=cancel'
|
params = 'event=hangup&direction=out&call_id=1234567890-1&cause=cancel'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -188,7 +188,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - II - new call
|
# outbound - II - new call
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=1234567890-2&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&call_id=1234567890-2&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -211,7 +211,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - II - answer by customer
|
# outbound - II - answer by customer
|
||||||
params = 'event=answer&direction=out&call_id=1234567890-2&from=4930600000000&to=4912347114711'
|
params = 'event=answer&direction=out&call_id=1234567890-2&from=4930600000000&to=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -234,7 +234,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# outbound - II - hangup by customer
|
# outbound - II - hangup by customer
|
||||||
params = 'event=hangup&direction=out&call_id=1234567890-2&cause=normalClearing&from=4930600000000&to=4912347114711'
|
params = 'event=hangup&direction=out&call_id=1234567890-2&cause=normalClearing&from=4930600000000&to=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -257,7 +257,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - I - new call
|
# inbound - I - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-3&user%5B%5D=user+1'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-3&user%5B%5D=user+1'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -280,7 +280,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - I - answer by customer
|
# inbound - I - answer by customer
|
||||||
params = 'event=answer&direction=in&call_id=1234567890-3&to=4930600000000&from=4912347114711'
|
params = 'event=answer&direction=in&call_id=1234567890-3&to=4930600000000&from=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -303,7 +303,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - I - hangup by customer
|
# inbound - I - hangup by customer
|
||||||
params = 'event=hangup&direction=in&call_id=1234567890-3&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&call_id=1234567890-3&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -326,7 +326,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - II - new call
|
# inbound - II - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-4&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-4&user%5B%5D=user+1,user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -349,7 +349,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - II - answer by voicemail
|
# inbound - II - answer by voicemail
|
||||||
params = 'event=answer&direction=in&call_id=1234567890-4&to=4930600000000&from=4912347114711&user=voicemail'
|
params = 'event=answer&direction=in&call_id=1234567890-4&to=4930600000000&from=4912347114711&user=voicemail'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -372,7 +372,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - II - hangup by customer
|
# inbound - II - hangup by customer
|
||||||
params = 'event=hangup&direction=in&call_id=1234567890-4&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&call_id=1234567890-4&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -395,7 +395,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - III - new call
|
# inbound - III - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-5&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&call_id=1234567890-5&user%5B%5D=user+1,user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -418,7 +418,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - III - hangup by customer
|
# inbound - III - hangup by customer
|
||||||
params = 'event=hangup&direction=in&call_id=1234567890-5&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&call_id=1234567890-5&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -441,7 +441,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - IV - new call
|
# inbound - IV - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=49999992222222&call_id=1234567890-6&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=49999992222222&call_id=1234567890-6&user%5B%5D=user+1,user+2'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-6')
|
log = Cti::Log.find_by(call_id: '1234567890-6')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -466,7 +466,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - IV - new call
|
# inbound - IV - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-7&user%5B%5D=user+1,user+2&queue=some_queue_name'
|
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-7&user%5B%5D=user+1,user+2&queue=some_queue_name'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-7')
|
log = Cti::Log.find_by(call_id: '1234567890-7')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -488,11 +488,11 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
|
|
||||||
# get caller list
|
# get caller list
|
||||||
get '/api/v1/cti/log'
|
get '/api/v1/cti/log'
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['list']).to be_a_kind_of(Array)
|
expect(json_response['list']).to be_a_kind_of(Array)
|
||||||
expect(json_response['list'].count).to eq(7)
|
expect(json_response['list'].count).to eq(7)
|
||||||
expect(json_response['assets']).to be_truthy
|
expect(json_response['assets']).to be_truthy
|
||||||
|
@ -521,7 +521,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - queue & user
|
# inbound - queue & user
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-1&user%5B%5D=user+1,user+2&queue=some_queue_name'
|
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-1&user%5B%5D=user+1,user+2&queue=some_queue_name'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -544,7 +544,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
# inbound - queue & no user
|
# inbound - queue & no user
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-2&user%5B%5D=&queue=some_queue_name'
|
params = 'event=newCall&direction=in&to=4930600000000&from=anonymous&call_id=1234567890-2&user%5B%5D=&queue=some_queue_name'
|
||||||
post "/api/v1/cti/#{token}", params: params
|
post "/api/v1/cti/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
'https://idoit.example.com/i-doit/'
|
'https://idoit.example.com/i-doit/'
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Setting.set('idoit_integration', true)
|
Setting.set('idoit_integration', true)
|
||||||
Setting.set('idoit_config', {
|
Setting.set('idoit_config', {
|
||||||
api_token: token,
|
api_token: token,
|
||||||
|
@ -38,9 +38,9 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
|
||||||
stub_request(:post, "#{endpoint}src/jsonrpc.php")
|
stub_request(:post, "#{endpoint}src/jsonrpc.php")
|
||||||
|
@ -54,9 +54,9 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['result']).to eq('ok')
|
expect(json_response['result']).to eq('ok')
|
||||||
expect(json_response['response']).to be_truthy
|
expect(json_response['response']).to be_truthy
|
||||||
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
||||||
|
@ -68,9 +68,9 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
client_id: '',
|
client_id: '',
|
||||||
}
|
}
|
||||||
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
post '/api/v1/integration/idoit/verify', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['result']).to eq('ok')
|
expect(json_response['result']).to eq('ok')
|
||||||
expect(json_response['response']).to be_truthy
|
expect(json_response['response']).to be_truthy
|
||||||
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
||||||
|
@ -89,10 +89,10 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['result']).to eq('ok')
|
expect(json_response['result']).to eq('ok')
|
||||||
expect(json_response['response']).to be_truthy
|
expect(json_response['response']).to be_truthy
|
||||||
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
||||||
|
@ -105,10 +105,10 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['result']).to eq('ok')
|
expect(json_response['result']).to eq('ok')
|
||||||
expect(json_response['response']).to be_truthy
|
expect(json_response['response']).to be_truthy
|
||||||
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
||||||
|
@ -132,10 +132,10 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['result']).to eq('ok')
|
expect(json_response['result']).to eq('ok')
|
||||||
expect(json_response['response']).to be_truthy
|
expect(json_response['response']).to be_truthy
|
||||||
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
expect(json_response['response']['jsonrpc']).to eq('2.0')
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
SecureRandom.urlsafe_base64(64)
|
SecureRandom.urlsafe_base64(64)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Setting.set('monitoring_token', token)
|
Setting.set('monitoring_token', token)
|
||||||
|
|
||||||
# channel cleanup
|
# channel cleanup
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['healthy']).to be_falsey
|
expect(json_response['healthy']).to be_falsey
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get '/api/v1/monitoring/status', params: {}, as: :json
|
get '/api/v1/monitoring/status', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['agents']).to be_falsey
|
expect(json_response['agents']).to be_falsey
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: {}, as: :json
|
post '/api/v1/monitoring/token', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -79,7 +79,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get '/api/v1/monitoring/health_check?token=abc', params: {}, as: :json
|
get '/api/v1/monitoring/health_check?token=abc', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['healthy']).to be_falsey
|
expect(json_response['healthy']).to be_falsey
|
||||||
|
@ -87,7 +87,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get '/api/v1/monitoring/status?token=abc', params: {}, as: :json
|
get '/api/v1/monitoring/status?token=abc', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['agents']).to be_falsey
|
expect(json_response['agents']).to be_falsey
|
||||||
|
@ -98,7 +98,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: 'abc' }, as: :json
|
post '/api/v1/monitoring/token', params: { token: 'abc' }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -124,7 +124,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
|
@ -133,22 +133,22 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response.key?('agents')).to be_truthy
|
expect(json_response).to be_key('agents')
|
||||||
expect(json_response.key?('last_login')).to be_truthy
|
expect(json_response).to be_key('last_login')
|
||||||
expect(json_response.key?('counts')).to be_truthy
|
expect(json_response).to be_key('counts')
|
||||||
expect(json_response.key?('last_created_at')).to be_truthy
|
expect(json_response).to be_key('last_created_at')
|
||||||
|
|
||||||
first_json_response_kb = 0
|
first_json_response_kb = 0
|
||||||
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
||||||
expect(json_response['storage']).to be_truthy
|
expect(json_response['storage']).to be_truthy
|
||||||
expect(json_response['storage'].key?('kB')).to be_truthy
|
expect(json_response['storage']).to be_key('kB')
|
||||||
expect(json_response['storage']['kB']).to be > 0
|
expect(json_response['storage']['kB']).to be > 0
|
||||||
expect(json_response['storage'].key?('MB')).to be_truthy
|
expect(json_response['storage']).to be_key('MB')
|
||||||
expect(json_response['storage'].key?('GB')).to be_truthy
|
expect(json_response['storage']).to be_key('GB')
|
||||||
|
|
||||||
first_json_response_kb = json_response['storage']['kB']
|
first_json_response_kb = json_response['storage']['kB']
|
||||||
else
|
else
|
||||||
|
@ -166,23 +166,23 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response.key?('agents')).to be_truthy
|
expect(json_response).to be_key('agents')
|
||||||
expect(json_response.key?('last_login')).to be_truthy
|
expect(json_response).to be_key('last_login')
|
||||||
expect(json_response.key?('counts')).to be_truthy
|
expect(json_response).to be_key('counts')
|
||||||
expect(json_response.key?('last_created_at')).to be_truthy
|
expect(json_response).to be_key('last_created_at')
|
||||||
|
|
||||||
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
||||||
expect(json_response['storage']).to be_truthy
|
expect(json_response['storage']).to be_truthy
|
||||||
expect(json_response['storage'].key?('kB')).to be_truthy
|
expect(json_response['storage']).to be_key('kB')
|
||||||
|
|
||||||
# check if the stores got summarized. value should be the same because the file has the same fingerprint
|
# check if the stores got summarized. value should be the same because the file has the same fingerprint
|
||||||
expect(json_response['storage']['kB']).to eq(first_json_response_kb)
|
expect(json_response['storage']['kB']).to eq(first_json_response_kb)
|
||||||
expect(json_response['storage'].key?('MB')).to be_truthy
|
expect(json_response['storage']).to be_key('MB')
|
||||||
expect(json_response['storage'].key?('GB')).to be_truthy
|
expect(json_response['storage']).to be_key('GB')
|
||||||
else
|
else
|
||||||
expect(json_response['storage']).to be_falsey
|
expect(json_response['storage']).to be_falsey
|
||||||
end
|
end
|
||||||
|
@ -197,30 +197,30 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response.key?('agents')).to be_truthy
|
expect(json_response).to be_key('agents')
|
||||||
expect(json_response.key?('last_login')).to be_truthy
|
expect(json_response).to be_key('last_login')
|
||||||
expect(json_response.key?('counts')).to be_truthy
|
expect(json_response).to be_key('counts')
|
||||||
expect(json_response.key?('last_created_at')).to be_truthy
|
expect(json_response).to be_key('last_created_at')
|
||||||
|
|
||||||
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
||||||
expect(json_response['storage']).to be_truthy
|
expect(json_response['storage']).to be_truthy
|
||||||
expect(json_response['storage'].key?('kB')).to be_truthy
|
expect(json_response['storage']).to be_key('kB')
|
||||||
|
|
||||||
# check if the stores got summarized. value should be greather than the size of just one file (saved 2 times)
|
# check if the stores got summarized. value should be greather than the size of just one file (saved 2 times)
|
||||||
expect(json_response['storage']['kB']).to be > first_json_response_kb
|
expect(json_response['storage']['kB']).to be > first_json_response_kb
|
||||||
expect(json_response['storage'].key?('MB')).to be_truthy
|
expect(json_response['storage']).to be_key('MB')
|
||||||
expect(json_response['storage'].key?('GB')).to be_truthy
|
expect(json_response['storage']).to be_key('GB')
|
||||||
else
|
else
|
||||||
expect(json_response['storage']).to be_falsey
|
expect(json_response['storage']).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -233,7 +233,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
|
@ -242,18 +242,18 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get '/api/v1/monitoring/status', params: {}, as: :json
|
get '/api/v1/monitoring/status', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response.key?('agents')).to be_truthy
|
expect(json_response).to be_key('agents')
|
||||||
expect(json_response.key?('last_login')).to be_truthy
|
expect(json_response).to be_key('last_login')
|
||||||
expect(json_response.key?('counts')).to be_truthy
|
expect(json_response).to be_key('counts')
|
||||||
expect(json_response.key?('last_created_at')).to be_truthy
|
expect(json_response).to be_key('last_created_at')
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_truthy
|
expect(json_response['token']).to be_truthy
|
||||||
|
@ -267,7 +267,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['healthy']).to be_falsey
|
expect(json_response['healthy']).to be_falsey
|
||||||
|
@ -275,7 +275,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get '/api/v1/monitoring/status', params: {}, as: :json
|
get '/api/v1/monitoring/status', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['agents']).to be_falsey
|
expect(json_response['agents']).to be_falsey
|
||||||
|
@ -286,7 +286,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -303,7 +303,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['healthy']).to be_falsey
|
expect(json_response['healthy']).to be_falsey
|
||||||
|
@ -311,7 +311,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get '/api/v1/monitoring/status', params: {}, as: :json
|
get '/api/v1/monitoring/status', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['agents']).to be_falsey
|
expect(json_response['agents']).to be_falsey
|
||||||
|
@ -322,7 +322,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -340,7 +340,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
|
@ -349,18 +349,18 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# status
|
# status
|
||||||
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/status?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response.key?('agents')).to be_truthy
|
expect(json_response).to be_key('agents')
|
||||||
expect(json_response.key?('last_login')).to be_truthy
|
expect(json_response).to be_key('last_login')
|
||||||
expect(json_response.key?('counts')).to be_truthy
|
expect(json_response).to be_key('counts')
|
||||||
expect(json_response.key?('last_created_at')).to be_truthy
|
expect(json_response).to be_key('last_created_at')
|
||||||
|
|
||||||
# token
|
# token
|
||||||
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
post '/api/v1/monitoring/token', params: { token: token }, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['token']).to be_falsey
|
expect(json_response['token']).to be_falsey
|
||||||
|
@ -381,7 +381,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check - channel
|
# health_check - channel
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -396,7 +396,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
scheduler.save!
|
scheduler.save!
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -411,7 +411,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
scheduler.save!
|
scheduler.save!
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -431,7 +431,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
total_jobs = Delayed::Job.count
|
total_jobs = Delayed::Job.count
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -446,7 +446,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -463,7 +463,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
FileUtils.touch("#{dir}/test.eml")
|
FileUtils.touch("#{dir}/test.eml")
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -483,7 +483,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
)
|
)
|
||||||
|
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -501,7 +501,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -515,7 +515,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
it 'does check restart_failed_jobs' do
|
it 'does check restart_failed_jobs' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/monitoring/restart_failed_jobs', params: {}, as: :json
|
post '/api/v1/monitoring/restart_failed_jobs', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does check failed delayed job', db_strategy: :reset do
|
it 'does check failed delayed job', db_strategy: :reset do
|
||||||
|
@ -574,7 +574,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
expect(true).to eq(migration)
|
expect(true).to eq(migration)
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect('test4').to eq(json_response['name'])
|
expect('test4').to eq(json_response['name'])
|
||||||
|
@ -590,7 +590,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -604,7 +604,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -625,7 +625,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -644,7 +644,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
get "/api/v1/monitoring/health_check?token=#{token}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['message']).to be_truthy
|
expect(json_response['message']).to be_truthy
|
||||||
|
@ -661,7 +661,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
# amount_check - ok
|
# amount_check - ok
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response.key?('state')).to eq(false)
|
expect(json_response.key?('state')).to eq(false)
|
||||||
|
@ -675,7 +675,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&min_warning=10&min_critical=8", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&min_warning=10&min_critical=8", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('critical')
|
expect(json_response['state']).to eq('critical')
|
||||||
|
@ -683,7 +683,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['count']).to eq(6)
|
expect(json_response['count']).to eq(6)
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&min_warning=7&min_critical=2", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&min_warning=7&min_critical=2", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('warning')
|
expect(json_response['state']).to eq('warning')
|
||||||
|
@ -691,7 +691,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['count']).to eq(6)
|
expect(json_response['count']).to eq(6)
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('ok')
|
expect(json_response['state']).to eq('ok')
|
||||||
|
@ -704,7 +704,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('warning')
|
expect(json_response['state']).to eq('warning')
|
||||||
|
@ -717,7 +717,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=10&max_critical=20", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('critical')
|
expect(json_response['state']).to eq('critical')
|
||||||
|
@ -725,7 +725,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['count']).to eq(22)
|
expect(json_response['count']).to eq(22)
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=30", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=30", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('ok')
|
expect(json_response['state']).to eq('ok')
|
||||||
|
@ -733,7 +733,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['count']).to eq(22)
|
expect(json_response['count']).to eq(22)
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response.key?('state')).to eq(false)
|
expect(json_response.key?('state')).to eq(false)
|
||||||
|
@ -743,7 +743,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
travel 2.hours
|
travel 2.hours
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=30", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h&max_warning=30", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['state']).to eq('ok')
|
expect(json_response['state']).to eq('ok')
|
||||||
|
@ -751,7 +751,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['count']).to eq(0)
|
expect(json_response['count']).to eq(0)
|
||||||
|
|
||||||
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
get "/api/v1/monitoring/amount_check?token=#{token}&periode=1h", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response.key?('state')).to eq(false)
|
expect(json_response.key?('state')).to eq(false)
|
||||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to eq(true)
|
expect(json_response['data_option']['null']).to eq(true)
|
||||||
|
@ -96,7 +96,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to eq(true)
|
expect(json_response['data_option']['null']).to eq(true)
|
||||||
|
@ -152,7 +152,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
# update the object
|
# update the object
|
||||||
put "/api/v1/object_manager_attributes/#{object.id}", params: params, as: :json
|
put "/api/v1/object_manager_attributes/#{object.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect(json_response['name']).to eq('test4')
|
expect(json_response['name']).to eq('test4')
|
||||||
|
@ -201,7 +201,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to eq(true)
|
expect(json_response['data_option']['null']).to eq(true)
|
||||||
|
@ -261,7 +261,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to be_truthy
|
expect(json_response['data_option']['null']).to be_truthy
|
||||||
expect(json_response['data_option']['null']).to eq(true)
|
expect(json_response['data_option']['null']).to eq(true)
|
||||||
|
@ -330,7 +330,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
# update the object
|
# update the object
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
put "/api/v1/object_manager_attributes/#{object.id}", params: params, as: :json
|
put "/api/v1/object_manager_attributes/#{object.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['options']).to be_truthy
|
expect(json_response['data_option']['options']).to be_truthy
|
||||||
expect(json_response['name']).to eq('test7')
|
expect(json_response['name']).to eq('test7')
|
||||||
|
@ -380,7 +380,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
expect(migration).to eq(true)
|
expect(migration).to eq(true)
|
||||||
|
|
||||||
expect(response).to have_http_status(201) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['default']).to be_truthy
|
expect(json_response['data_option']['default']).to be_truthy
|
||||||
|
@ -430,7 +430,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
expect(migration).to eq(true)
|
expect(migration).to eq(true)
|
||||||
|
|
||||||
expect(response).to have_http_status(201) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['default']).to be_falsey
|
expect(json_response['data_option']['default']).to be_falsey
|
||||||
|
@ -514,20 +514,20 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
if Overview.where('name like ?', '%test%').empty?
|
if Overview.where('name like ?', '%test%').empty?
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('test_overview').to eq(json_response['name'])
|
expect('test_overview').to eq(json_response['name'])
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3. attempt to delete the ticket attribute
|
# 3. attempt to delete the ticket attribute
|
||||||
get '/api/v1/object_manager_attributes', as: :json
|
get '/api/v1/object_manager_attributes', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'Ticket' }
|
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'Ticket' }
|
||||||
expect(target_attribute.size).to eq(1)
|
expect(target_attribute.size).to eq(1)
|
||||||
target_id = target_attribute[0]['id']
|
target_id = target_attribute[0]['id']
|
||||||
|
|
||||||
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to include('Overview')
|
expect(response.body).to include('Overview')
|
||||||
expect(response.body).to include('test_overview')
|
expect(response.body).to include('test_overview')
|
||||||
expect(response.body).to include('cannot be deleted!')
|
expect(response.body).to include('cannot be deleted!')
|
||||||
|
@ -600,20 +600,20 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
if Trigger.where('name like ?', '%test%').empty?
|
if Trigger.where('name like ?', '%test%').empty?
|
||||||
post '/api/v1/triggers', params: params, as: :json
|
post '/api/v1/triggers', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('test_trigger').to eq(json_response['name'])
|
expect('test_trigger').to eq(json_response['name'])
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3. attempt to delete the ticket attribute
|
# 3. attempt to delete the ticket attribute
|
||||||
get '/api/v1/object_manager_attributes', as: :json
|
get '/api/v1/object_manager_attributes', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_a_trigger' && x['object'] == 'Ticket' }
|
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_a_trigger' && x['object'] == 'Ticket' }
|
||||||
expect(target_attribute.size).to eq(1)
|
expect(target_attribute.size).to eq(1)
|
||||||
target_id = target_attribute[0]['id']
|
target_id = target_attribute[0]['id']
|
||||||
|
|
||||||
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to include('Trigger')
|
expect(response.body).to include('Trigger')
|
||||||
expect(response.body).to include('test_trigger')
|
expect(response.body).to include('test_trigger')
|
||||||
expect(response.body).to include('cannot be deleted!')
|
expect(response.body).to include('cannot be deleted!')
|
||||||
|
@ -733,20 +733,20 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
if Job.where('name like ?', '%test%').empty?
|
if Job.where('name like ?', '%test%').empty?
|
||||||
post '/api/v1/jobs', params: params, as: :json
|
post '/api/v1/jobs', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('test_scheduler').to eq(json_response['name'])
|
expect('test_scheduler').to eq(json_response['name'])
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3. attempt to delete the ticket attribute
|
# 3. attempt to delete the ticket attribute
|
||||||
get '/api/v1/object_manager_attributes', as: :json
|
get '/api/v1/object_manager_attributes', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_a_scheduler' && x['object'] == 'Ticket' }
|
target_attribute = json_response.select { |x| x['name'] == 'test_attribute_referenced_by_a_scheduler' && x['object'] == 'Ticket' }
|
||||||
expect(target_attribute.size).to eq(1)
|
expect(target_attribute.size).to eq(1)
|
||||||
target_id = target_attribute[0]['id']
|
target_id = target_attribute[0]['id']
|
||||||
|
|
||||||
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to include('Job')
|
expect(response.body).to include('Job')
|
||||||
expect(response.body).to include('test_scheduler')
|
expect(response.body).to include('test_scheduler')
|
||||||
expect(response.body).to include('cannot be deleted!')
|
expect(response.body).to include('cannot be deleted!')
|
||||||
|
@ -866,14 +866,14 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
if Overview.where('name like ?', '%test%').empty?
|
if Overview.where('name like ?', '%test%').empty?
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('test_overview').to eq(json_response['name'])
|
expect('test_overview').to eq(json_response['name'])
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3. attempt to delete the ticket attribute
|
# 3. attempt to delete the ticket attribute
|
||||||
get '/api/v1/object_manager_attributes', as: :json
|
get '/api/v1/object_manager_attributes', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
all_json_response = json_response
|
all_json_response = json_response
|
||||||
|
|
||||||
target_attribute = all_json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'User' }
|
target_attribute = all_json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'User' }
|
||||||
|
@ -881,14 +881,14 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
target_id = target_attribute[0]['id']
|
target_id = target_attribute[0]['id']
|
||||||
|
|
||||||
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
target_attribute = all_json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'Ticket' }
|
target_attribute = all_json_response.select { |x| x['name'] == 'test_attribute_referenced_by_an_overview' && x['object'] == 'Ticket' }
|
||||||
expect(target_attribute.size).to eq(1)
|
expect(target_attribute.size).to eq(1)
|
||||||
target_id = target_attribute[0]['id']
|
target_id = target_attribute[0]['id']
|
||||||
|
|
||||||
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
delete "/api/v1/object_manager_attributes/#{target_id}", as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to include('Overview')
|
expect(response.body).to include('Overview')
|
||||||
expect(response.body).to include('test_overview')
|
expect(response.body).to include('test_overview')
|
||||||
expect(response.body).to include('cannot be deleted!')
|
expect(response.body).to include('cannot be deleted!')
|
||||||
|
@ -937,7 +937,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(201) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['default']).to be_falsey
|
expect(json_response['data_option']['default']).to be_falsey
|
||||||
|
@ -955,7 +955,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
}
|
}
|
||||||
|
|
||||||
put "/api/v1/object_manager_attributes/#{json_response['id']}", params: params, as: :json
|
put "/api/v1/object_manager_attributes/#{json_response['id']}", params: params, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_truthy
|
||||||
|
|
||||||
|
@ -999,7 +999,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(201) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['default']).to eq('test')
|
expect(json_response['data_option']['default']).to eq('test')
|
||||||
|
@ -1019,7 +1019,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
put "/api/v1/object_manager_attributes/#{json_response['id']}", params: params, as: :json
|
put "/api/v1/object_manager_attributes/#{json_response['id']}", params: params, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['data_option']['default']).to eq('test')
|
expect(json_response['data_option']['default']).to eq('test')
|
||||||
expect(json_response['data_option_new']['default']).to eq('fuu')
|
expect(json_response['data_option_new']['default']).to eq('fuu')
|
||||||
|
|
|
@ -36,7 +36,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Cti::Log.destroy_all
|
Cti::Log.destroy_all
|
||||||
|
|
||||||
Setting.set('placetel_integration', true)
|
Setting.set('placetel_integration', true)
|
||||||
|
@ -76,7 +76,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
it 'does token check' do
|
it 'does token check' do
|
||||||
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-1'
|
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-1'
|
||||||
post '/api/v1/placetel/not_existing_token', params: params
|
post '/api/v1/placetel/not_existing_token', params: params
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
error = nil
|
error = nil
|
||||||
local_response = REXML::Document.new(response.body)
|
local_response = REXML::Document.new(response.body)
|
||||||
|
@ -92,7 +92,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - I
|
# inbound - I
|
||||||
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-1'
|
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-1'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
local_response = REXML::Document.new(response.body)
|
local_response = REXML::Document.new(response.body)
|
||||||
expect(local_response.elements.count).to eq(1)
|
expect(local_response.elements.count).to eq(1)
|
||||||
|
@ -101,7 +101,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - II - block caller
|
# inbound - II - block caller
|
||||||
params = 'event=IncomingCall&from=491715000000&to=030600000000&call_id=4991155921769858278-2'
|
params = 'event=IncomingCall&from=491715000000&to=030600000000&call_id=4991155921769858278-2'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
local_response = REXML::Document.new(response.body)
|
local_response = REXML::Document.new(response.body)
|
||||||
reason = nil
|
reason = nil
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - I - set default_caller_id
|
# outbound - I - set default_caller_id
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=8621106404543334274-3'
|
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=8621106404543334274-3'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
number_to_dail = nil
|
number_to_dail = nil
|
||||||
|
@ -130,7 +130,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - II - set caller_id based on routing_table by explicite number
|
# outbound - II - set caller_id based on routing_table by explicite number
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=491714000000&call_id=8621106404543334274-4'
|
params = 'event=newCall&direction=out&from=030600000000&to=491714000000&call_id=8621106404543334274-4'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
number_to_dail = nil
|
number_to_dail = nil
|
||||||
|
@ -147,7 +147,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - III - set caller_id based on routing_table by 41*
|
# outbound - III - set caller_id based on routing_table by 41*
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=4147110000000&call_id=8621106404543334274-5'
|
params = 'event=newCall&direction=out&from=030600000000&to=4147110000000&call_id=8621106404543334274-5'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
number_to_dail = nil
|
number_to_dail = nil
|
||||||
|
@ -165,7 +165,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
Setting.set('placetel_config', {})
|
Setting.set('placetel_config', {})
|
||||||
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-6'
|
params = 'event=IncomingCall&from=01114100300&to=030600000000&call_id=4991155921769858278-6'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
|
||||||
error = nil
|
error = nil
|
||||||
local_response = REXML::Document.new(response.body)
|
local_response = REXML::Document.new(response.body)
|
||||||
|
@ -181,7 +181,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - I - new call
|
# outbound - I - new call
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-1'
|
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-1'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -203,7 +203,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - I - hangup by agent
|
# outbound - I - hangup by agent
|
||||||
params = 'event=HungUp&call_id=1234567890-1&type=missed'
|
params = 'event=HungUp&call_id=1234567890-1&type=missed'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -225,7 +225,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - II - new call
|
# outbound - II - new call
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-2'
|
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-2'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -247,7 +247,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - II - answer by customer
|
# outbound - II - answer by customer
|
||||||
params = 'event=CallAccepted&call_id=1234567890-2&from=030600000000&to=01114100300'
|
params = 'event=CallAccepted&call_id=1234567890-2&from=030600000000&to=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -269,7 +269,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - II - hangup by customer
|
# outbound - II - hangup by customer
|
||||||
params = 'event=HungUp&call_id=1234567890-2&type=accepted&from=030600000000&to=01114100300'
|
params = 'event=HungUp&call_id=1234567890-2&type=accepted&from=030600000000&to=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -291,7 +291,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - I - new call
|
# inbound - I - new call
|
||||||
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-3'
|
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-3'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -313,7 +313,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - I - answer by customer
|
# inbound - I - answer by customer
|
||||||
params = 'event=CallAccepted&call_id=1234567890-3&to=030600000000&from=01114100300'
|
params = 'event=CallAccepted&call_id=1234567890-3&to=030600000000&from=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -335,7 +335,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - I - hangup by customer
|
# inbound - I - hangup by customer
|
||||||
params = 'event=HungUp&call_id=1234567890-3&type=accepted&to=030600000000&from=01114100300'
|
params = 'event=HungUp&call_id=1234567890-3&type=accepted&to=030600000000&from=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -357,7 +357,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - II - new call
|
# inbound - II - new call
|
||||||
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-4'
|
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-4'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -379,7 +379,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - II - answer by voicemail
|
# inbound - II - answer by voicemail
|
||||||
params = 'event=CallAccepted&call_id=1234567890-4&to=030600000000&from=01114100300&user=voicemail'
|
params = 'event=CallAccepted&call_id=1234567890-4&to=030600000000&from=01114100300&user=voicemail'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -401,7 +401,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - II - hangup by customer
|
# inbound - II - hangup by customer
|
||||||
params = 'event=HungUp&call_id=1234567890-4&type=accepted&to=030600000000&from=01114100300'
|
params = 'event=HungUp&call_id=1234567890-4&type=accepted&to=030600000000&from=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -423,7 +423,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - III - new call
|
# inbound - III - new call
|
||||||
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-5'
|
params = 'event=IncomingCall&to=030600000000&from=01114100300&call_id=1234567890-5'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -445,7 +445,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - III - hangup by customer
|
# inbound - III - hangup by customer
|
||||||
params = 'event=HungUp&call_id=1234567890-5&type=accepted&to=030600000000&from=01114100300'
|
params = 'event=HungUp&call_id=1234567890-5&type=accepted&to=030600000000&from=01114100300'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -467,7 +467,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - IV - new call
|
# inbound - IV - new call
|
||||||
params = 'event=IncomingCall&to=030600000000&from=49999992222222&call_id=1234567890-6'
|
params = 'event=IncomingCall&to=030600000000&from=49999992222222&call_id=1234567890-6'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-6')
|
log = Cti::Log.find_by(call_id: '1234567890-6')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -491,7 +491,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# inbound - IV - new call
|
# inbound - IV - new call
|
||||||
params = 'event=IncomingCall&to=030600000000&from=anonymous&call_id=1234567890-7'
|
params = 'event=IncomingCall&to=030600000000&from=anonymous&call_id=1234567890-7'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-7')
|
log = Cti::Log.find_by(call_id: '1234567890-7')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('030600000000')
|
expect(log.to).to eq('030600000000')
|
||||||
|
@ -512,11 +512,11 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
|
|
||||||
# get caller list
|
# get caller list
|
||||||
get '/api/v1/cti/log'
|
get '/api/v1/cti/log'
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['list']).to be_a_kind_of(Array)
|
expect(json_response['list']).to be_a_kind_of(Array)
|
||||||
expect(json_response['list'].count).to eq(7)
|
expect(json_response['list'].count).to eq(7)
|
||||||
expect(json_response['assets']).to be_truthy
|
expect(json_response['assets']).to be_truthy
|
||||||
|
@ -545,7 +545,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
# outbound - I - new call
|
# outbound - I - new call
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-1&peer=something@example.com'
|
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-1&peer=something@example.com'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -571,7 +571,7 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
|
|
||||||
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-2&peer=777008478072@example.com'
|
params = 'event=newCall&direction=out&from=030600000000&to=01114100300&call_id=1234567890-2&peer=777008478072@example.com'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
|
|
@ -36,7 +36,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Cti::Log.destroy_all
|
Cti::Log.destroy_all
|
||||||
|
|
||||||
Setting.set('sipgate_integration', true)
|
Setting.set('sipgate_integration', true)
|
||||||
|
@ -78,7 +78,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - I
|
# inbound - I
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
content = @response.body
|
content = @response.body
|
||||||
|
@ -93,7 +93,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - II - block caller
|
# inbound - II - block caller
|
||||||
params = 'event=newCall&direction=in&from=491715000000&to=4930600000000&callId=4991155921769858278-2&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=491715000000&to=4930600000000&callId=4991155921769858278-2&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
content = @response.body
|
content = @response.body
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - I - set default_caller_id
|
# outbound - I - set default_caller_id
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=8621106404543334274-3&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=8621106404543334274-3&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
|
@ -138,7 +138,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - II - set caller_id based on routing_table by explicite number
|
# outbound - II - set caller_id based on routing_table by explicite number
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=491714000000&callId=8621106404543334274-4&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=491714000000&callId=8621106404543334274-4&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
|
@ -163,7 +163,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - III - set caller_id based on routing_table by 41*
|
# outbound - III - set caller_id based on routing_table by 41*
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4147110000000&callId=8621106404543334274-5&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4147110000000&callId=8621106404543334274-5&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
caller_id = nil
|
caller_id = nil
|
||||||
|
@ -189,7 +189,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
Setting.set('sipgate_config', {})
|
Setting.set('sipgate_config', {})
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-6&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-6&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(422)
|
expect(@response).to have_http_status(:unprocessable_entity)
|
||||||
error = nil
|
error = nil
|
||||||
content = @response.body
|
content = @response.body
|
||||||
response = REXML::Document.new(content)
|
response = REXML::Document.new(content)
|
||||||
|
@ -205,7 +205,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - I - new call
|
# outbound - I - new call
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-1&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-1&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -222,7 +222,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - I - hangup by agent
|
# outbound - I - hangup by agent
|
||||||
params = 'event=hangup&direction=out&callId=1234567890-1&cause=cancel'
|
params = 'event=hangup&direction=out&callId=1234567890-1&cause=cancel'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-1')
|
log = Cti::Log.find_by(call_id: '1234567890-1')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -239,7 +239,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - II - new call
|
# outbound - II - new call
|
||||||
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-2&user%5B%5D=user+1'
|
params = 'event=newCall&direction=out&from=4930600000000&to=4912347114711&callId=1234567890-2&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -256,7 +256,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - II - answer by customer
|
# outbound - II - answer by customer
|
||||||
params = 'event=answer&direction=out&callId=1234567890-2&from=4930600000000&to=4912347114711'
|
params = 'event=answer&direction=out&callId=1234567890-2&from=4930600000000&to=4912347114711'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -273,7 +273,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# outbound - II - hangup by customer
|
# outbound - II - hangup by customer
|
||||||
params = 'event=hangup&direction=out&callId=1234567890-2&cause=normalClearing&from=4930600000000&to=4912347114711'
|
params = 'event=hangup&direction=out&callId=1234567890-2&cause=normalClearing&from=4930600000000&to=4912347114711'
|
||||||
post '/api/v1/sipgate/out', params: params
|
post '/api/v1/sipgate/out', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-2')
|
log = Cti::Log.find_by(call_id: '1234567890-2')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.from).to eq('4930777000000')
|
expect(log.from).to eq('4930777000000')
|
||||||
|
@ -290,7 +290,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - I - new call
|
# inbound - I - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-3&user%5B%5D=user+1'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-3&user%5B%5D=user+1'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -307,7 +307,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - I - answer by customer
|
# inbound - I - answer by customer
|
||||||
params = 'event=answer&direction=in&callId=1234567890-3&to=4930600000000&from=4912347114711'
|
params = 'event=answer&direction=in&callId=1234567890-3&to=4930600000000&from=4912347114711'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -324,7 +324,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - I - hangup by customer
|
# inbound - I - hangup by customer
|
||||||
params = 'event=hangup&direction=in&callId=1234567890-3&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&callId=1234567890-3&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-3')
|
log = Cti::Log.find_by(call_id: '1234567890-3')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -341,7 +341,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - II - new call
|
# inbound - II - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-4&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-4&user%5B%5D=user+1,user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -358,7 +358,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - II - answer by voicemail
|
# inbound - II - answer by voicemail
|
||||||
params = 'event=answer&direction=in&callId=1234567890-4&to=4930600000000&from=4912347114711&user=voicemail'
|
params = 'event=answer&direction=in&callId=1234567890-4&to=4930600000000&from=4912347114711&user=voicemail'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -375,7 +375,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - II - hangup by customer
|
# inbound - II - hangup by customer
|
||||||
params = 'event=hangup&direction=in&callId=1234567890-4&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&callId=1234567890-4&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-4')
|
log = Cti::Log.find_by(call_id: '1234567890-4')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -392,7 +392,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - III - new call
|
# inbound - III - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-5&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=4912347114711&callId=1234567890-5&user%5B%5D=user+1,user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -409,7 +409,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - III - hangup by customer
|
# inbound - III - hangup by customer
|
||||||
params = 'event=hangup&direction=in&callId=1234567890-5&cause=normalClearing&to=4930600000000&from=4912347114711'
|
params = 'event=hangup&direction=in&callId=1234567890-5&cause=normalClearing&to=4930600000000&from=4912347114711'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-5')
|
log = Cti::Log.find_by(call_id: '1234567890-5')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -426,7 +426,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - IV - new call
|
# inbound - IV - new call
|
||||||
params = 'event=newCall&direction=in&to=4930600000000&from=49999992222222&callId=1234567890-6&user%5B%5D=user+1,user+2'
|
params = 'event=newCall&direction=in&to=4930600000000&from=49999992222222&callId=1234567890-6&user%5B%5D=user+1,user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
log = Cti::Log.find_by(call_id: '1234567890-6')
|
log = Cti::Log.find_by(call_id: '1234567890-6')
|
||||||
expect(log).to be_truthy
|
expect(log).to be_truthy
|
||||||
expect(log.to).to eq('4930600000000')
|
expect(log.to).to eq('4930600000000')
|
||||||
|
@ -442,11 +442,11 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
|
|
||||||
# get caller list
|
# get caller list
|
||||||
get '/api/v1/cti/log'
|
get '/api/v1/cti/log'
|
||||||
expect(@response).to have_http_status(401)
|
expect(@response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
expect(json_response['list']).to be_a_kind_of(Array)
|
expect(json_response['list']).to be_a_kind_of(Array)
|
||||||
expect(json_response['list'].count).to eq(6)
|
expect(json_response['list'].count).to eq(6)
|
||||||
expect(json_response['assets']).to be_truthy
|
expect(json_response['assets']).to be_truthy
|
||||||
|
@ -474,7 +474,7 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
# inbound - I
|
# inbound - I
|
||||||
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
params = 'event=newCall&direction=in&from=4912347114711&to=4930600000000&callId=4991155921769858278-1&user%5B%5D=user+1&user%5B%5D=user+2'
|
||||||
post '/api/v1/sipgate/in', params: params
|
post '/api/v1/sipgate/in', params: params
|
||||||
expect(@response).to have_http_status(200)
|
expect(@response).to have_http_status(:ok)
|
||||||
on_hangup = nil
|
on_hangup = nil
|
||||||
on_answer = nil
|
on_answer = nil
|
||||||
content = @response.body
|
content = @response.body
|
||||||
|
|
|
@ -72,24 +72,24 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# start communication #1
|
# start communication #1
|
||||||
post '/api/v1/channels/telegram_webhook', params: read_message('personal1_message_start'), as: :json
|
post '/api/v1/channels/telegram_webhook', params: read_message('personal1_message_start'), as: :json
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
|
|
||||||
post '/api/v1/channels_telegram_webhook/not_existing', params: read_message('personal1_message_start'), as: :json
|
post '/api/v1/channels_telegram_webhook/not_existing', params: read_message('personal1_message_start'), as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response['error']).to eq('bot param missing')
|
expect(json_response['error']).to eq('bot param missing')
|
||||||
|
|
||||||
callback_url = "/api/v1/channels_telegram_webhook/not_existing?bid=#{channel.options[:bot][:id]}"
|
callback_url = "/api/v1/channels_telegram_webhook/not_existing?bid=#{channel.options[:bot][:id]}"
|
||||||
post callback_url, params: read_message('personal1_message_start'), as: :json
|
post callback_url, params: read_message('personal1_message_start'), as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response['error']).to eq('invalid callback token')
|
expect(json_response['error']).to eq('invalid callback token')
|
||||||
|
|
||||||
callback_url = "/api/v1/channels_telegram_webhook/#{channel.options[:callback_token]}?bid=#{channel.options[:bot][:id]}"
|
callback_url = "/api/v1/channels_telegram_webhook/#{channel.options[:callback_token]}?bid=#{channel.options[:bot][:id]}"
|
||||||
post callback_url, params: read_message('personal1_message_start'), as: :json
|
post callback_url, params: read_message('personal1_message_start'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
# send message1
|
# send message1
|
||||||
post callback_url, params: read_message('personal1_message_content1'), as: :json
|
post callback_url, params: read_message('personal1_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(1)
|
expect(Ticket.count).to eq(1)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
|
@ -100,7 +100,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send channel message1
|
# send channel message1
|
||||||
post callback_url, params: read_message('channel1_message_content1'), as: :json
|
post callback_url, params: read_message('channel1_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(1)
|
expect(Ticket.count).to eq(1)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
|
@ -111,7 +111,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# edit channel message1
|
# edit channel message1
|
||||||
post callback_url, params: read_message('channel2_message_content1'), as: :json
|
post callback_url, params: read_message('channel2_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(1)
|
expect(Ticket.count).to eq(1)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send same message again, ignore it
|
# send same message again, ignore it
|
||||||
post callback_url, params: read_message('personal1_message_content1'), as: :json
|
post callback_url, params: read_message('personal1_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
expect(ticket.state.name).to eq('new')
|
expect(ticket.state.name).to eq('new')
|
||||||
|
@ -132,7 +132,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send message2
|
# send message2
|
||||||
post callback_url, params: read_message('personal1_message_content2'), as: :json
|
post callback_url, params: read_message('personal1_message_content2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
expect(ticket.state.name).to eq('new')
|
expect(ticket.state.name).to eq('new')
|
||||||
|
@ -142,7 +142,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send end message
|
# send end message
|
||||||
post callback_url, params: read_message('personal1_message_end'), as: :json
|
post callback_url, params: read_message('personal1_message_end'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
expect(ticket.state.name).to eq('closed')
|
expect(ticket.state.name).to eq('closed')
|
||||||
|
@ -152,11 +152,11 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# start communication #2
|
# start communication #2
|
||||||
post callback_url, params: read_message('personal2_message_start'), as: :json
|
post callback_url, params: read_message('personal2_message_start'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
# send message1
|
# send message1
|
||||||
post callback_url, params: read_message('personal2_message_content1'), as: :json
|
post callback_url, params: read_message('personal2_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(2)
|
expect(Ticket.count).to eq(2)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -167,7 +167,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send message2
|
# send message2
|
||||||
post callback_url, params: read_message('personal2_message_content2'), as: :json
|
post callback_url, params: read_message('personal2_message_content2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(2)
|
expect(Ticket.count).to eq(2)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -178,11 +178,11 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# start communication #3
|
# start communication #3
|
||||||
post callback_url, params: read_message('personal3_message_start'), as: :json
|
post callback_url, params: read_message('personal3_message_start'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
# send message1
|
# send message1
|
||||||
post callback_url, params: read_message('personal3_message_content1'), as: :json
|
post callback_url, params: read_message('personal3_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -199,7 +199,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
.to_return(status: 200, body: 'ABC1', headers: {})
|
.to_return(status: 200, body: 'ABC1', headers: {})
|
||||||
|
|
||||||
post callback_url, params: read_message('personal3_message_content2'), as: :json
|
post callback_url, params: read_message('personal3_message_content2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -210,7 +210,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send channel message 3
|
# send channel message 3
|
||||||
post callback_url, params: read_message('channel1_message_content3'), as: :json
|
post callback_url, params: read_message('channel1_message_content3'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -230,7 +230,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAgADDgAD7x6ZSC_-1LMkOEmoAg","file_path":"abc123"}}', headers: {})
|
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAgADDgAD7x6ZSC_-1LMkOEmoAg","file_path":"abc123"}}', headers: {})
|
||||||
|
|
||||||
post callback_url, params: read_message('personal3_message_content3'), as: :json
|
post callback_url, params: read_message('personal3_message_content3'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -242,7 +242,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# isend channel message 2
|
# isend channel message 2
|
||||||
post callback_url, params: read_message('channel1_message_content2'), as: :json
|
post callback_url, params: read_message('channel1_message_content2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -254,7 +254,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# update message1
|
# update message1
|
||||||
post callback_url, params: read_message('personal3_message_content4'), as: :json
|
post callback_url, params: read_message('personal3_message_content4'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -273,7 +273,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AwADAgADVQADCEIYSZwyOmSZK9iZAg","file_path":"abc123"}}', headers: {})
|
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AwADAgADVQADCEIYSZwyOmSZK9iZAg","file_path":"abc123"}}', headers: {})
|
||||||
|
|
||||||
post callback_url, params: read_message('personal3_message_content5'), as: :json
|
post callback_url, params: read_message('personal3_message_content5'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -284,7 +284,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send channel message 4 with voice
|
# send channel message 4 with voice
|
||||||
post callback_url, params: read_message('channel1_message_content4'), as: :json
|
post callback_url, params: read_message('channel1_message_content4'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(3)
|
expect(Ticket.count).to eq(3)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Can you help me with my feature?')
|
expect(ticket.title).to eq('Can you help me with my feature?')
|
||||||
|
@ -302,7 +302,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAwAD0QIAAqbJWAAB8OkQqgtDQe0C","file_path":"abc123"}}', headers: {})
|
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123BQADAwAD0QIAAqbJWAAB8OkQqgtDQe0C","file_path":"abc123"}}', headers: {})
|
||||||
|
|
||||||
post callback_url, params: read_message('personal4_message_content1'), as: :json
|
post callback_url, params: read_message('personal4_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(4)
|
expect(Ticket.count).to eq(4)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
if Rails.application.config.db_4bytes_utf8
|
if Rails.application.config.db_4bytes_utf8
|
||||||
|
@ -318,7 +318,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
|
|
||||||
# send channel message #5 with sticker
|
# send channel message #5 with sticker
|
||||||
post callback_url, params: read_message('channel1_message_content5'), as: :json
|
post callback_url, params: read_message('channel1_message_content5'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(4)
|
expect(Ticket.count).to eq(4)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
if Rails.application.config.db_4bytes_utf8
|
if Rails.application.config.db_4bytes_utf8
|
||||||
|
@ -338,7 +338,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AgADAgADwacxGxk5MUmim45lijOwsKk1Sw0ABNQoaI8BwR_z_2MFAAEC","file_path":"abc123"}}', headers: {})
|
.to_return(status: 200, body: '{"result":{"file_size":123,"file_id":"ABC-123AgADAgADwacxGxk5MUmim45lijOwsKk1Sw0ABNQoaI8BwR_z_2MFAAEC","file_path":"abc123"}}', headers: {})
|
||||||
|
|
||||||
post callback_url, params: read_message('personal5_message_content1'), as: :json
|
post callback_url, params: read_message('personal5_message_content1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(5)
|
expect(Ticket.count).to eq(5)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('-')
|
expect(ticket.title).to eq('-')
|
||||||
|
@ -349,7 +349,7 @@ RSpec.describe 'Telegram', type: :request do
|
||||||
expect(ticket.articles.last.attachments.count).to eq(0)
|
expect(ticket.articles.last.attachments.count).to eq(0)
|
||||||
|
|
||||||
post callback_url, params: read_message('personal5_message_content2'), as: :json
|
post callback_url, params: read_message('personal5_message_content2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Ticket.count).to eq(5)
|
expect(Ticket.count).to eq(5)
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
expect(ticket.title).to eq('Hello, I need your Help')
|
expect(ticket.title).to eq('Hello, I need your Help')
|
||||||
|
|
|
@ -30,20 +30,20 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
|
|
||||||
# process inbound sms
|
# process inbound sms
|
||||||
post '/api/v1/sms_webhook', params: read_message('inbound_sms1'), as: :json
|
post '/api/v1/sms_webhook', params: read_message('inbound_sms1'), as: :json
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/not_existing', params: read_message('inbound_sms1'), as: :json
|
post '/api/v1/sms_webhook/not_existing', params: read_message('inbound_sms1'), as: :json
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(:not_found)
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect('Can\'t use Channel::Driver::Sms::Twilio: #<Exceptions::UnprocessableEntity: Group needed in channel definition!>').to eq(json_response['error'])
|
expect('Can\'t use Channel::Driver::Sms::Twilio: #<Exceptions::UnprocessableEntity: Group needed in channel definition!>').to eq(json_response['error'])
|
||||||
|
|
||||||
channel.group_id = Group.first.id
|
channel.group_id = Group.first.id
|
||||||
channel.save!
|
channel.save!
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
xml_response = REXML::Document.new(response.body)
|
xml_response = REXML::Document.new(response.body)
|
||||||
expect(1).to eq(xml_response.elements.count)
|
expect(1).to eq(xml_response.elements.count)
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
expect(article.type.name).to eq('sms')
|
expect(article.type.name).to eq('sms')
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms2'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
xml_response = REXML::Document.new(response.body)
|
xml_response = REXML::Document.new(response.body)
|
||||||
expect(1).to eq(xml_response.elements.count)
|
expect(1).to eq(xml_response.elements.count)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
|
|
||||||
# check duplicate callbacks
|
# check duplicate callbacks
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms2'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms2'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
xml_response = REXML::Document.new(response.body)
|
xml_response = REXML::Document.new(response.body)
|
||||||
expect(1).to eq(xml_response.elements.count)
|
expect(1).to eq(xml_response.elements.count)
|
||||||
|
|
||||||
|
@ -100,13 +100,13 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
ticket.save!
|
ticket.save!
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms3'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms3'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
xml_response = REXML::Document.new(response.body)
|
xml_response = REXML::Document.new(response.body)
|
||||||
expect(1).to eq(xml_response.elements.count)
|
expect(1).to eq(xml_response.elements.count)
|
||||||
|
|
||||||
ticket.reload
|
ticket.reload
|
||||||
expect(ticket.articles.count).to eq(2)
|
expect(ticket.articles.count).to eq(2)
|
||||||
expect(ticket.id).to_not eq(Ticket.last.id)
|
expect(ticket.id).not_to eq(Ticket.last.id)
|
||||||
expect(ticket.state.name).to eq('closed')
|
expect(ticket.state.name).to eq('closed')
|
||||||
|
|
||||||
ticket = Ticket.last
|
ticket = Ticket.last
|
||||||
|
@ -134,7 +134,7 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/ticket_articles', params: params, as: :json
|
post '/api/v1/ticket_articles', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some test')
|
expect(json_response['body']).to eq('some test')
|
||||||
|
@ -196,7 +196,7 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
)
|
)
|
||||||
|
|
||||||
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
post '/api/v1/sms_webhook/f409460e50f76d331fdac8ba7b7963b6', params: read_message('inbound_sms1'), as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
xml_response = REXML::Document.new(response.body)
|
xml_response = REXML::Document.new(response.body)
|
||||||
expect(1).to eq(xml_response.elements.count)
|
expect(1).to eq(xml_response.elements.count)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
describe '#webhook_verify (for Twitter to confirm Zammad’s credentials)' do
|
describe '#webhook_verify (for Twitter to confirm Zammad’s credentials)' do
|
||||||
context 'with only cached credentials' do
|
context 'with only cached credentials' do
|
||||||
let!(:external_credential) { nil }
|
let!(:external_credential) { nil }
|
||||||
|
|
||||||
before { Cache.write('external_credential_twitter', credentials) }
|
before { Cache.write('external_credential_twitter', credentials) }
|
||||||
|
|
||||||
it 'returns an HMAC signature for cached credentials plus params[:crc_token]' do
|
it 'returns an HMAC signature for cached credentials plus params[:crc_token]' do
|
||||||
|
@ -15,7 +16,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('response_token' => 'sha256=VE19eUk6krbdSqWPdvH71xtFhApBAU81uPW3UT65vOs=')
|
expect(json_response).to include('response_token' => 'sha256=VE19eUk6krbdSqWPdvH71xtFhApBAU81uPW3UT65vOs=')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +28,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to include('response_token' => 'sha256=VE19eUk6krbdSqWPdvH71xtFhApBAU81uPW3UT65vOs=')
|
expect(json_response).to include('response_token' => 'sha256=VE19eUk6krbdSqWPdvH71xtFhApBAU81uPW3UT65vOs=')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +75,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'sha256=JjEmBe1lVKT8XldrYUKibF+D5ehp8f0jDk3PXZSHEWI=' },
|
headers: { 'x-twitter-webhooks-signature' => 'sha256=JjEmBe1lVKT8XldrYUKibF+D5ehp8f0jDk3PXZSHEWI=' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 422 with error message' do
|
it 'returns 422 with error message' do
|
||||||
post '/api/v1/channels_twitter_webhook', as: :json
|
post '/api/v1/channels_twitter_webhook', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => "Missing 'x-twitter-webhooks-signature' header")
|
expect(json_response).to include('error' => "Missing 'x-twitter-webhooks-signature' header")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,7 +97,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => "No such external_credential 'twitter'!")
|
expect(json_response).to include('error' => "No such external_credential 'twitter'!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -107,7 +108,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
headers: { 'x-twitter-webhooks-signature' => 'something' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to include('error' => 'Not authorized')
|
expect(json_response).to include('error' => 'Not authorized')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -119,7 +120,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'sha256=EERHBy/k17v+SuT+K0OXuwhJtKnPtxi0n/Y4Wye4kVU=' },
|
headers: { 'x-twitter-webhooks-signature' => 'sha256=EERHBy/k17v+SuT+K0OXuwhJtKnPtxi0n/Y4Wye4kVU=' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => "Missing 'for_user_id' in payload!")
|
expect(json_response).to include('error' => "Missing 'for_user_id' in payload!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -131,7 +132,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
headers: { 'x-twitter-webhooks-signature' => 'sha256=QaJiQl/4WRp/GF37b+eAdF6kPgptjDCLOgAIIbB1s0I=' },
|
headers: { 'x-twitter-webhooks-signature' => 'sha256=QaJiQl/4WRp/GF37b+eAdF6kPgptjDCLOgAIIbB1s0I=' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to include('error' => "No such channel for user id 'not_existing'!")
|
expect(json_response).to include('error' => "No such channel for user id 'not_existing'!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -149,12 +150,12 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 200' do
|
it 'returns 200' do
|
||||||
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates closed ticket' do
|
it 'creates closed ticket' do
|
||||||
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.attributes)
|
expect(Ticket.last.attributes)
|
||||||
.to include(
|
.to include(
|
||||||
|
@ -194,12 +195,12 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 200' do
|
it 'returns 200' do
|
||||||
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates new ticket' do
|
it 'creates new ticket' do
|
||||||
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.attributes)
|
expect(Ticket.last.attributes)
|
||||||
.to include(
|
.to include(
|
||||||
|
@ -243,12 +244,12 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 200' do
|
it 'returns 200' do
|
||||||
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create new ticket' do
|
it 'does not create new ticket' do
|
||||||
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
.not_to change { Ticket.count }
|
.not_to change(Ticket, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds new article to existing, open ticket' do
|
it 'adds new article to existing, open ticket' do
|
||||||
|
@ -280,7 +281,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'still returns 200' do
|
it 'still returns 200' do
|
||||||
2.times { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
2.times { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create duplicate articles' do
|
it 'does not create duplicate articles' do
|
||||||
|
@ -305,12 +306,12 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 200' do
|
it 'returns 200' do
|
||||||
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a closed ticket' do
|
it 'creates a closed ticket' do
|
||||||
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.attributes)
|
expect(Ticket.last.attributes)
|
||||||
.to include(
|
.to include(
|
||||||
|
@ -353,12 +354,12 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'returns 200' do
|
it 'returns 200' do
|
||||||
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a new ticket' do
|
it 'creates a new ticket' do
|
||||||
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
expect { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
.to change { Ticket.count }.by(1)
|
.to change(Ticket, :count).by(1)
|
||||||
|
|
||||||
expect(Ticket.last.attributes)
|
expect(Ticket.last.attributes)
|
||||||
.to include(
|
.to include(
|
||||||
|
@ -397,7 +398,7 @@ RSpec.describe 'Twitter Webhook Integration', type: :request do
|
||||||
it 'still returns 200' do
|
it 'still returns 200' do
|
||||||
2.times { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
2.times { post '/api/v1/channels_twitter_webhook', **webhook_payload, as: :json }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create duplicate articles' do
|
it 'does not create duplicate articles' do
|
||||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
create(:agent_user, login: 'user-device-agent', password: 'agentpw', groups: Group.all)
|
create(:agent_user, login: 'user-device-agent', password: 'agentpw', groups: Group.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
||||||
ENV['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0'
|
ENV['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0'
|
||||||
ENV['SWITCHED_FROM_USER_ID'] = nil
|
ENV['SWITCHED_FROM_USER_ID'] = nil
|
||||||
|
@ -22,7 +22,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
it 'does index with nobody (01)' do
|
it 'does index with nobody (01)' do
|
||||||
|
|
||||||
get '/api/v1/signshow'
|
get '/api/v1/signshow'
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect('no valid session').to eq(json_response['error'])
|
expect('no valid session').to eq(json_response['error'])
|
||||||
expect(json_response['config']).to be_truthy
|
expect(json_response['config']).to be_truthy
|
||||||
|
@ -35,7 +35,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { without_fingerprint: 'none', username: 'user-device-admin', password: 'adminpw' }
|
params = { without_fingerprint: 'none', username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Need fingerprint param!')
|
expect(json_response['error']).to eq('Need fingerprint param!')
|
||||||
|
@ -62,7 +62,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
it 'does login index with admin with fingerprint - I (03)' do
|
it 'does login index with admin with fingerprint - I (03)' do
|
||||||
params = { fingerprint: 'my_finger_print', username: 'user-device-admin', password: 'adminpw' }
|
params = { fingerprint: 'my_finger_print', username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
expect(json_response['config']).to be_truthy
|
expect(json_response['config']).to be_truthy
|
||||||
|
@ -88,7 +88,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(controller.session[:user_device_fingerprint]).to eq('my_finger_print')
|
expect(controller.session[:user_device_fingerprint]).to eq('my_finger_print')
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { fingerprint: 'my_finger_print' }
|
params = { fingerprint: 'my_finger_print' }
|
||||||
get '/api/v1/signshow', params: params, as: :json
|
get '/api/v1/signshow', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['session']).to be_truthy
|
expect(json_response['session']).to be_truthy
|
||||||
expect('user-device-admin').to eq(json_response['session']['login'])
|
expect('user-device-admin').to eq(json_response['session']['login'])
|
||||||
|
@ -139,7 +139,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(controller.session[:user_device_fingerprint]).to eq('my_finger_print')
|
expect(controller.session[:user_device_fingerprint]).to eq('my_finger_print')
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_last.updated_at.to_s).to_not eq(user_device_first.updated_at.to_s)
|
expect(user_device_last.updated_at.to_s).not_to eq(user_device_first.updated_at.to_s)
|
||||||
ENV['USER_DEVICE_UPDATED_AT'] = nil
|
ENV['USER_DEVICE_UPDATED_AT'] = nil
|
||||||
|
|
||||||
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
||||||
|
@ -168,7 +168,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { fingerprint: 'my_finger_print_II', username: 'user-device-admin', password: 'adminpw' }
|
params = { fingerprint: 'my_finger_print_II', username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
expect(controller.session[:user_device_fingerprint]).to be_truthy
|
expect(controller.session[:user_device_fingerprint]).to be_truthy
|
||||||
|
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
@ -245,7 +245,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { fingerprint: 'my_finger_print_II' }
|
params = { fingerprint: 'my_finger_print_II' }
|
||||||
get '/api/v1/signshow', params: params, as: :json
|
get '/api/v1/signshow', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['session']).to be_truthy
|
expect(json_response['session']).to be_truthy
|
||||||
expect('user-device-admin').to eq(json_response['session']['login'])
|
expect('user-device-admin').to eq(json_response['session']['login'])
|
||||||
|
@ -271,7 +271,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { fingerprint: 'my_finger_print_II', username: 'user-device-admin', password: 'adminpw' }
|
params = { fingerprint: 'my_finger_print_II', username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin_user, password: 'adminpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin_user, password: 'adminpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(agent_user, password: 'agentpw')
|
authenticated_as(agent_user, password: 'agentpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(agent_user, password: 'agentpw')
|
authenticated_as(agent_user, password: 'agentpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
params = { fingerprint: 'my_finger_print_II', username: 'user-device-agent', password: 'agentpw' }
|
params = { fingerprint: 'my_finger_print_II', username: 'user-device-agent', password: 'agentpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
ENV['USER_DEVICE_UPDATED_AT'] = (Time.zone.now - 4.hours).to_s
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
@ -591,7 +591,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
||||||
params = {}
|
params = {}
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
it 'does login with invalid fingerprint (11)' do
|
it 'does login with invalid fingerprint (11)' do
|
||||||
params = { fingerprint: 'to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890', username: 'user-device-admin', password: 'adminpw' }
|
params = { fingerprint: 'to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890to_long_1234567890', username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('fingerprint is 198 chars but can only be 160 chars!')
|
expect(json_response['error']).to eq('fingerprint is 198 chars but can only be 160 chars!')
|
||||||
|
@ -643,7 +643,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
it 'does login with integer as fingerprint (12)' do
|
it 'does login with integer as fingerprint (12)' do
|
||||||
params = { fingerprint: 123_456_789, username: 'user-device-admin', password: 'adminpw' }
|
params = { fingerprint: 123_456_789, username: 'user-device-admin', password: 'adminpw' }
|
||||||
post '/api/v1/signin', params: params, as: :json
|
post '/api/v1/signin', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(controller.session[:user_device_fingerprint]).to be_truthy
|
expect(controller.session[:user_device_fingerprint]).to be_truthy
|
||||||
|
|
||||||
check_notification do
|
check_notification do
|
||||||
|
@ -673,7 +673,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin_user, password: 'adminpw')
|
||||||
post '/api/v1/form_config', params: params, as: :json
|
post '/api/v1/form_config', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_falsey
|
expect(json_response['error']).to be_falsey
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
create(:agent_user)
|
create(:agent_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
Sessions.sessions.each do |client_id|
|
Sessions.sessions.each do |client_id|
|
||||||
Sessions.destroy(client_id)
|
Sessions.destroy(client_id)
|
||||||
end
|
end
|
||||||
|
@ -17,25 +17,25 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
|
|
||||||
it 'receive without client_id - no user login' do
|
it 'receive without client_id - no user login' do
|
||||||
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid client_id receive!')
|
expect(json_response['error']).to eq('Invalid client_id receive!')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'send without client_id - no user login' do
|
it 'send without client_id - no user login' do
|
||||||
get '/api/v1/message_send', params: { data: {} }, as: :json
|
get '/api/v1/message_send', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
||||||
|
|
||||||
client_id = json_response['client_id']
|
client_id = json_response['client_id']
|
||||||
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'spool' } }, as: :json
|
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'spool' } }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
||||||
|
|
||||||
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid client_id receive!')
|
expect(json_response['error']).to eq('Invalid client_id receive!')
|
||||||
end
|
end
|
||||||
|
@ -43,7 +43,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
it 'receive without client_id' do
|
it 'receive without client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid client_id receive!')
|
expect(json_response['error']).to eq('Invalid client_id receive!')
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
it 'receive without wrong client_id' do
|
it 'receive without wrong client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/message_receive', params: { client_id: 'not existing', data: {} }, as: :json
|
get '/api/v1/message_receive', params: { client_id: 'not existing', data: {} }, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Invalid client_id receive!')
|
expect(json_response['error']).to eq('Invalid client_id receive!')
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
it 'send without client_id' do
|
it 'send without client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/message_send', params: { data: {} }, as: :json
|
get '/api/v1/message_send', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
Sessions.create('123456', {}, { type: 'ajax' })
|
Sessions.create('123456', {}, { type: 'ajax' })
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/message_send', params: { client_id: '123456', data: {} }, as: :json
|
get '/api/v1/message_send', params: { client_id: '123456', data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to eq({})
|
expect(json_response).to eq({})
|
||||||
end
|
end
|
||||||
|
@ -79,22 +79,22 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
# will update the user by every request and return a different result for the test
|
# will update the user by every request and return a different result for the test
|
||||||
authenticated_as(agent_user, token: create(:token, action: 'api', user_id: agent_user.id) )
|
authenticated_as(agent_user, token: create(:token, action: 'api', user_id: agent_user.id) )
|
||||||
get '/api/v1/message_send', params: { data: { event: 'login' } }, as: :json
|
get '/api/v1/message_send', params: { data: { event: 'login' } }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
expect(json_response['client_id'].to_i).to be_between(1, 9_999_999_999)
|
||||||
client_id = json_response['client_id']
|
client_id = json_response['client_id']
|
||||||
|
|
||||||
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to eq([{ 'data' => { 'success' => true }, 'event' => 'ws:login' }])
|
expect(json_response).to eq([{ 'data' => { 'success' => true }, 'event' => 'ws:login' }])
|
||||||
|
|
||||||
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'spool' } }, as: :json
|
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'spool' } }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to eq({})
|
expect(json_response).to eq({})
|
||||||
|
|
||||||
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0]['event']).to eq('spool:sent')
|
expect(json_response[0]['event']).to eq('spool:sent')
|
||||||
expect(json_response[0]['event']).to eq('spool:sent')
|
expect(json_response[0]['event']).to eq('spool:sent')
|
||||||
|
@ -104,12 +104,12 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
expect(spool_list).to eq([])
|
expect(spool_list).to eq([])
|
||||||
|
|
||||||
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'broadcast', spool: true, recipient: { user_id: [agent_user.id] }, data: { taskbar_id: 9_391_633 } } }, as: :json
|
get '/api/v1/message_send', params: { client_id: client_id, data: { event: 'broadcast', spool: true, recipient: { user_id: [agent_user.id] }, data: { taskbar_id: 9_391_633 } } }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to eq({})
|
expect(json_response).to eq({})
|
||||||
|
|
||||||
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
get '/api/v1/message_receive', params: { client_id: client_id, data: {} }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to eq({ 'event' => 'pong' })
|
expect(json_response).to eq({ 'event' => 'pong' })
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'OAuth', type: :request do
|
||||||
|
|
||||||
it 'does o365 - start' do
|
it 'does o365 - start' do
|
||||||
get '/auth/microsoft_office365'
|
get '/auth/microsoft_office365'
|
||||||
expect(response).to have_http_status(302)
|
expect(response).to have_http_status(:found)
|
||||||
expect(response.body).to include('https://login.microsoftonline.com/common/oauth2/v2.0/authorize')
|
expect(response.body).to include('https://login.microsoftonline.com/common/oauth2/v2.0/authorize')
|
||||||
expect(response.body).to include('redirect_uri=http%3A%2F%2Fzammad.example.com%2Fauth%2Fmicrosoft_office365%2Fcallback')
|
expect(response.body).to include('redirect_uri=http%3A%2F%2Fzammad.example.com%2Fauth%2Fmicrosoft_office365%2Fcallback')
|
||||||
expect(response.body).to include('scope=openid+email+profile')
|
expect(response.body).to include('scope=openid+email+profile')
|
||||||
|
@ -15,13 +15,13 @@ RSpec.describe 'OAuth', type: :request do
|
||||||
|
|
||||||
it 'does o365 - callback' do
|
it 'does o365 - callback' do
|
||||||
get '/auth/microsoft_office365/callback?code=1234&state=1234'
|
get '/auth/microsoft_office365/callback?code=1234&state=1234'
|
||||||
expect(response).to have_http_status(302)
|
expect(response).to have_http_status(:found)
|
||||||
expect(response.body).to include('302 Moved')
|
expect(response.body).to include('302 Moved')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does auth failure' do
|
it 'does auth failure' do
|
||||||
get '/auth/failure?message=123&strategy=some_provider'
|
get '/auth/failure?message=123&strategy=some_provider'
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(response.body).to include('<title>422: Unprocessable Entity</title>')
|
expect(response.body).to include('<title>422: Unprocessable Entity</title>')
|
||||||
expect(response.body).to include('<h1>422: The change you wanted was rejected.</h1>')
|
expect(response.body).to include('<h1>422: The change you wanted was rejected.</h1>')
|
||||||
expect(response.body).to include('<div>Message from some_provider: 123</div>')
|
expect(response.body).to include('<div>Message from some_provider: 123</div>')
|
||||||
|
|
|
@ -39,7 +39,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
create(:customer_user, organization: organization)
|
create(:customer_user, organization: organization)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
configure_elasticsearch do
|
configure_elasticsearch do
|
||||||
|
|
||||||
travel 1.minute
|
travel 1.minute
|
||||||
|
@ -60,13 +60,13 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# index
|
# index
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0]['member_ids']).to be_a_kind_of(Array)
|
expect(json_response[0]['member_ids']).to be_a_kind_of(Array)
|
||||||
expect(json_response.length >= 3).to be_truthy
|
expect(json_response.length >= 3).to be_truthy
|
||||||
|
|
||||||
get '/api/v1/organizations?limit=40&page=1&per_page=2', params: {}, as: :json
|
get '/api/v1/organizations?limit=40&page=1&per_page=2', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
organizations = Organization.order(:id).limit(2)
|
organizations = Organization.order(:id).limit(2)
|
||||||
expect(json_response[0]['id']).to eq(organizations[0].id)
|
expect(json_response[0]['id']).to eq(organizations[0].id)
|
||||||
|
@ -76,7 +76,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.count).to eq(2)
|
expect(json_response.count).to eq(2)
|
||||||
|
|
||||||
get '/api/v1/organizations?limit=40&page=2&per_page=2', params: {}, as: :json
|
get '/api/v1/organizations?limit=40&page=2&per_page=2', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
organizations = Organization.order(:id).limit(4)
|
organizations = Organization.order(:id).limit(4)
|
||||||
expect(json_response[0]['id']).to eq(organizations[2].id)
|
expect(json_response[0]['id']).to eq(organizations[2].id)
|
||||||
|
@ -88,14 +88,14 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['member_ids']).to be_a_kind_of(Array)
|
expect(json_response['member_ids']).to be_a_kind_of(Array)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect('Rest Org #1').to eq(json_response['name'])
|
expect('Rest Org #1').to eq(json_response['name'])
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['member_ids']).to be_a_kind_of(Array)
|
expect(json_response['member_ids']).to be_a_kind_of(Array)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
|
@ -104,21 +104,21 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# search as agent
|
# search as agent
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0]['name']).to eq('Zammad Foundation')
|
expect(json_response[0]['name']).to eq('Zammad Foundation')
|
||||||
expect(json_response[0]['member_ids']).to be_truthy
|
expect(json_response[0]['member_ids']).to be_truthy
|
||||||
expect(json_response[0]['members']).to be_falsey
|
expect(json_response[0]['members']).to be_falsey
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&expand=true", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&expand=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0]['name']).to eq('Zammad Foundation')
|
expect(json_response[0]['name']).to eq('Zammad Foundation')
|
||||||
expect(json_response[0]['member_ids']).to be_truthy
|
expect(json_response[0]['member_ids']).to be_truthy
|
||||||
expect(json_response[0]['members']).to be_truthy
|
expect(json_response[0]['members']).to be_truthy
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&label=true", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}&label=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0]['label']).to eq('Zammad Foundation')
|
expect(json_response[0]['label']).to eq('Zammad Foundation')
|
||||||
expect(json_response[0]['value']).to eq('Zammad Foundation')
|
expect(json_response[0]['value']).to eq('Zammad Foundation')
|
||||||
|
@ -131,25 +131,25 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response.length).to eq(0)
|
expect(json_response.length).to eq(0)
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to be_nil
|
expect(json_response['name']).to be_nil
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to be_nil
|
expect(json_response['name']).to be_nil
|
||||||
|
|
||||||
# search
|
# search
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does index with customer2' do
|
it 'does index with customer2' do
|
||||||
|
@ -157,59 +157,59 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer_user2)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response.length).to eq(1)
|
expect(json_response.length).to eq(1)
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect('Rest Org #1').to eq(json_response['name'])
|
expect('Rest Org #1').to eq(json_response['name'])
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization2.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to be_nil
|
expect(json_response['name']).to be_nil
|
||||||
|
|
||||||
# search
|
# search
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Zammad')}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does organization search sortable' do
|
it 'does organization search sortable' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: {}, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
result.collect! { |v| v['id'] }
|
result.collect! { |v| v['id'] }
|
||||||
expect(result).to be_a_kind_of(Array)
|
expect(result).to be_a_kind_of(Array)
|
||||||
expect(result).to eq([ organization.id, organization3.id, organization2.id ])
|
expect(result).to eq([ organization.id, organization3.id, organization2.id ])
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'created_at', order_by: 'asc' }, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'created_at', order_by: 'asc' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
result.collect! { |v| v['id'] }
|
result.collect! { |v| v['id'] }
|
||||||
expect(result).to be_a_kind_of(Array)
|
expect(result).to be_a_kind_of(Array)
|
||||||
expect(result).to eq([ organization.id, organization2.id, organization3.id ])
|
expect(result).to eq([ organization.id, organization2.id, organization3.id ])
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'note', order_by: 'asc' }, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'note', order_by: 'asc' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
result.collect! { |v| v['id'] }
|
result.collect! { |v| v['id'] }
|
||||||
expect(result).to be_a_kind_of(Array)
|
expect(result).to be_a_kind_of(Array)
|
||||||
expect(result).to eq([ organization.id, organization2.id, organization3.id ])
|
expect(result).to eq([ organization.id, organization2.id, organization3.id ])
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'note', order_by: 'desc' }, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: 'note', order_by: 'desc' }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
result.collect! { |v| v['id'] }
|
result.collect! { |v| v['id'] }
|
||||||
expect(result).to be_a_kind_of(Array)
|
expect(result).to be_a_kind_of(Array)
|
||||||
expect(result).to eq([ organization3.id, organization2.id, organization.id ])
|
expect(result).to eq([ organization3.id, organization2.id, organization.id ])
|
||||||
|
|
||||||
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: %w[note created_at], order_by: %w[desc asc] }, as: :json
|
get "/api/v1/organizations/search?query=#{CGI.escape('Rest Org')}", params: { sort_by: %w[note created_at], order_by: %w[desc asc] }, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
result.collect! { |v| v['id'] }
|
result.collect! { |v| v['id'] }
|
||||||
expect(result).to be_a_kind_of(Array)
|
expect(result).to be_a_kind_of(Array)
|
||||||
|
@ -227,7 +227,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['id']).to eq(organization.id)
|
expect(json_response['id']).to eq(organization.id)
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
|
@ -237,7 +237,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization.id}?expand=true", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}?expand=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['id']).to eq(organization.id)
|
expect(json_response['id']).to eq(organization.id)
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
|
@ -247,7 +247,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization.id}?expand=false", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}?expand=false", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['id']).to eq(organization.id)
|
expect(json_response['id']).to eq(organization.id)
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
|
@ -257,7 +257,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization.id}?full=true", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}?full=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['id']).to eq(organization.id)
|
expect(json_response['id']).to eq(organization.id)
|
||||||
|
@ -270,7 +270,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['assets']['Organization'][organization.id.to_s]['members']).to be_falsey
|
expect(json_response['assets']['Organization'][organization.id.to_s]['members']).to be_falsey
|
||||||
|
|
||||||
get "/api/v1/organizations/#{organization.id}?full=false", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}?full=false", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['id']).to eq(organization.id)
|
expect(json_response['id']).to eq(organization.id)
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
|
@ -291,7 +291,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0].class).to eq(Hash)
|
expect(json_response[0].class).to eq(Hash)
|
||||||
expect(json_response.last['id']).to eq(organization.id)
|
expect(json_response.last['id']).to eq(organization.id)
|
||||||
|
@ -302,7 +302,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get '/api/v1/organizations?expand=true', params: {}, as: :json
|
get '/api/v1/organizations?expand=true', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0].class).to eq(Hash)
|
expect(json_response[0].class).to eq(Hash)
|
||||||
expect(json_response.last['id']).to eq(organization.id)
|
expect(json_response.last['id']).to eq(organization.id)
|
||||||
|
@ -313,7 +313,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get '/api/v1/organizations?expand=false', params: {}, as: :json
|
get '/api/v1/organizations?expand=false', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0].class).to eq(Hash)
|
expect(json_response[0].class).to eq(Hash)
|
||||||
expect(json_response.last['id']).to eq(organization.id)
|
expect(json_response.last['id']).to eq(organization.id)
|
||||||
|
@ -324,7 +324,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
||||||
|
|
||||||
get '/api/v1/organizations?full=true', params: {}, as: :json
|
get '/api/v1/organizations?full=true', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['record_ids'].class).to eq(Array)
|
expect(json_response['record_ids'].class).to eq(Array)
|
||||||
|
@ -339,7 +339,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['assets']['Organization'][organization.id.to_s]['members']).to be_falsey
|
expect(json_response['assets']['Organization'][organization.id.to_s]['members']).to be_falsey
|
||||||
|
|
||||||
get '/api/v1/organizations?full=false', params: {}, as: :json
|
get '/api/v1/organizations?full=false', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response[0].class).to eq(Hash)
|
expect(json_response[0].class).to eq(Hash)
|
||||||
expect(json_response.last['id']).to eq(organization.id)
|
expect(json_response.last['id']).to eq(organization.id)
|
||||||
|
@ -358,7 +358,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/organizations', params: params, as: :json
|
post '/api/v1/organizations', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -370,7 +370,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
params[:name] = 'Rest Org NEW #2'
|
params[:name] = 'Rest Org NEW #2'
|
||||||
post '/api/v1/organizations?expand=true', params: params, as: :json
|
post '/api/v1/organizations?expand=true', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -382,7 +382,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
params[:name] = 'Rest Org NEW #3'
|
params[:name] = 'Rest Org NEW #3'
|
||||||
post '/api/v1/organizations?full=true', params: params, as: :json
|
post '/api/v1/organizations?full=true', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -410,7 +410,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
put "/api/v1/organizations/#{organization.id}", params: params, as: :json
|
put "/api/v1/organizations/#{organization.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -424,7 +424,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
name: 'a update name #2',
|
name: 'a update name #2',
|
||||||
}
|
}
|
||||||
put "/api/v1/organizations/#{organization.id}?expand=true", params: params, as: :json
|
put "/api/v1/organizations/#{organization.id}?expand=true", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -438,7 +438,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
name: 'a update name #3',
|
name: 'a update name #3',
|
||||||
}
|
}
|
||||||
put "/api/v1/organizations/#{organization.id}?full=true", params: params, as: :json
|
put "/api/v1/organizations/#{organization.id}?full=true", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
|
@ -460,7 +460,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get "/api/v1/organizations/history/#{organization1.id}", params: {}, as: :json
|
get "/api/v1/organizations/history/#{organization1.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['history'].class).to eq(Array)
|
expect(json_response['history'].class).to eq(Array)
|
||||||
expect(json_response['assets'].class).to eq(Hash)
|
expect(json_response['assets'].class).to eq(Hash)
|
||||||
|
@ -471,14 +471,14 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
it 'does csv example - customer no access' do
|
it 'does csv example - customer no access' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/organizations/import_example', params: {}, as: :json
|
get '/api/v1/organizations/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does csv example - admin access' do
|
it 'does csv example - admin access' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/organizations/import_example', params: {}, as: :json
|
get '/api/v1/organizations/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
rows = CSV.parse(@response.body)
|
rows = CSV.parse(@response.body)
|
||||||
header = rows.shift
|
header = rows.shift
|
||||||
|
@ -490,7 +490,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(header[4]).to eq('domain_assignment')
|
expect(header[4]).to eq('domain_assignment')
|
||||||
expect(header[5]).to eq('active')
|
expect(header[5]).to eq('active')
|
||||||
expect(header[6]).to eq('note')
|
expect(header[6]).to eq('note')
|
||||||
expect(header.include?('members')).to be_truthy
|
expect(header).to include('members')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does csv import - admin access' do
|
it 'does csv import - admin access' do
|
||||||
|
@ -520,7 +520,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
csv_file = fixture_file_upload('csv_import/organization/simple_col_not_existing.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/organization/simple_col_not_existing.csv', 'text/csv')
|
||||||
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to eq(true)
|
expect(json_response['try']).to eq(true)
|
||||||
|
@ -533,7 +533,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# valid file try
|
# valid file try
|
||||||
csv_file = fixture_file_upload('csv_import/organization/simple.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/organization/simple.csv', 'text/csv')
|
||||||
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/organizations/import?try=true', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to eq(true)
|
expect(json_response['try']).to eq(true)
|
||||||
|
@ -546,7 +546,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
# valid file
|
# valid file
|
||||||
csv_file = fixture_file_upload('csv_import/organization/simple.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/organization/simple.csv', 'text/csv')
|
||||||
post '/api/v1/organizations/import', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/organizations/import', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to eq(false)
|
expect(json_response['try']).to eq(false)
|
||||||
|
|
|
@ -35,7 +35,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
end
|
end
|
||||||
|
@ -65,13 +65,13 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('Overview2')
|
expect(json_response['name']).to eq('Overview2')
|
||||||
expect(json_response['link']).to eq('my_overview')
|
expect(json_response['link']).to eq('my_overview')
|
||||||
|
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('Overview2')
|
expect(json_response['name']).to eq('Overview2')
|
||||||
expect(json_response['link']).to eq('my_overview_1')
|
expect(json_response['link']).to eq('my_overview_1')
|
||||||
|
@ -136,7 +136,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/overviews_prio', params: params, as: :json
|
post '/api/v1/overviews_prio', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['success']).to eq(true)
|
expect(json_response['success']).to eq(true)
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('Overview2')
|
expect(json_response['name']).to eq('Overview2')
|
||||||
expect(json_response['link']).to eq('my_overview')
|
expect(json_response['link']).to eq('my_overview')
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
|
|
||||||
it 'does packages index with nobody' do
|
it 'does packages index with nobody' do
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['packages']).to be_falsey
|
expect(json_response['packages']).to be_falsey
|
||||||
|
@ -27,7 +27,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['packages']).to be_truthy
|
expect(json_response['packages']).to be_truthy
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
authenticated_as(admin_user, password: 'wrongadminpw')
|
authenticated_as(admin_user, password: 'wrongadminpw')
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['packages']).to be_falsey
|
expect(json_response['packages']).to be_falsey
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['packages']).to be_falsey
|
expect(json_response['packages']).to be_falsey
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
|
|
@ -42,7 +42,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
configure_elasticsearch do
|
configure_elasticsearch do
|
||||||
|
|
||||||
travel 1.minute
|
travel 1.minute
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get "/api/v1/reports/sets?sheet=true;metric=count;year=#{year};month=#{month};week=#{week};day=#{day};timeRange=year;profile_id=1;downloadBackendSelected=count::created", params: {}, as: :json
|
get "/api/v1/reports/sets?sheet=true;metric=count;year=#{year};month=#{month};week=#{week};day=#{day};timeRange=year;profile_id=1;downloadBackendSelected=count::created", params: {}, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
assert(@response['Content-Disposition'])
|
assert(@response['Content-Disposition'])
|
||||||
expect(@response['Content-Disposition']).to eq('attachment; filename="tickets--all--Created.xls"')
|
expect(@response['Content-Disposition']).to eq('attachment; filename="tickets--all--Created.xls"')
|
||||||
expect(@response['Content-Type']).to eq('application/vnd.ms-excel')
|
expect(@response['Content-Type']).to eq('application/vnd.ms-excel')
|
||||||
|
@ -99,28 +99,28 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
backends: backends
|
backends: backends
|
||||||
}
|
}
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
expect(json_response['data']['count::created']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
expect(json_response['data']['count::backlog']).to eq([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'Europe/Berlin')
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::created']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'America/Chicago')
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'Australia/Melbourne')
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
@ -139,21 +139,21 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'Europe/Berlin')
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'America/Chicago')
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
@ -178,7 +178,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
@ -191,7 +191,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
|
|
||||||
Setting.set('timezone_default', 'America/Chicago')
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])
|
||||||
|
@ -216,7 +216,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
@ -229,7 +229,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
|
|
||||||
Setting.set('timezone_default', 'America/Chicago')
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
@ -252,28 +252,28 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
backends: backends
|
backends: backends
|
||||||
}
|
}
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 1, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 1, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 1, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 1, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'Europe/Berlin')
|
Setting.set('timezone_default', 'Europe/Berlin')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'America/Chicago')
|
Setting.set('timezone_default', 'America/Chicago')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 2, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 2, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 2, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 2, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
||||||
Setting.set('timezone_default', 'Australia/Melbourne')
|
Setting.set('timezone_default', 'Australia/Melbourne')
|
||||||
post '/api/v1/reports/generate', params: params, as: :json
|
post '/api/v1/reports/generate', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::created']).to eq([0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::closed']).to eq([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
expect(json_response['data']['count::backlog']).to eq([0, 0, 7, 2, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
create(:ticket_article, ticket_id: ticket3.id)
|
create(:ticket_article, ticket_id: ticket3.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
configure_elasticsearch do
|
configure_elasticsearch do
|
||||||
|
|
||||||
travel 1.minute
|
travel 1.minute
|
||||||
|
@ -75,21 +75,21 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/ticket', params: params, as: :json
|
post '/api/v1/search/ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
|
||||||
post '/api/v1/search/user', params: params, as: :json
|
post '/api/v1/search/user', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to_not be_blank
|
expect(json_response).not_to be_blank
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -115,7 +115,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -134,7 +134,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/ticket', params: params, as: :json
|
post '/api/v1/search/ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -151,7 +151,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/user', params: params, as: :json
|
post '/api/v1/search/user', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result'][0]['type']).to eq('User')
|
expect(json_response['result'][0]['type']).to eq('User')
|
||||||
expect(json_response['result'][0]['id']).to eq(agent_user.id)
|
expect(json_response['result'][0]['id']).to eq(agent_user.id)
|
||||||
|
@ -166,7 +166,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -181,7 +181,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -200,7 +200,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/ticket', params: params, as: :json
|
post '/api/v1/search/ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -217,7 +217,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/user', params: params, as: :json
|
post '/api/v1/search/user', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result'][0]['type']).to eq('User')
|
expect(json_response['result'][0]['type']).to eq('User')
|
||||||
expect(json_response['result'][0]['id']).to eq(agent_user.id)
|
expect(json_response['result'][0]['id']).to eq(agent_user.id)
|
||||||
|
@ -232,7 +232,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -245,7 +245,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/ticket', params: params, as: :json
|
post '/api/v1/search/ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -258,7 +258,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/user', params: params, as: :json
|
post '/api/v1/search/user', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result'][0]).to be_falsey
|
expect(json_response['result'][0]).to be_falsey
|
||||||
end
|
end
|
||||||
|
@ -271,7 +271,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer_user2)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -286,7 +286,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/ticket', params: params, as: :json
|
post '/api/v1/search/ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
|
@ -301,7 +301,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
}
|
}
|
||||||
|
|
||||||
post '/api/v1/search/user', params: params, as: :json
|
post '/api/v1/search/user', params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['result'][0]).to be_falsey
|
expect(json_response['result'][0]).to be_falsey
|
||||||
end
|
end
|
||||||
|
@ -310,7 +310,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
it 'does searching for organization with a dot in its name' do
|
it 'does searching for organization with a dot in its name' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/search/organization?query=tes.', as: :json
|
get '/api/v1/search/organization?query=tes.', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['result'].size).to eq(1)
|
expect(json_response['result'].size).to eq(1)
|
||||||
expect(json_response['result'][0]['type']).to eq('Organization')
|
expect(json_response['result'][0]['type']).to eq('Organization')
|
||||||
target_id = json_response['result'][0]['id']
|
target_id = json_response['result'][0]['id']
|
||||||
|
@ -321,7 +321,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
it 'does searching for organization with _ in its name' do
|
it 'does searching for organization with _ in its name' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/search/organization?query=abc_', as: :json
|
get '/api/v1/search/organization?query=abc_', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['result'].size).to eq(1)
|
expect(json_response['result'].size).to eq(1)
|
||||||
expect(json_response['result'][0]['type']).to eq('Organization')
|
expect(json_response['result'][0]['type']).to eq('Organization')
|
||||||
target_id = json_response['result'][0]['id']
|
target_id = json_response['result'][0]['id']
|
||||||
|
|
|
@ -24,14 +24,14 @@ RSpec.describe 'Settings', type: :request do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['settings']).to be_falsey
|
expect(json_response['settings']).to be_falsey
|
||||||
|
|
||||||
# show
|
# show
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# index
|
# index
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
hit_api = false
|
hit_api = false
|
||||||
|
@ -59,13 +59,13 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# show
|
# show
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('product_name')
|
expect(json_response['name']).to eq('product_name')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'api_token_access')
|
setting = Setting.find_by(name: 'api_token_access')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('api_token_access')
|
expect(json_response['name']).to eq('api_token_access')
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('product_name')
|
expect(json_response['name']).to eq('product_name')
|
||||||
expect(json_response['preferences']['permission'].length).to eq(1)
|
expect(json_response['preferences']['permission'].length).to eq(1)
|
||||||
|
@ -98,7 +98,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('api_token_access')
|
expect(json_response['name']).to eq('api_token_access')
|
||||||
expect(json_response['preferences']['permission'].length).to eq(1)
|
expect(json_response['preferences']['permission'].length).to eq(1)
|
||||||
|
@ -108,7 +108,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# delete
|
# delete
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (feature not possible)')
|
expect(json_response['error']).to eq('Not authorized (feature not possible)')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# index
|
# index
|
||||||
authenticated_as(admin_api_user)
|
authenticated_as(admin_api_user)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
hit_api = false
|
hit_api = false
|
||||||
|
@ -136,12 +136,12 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# show
|
# show
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (required ["admin.branding"])')
|
expect(json_response['error']).to eq('Not authorized (required ["admin.branding"])')
|
||||||
|
|
||||||
setting = Setting.find_by(name: 'api_token_access')
|
setting = Setting.find_by(name: 'api_token_access')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('api_token_access')
|
expect(json_response['name']).to eq('api_token_access')
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (required ["admin.branding"])')
|
expect(json_response['error']).to eq('Not authorized (required ["admin.branding"])')
|
||||||
|
|
||||||
# update
|
# update
|
||||||
|
@ -170,7 +170,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
put "/api/v1/settings/#{setting.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['name']).to eq('api_token_access')
|
expect(json_response['name']).to eq('api_token_access')
|
||||||
expect(json_response['preferences']['permission'].length).to eq(1)
|
expect(json_response['preferences']['permission'].length).to eq(1)
|
||||||
|
@ -180,7 +180,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# delete
|
# delete
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (feature not possible)')
|
expect(json_response['error']).to eq('Not authorized (feature not possible)')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# index
|
# index
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['settings']).to be_falsey
|
expect(json_response['settings']).to be_falsey
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
@ -197,7 +197,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# show
|
# show
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['settings']).to be_falsey
|
expect(json_response['settings']).to be_falsey
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
@ -214,13 +214,13 @@ RSpec.describe 'Settings', type: :request do
|
||||||
# show
|
# show
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
get "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
|
|
||||||
# delete
|
# delete
|
||||||
setting = Setting.find_by(name: 'product_name')
|
setting = Setting.find_by(name: 'product_name')
|
||||||
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
delete "/api/v1/settings/#{setting.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe 'SLAs', type: :request do
|
||||||
|
|
||||||
it 'does index sla with nobody' do
|
it 'does index sla with nobody' do
|
||||||
get '/api/v1/slas', as: :json
|
get '/api/v1/slas', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
@ -19,19 +19,19 @@ RSpec.describe 'SLAs', type: :request do
|
||||||
it 'does index sla with admin' do
|
it 'does index sla with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/slas', as: :json
|
get '/api/v1/slas', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response.count).to eq(0)
|
expect(json_response.count).to eq(0)
|
||||||
|
|
||||||
get '/api/v1/slas?expand=true', as: :json
|
get '/api/v1/slas?expand=true', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response.count).to eq(0)
|
expect(json_response.count).to eq(0)
|
||||||
|
|
||||||
get '/api/v1/slas?full=true', as: :json
|
get '/api/v1/slas?full=true', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(json_response['record_ids']).to be_truthy
|
expect(json_response['record_ids']).to be_truthy
|
||||||
|
|
|
@ -34,7 +34,7 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
post '/api/v1/taskbar', params: params, as: :json
|
post '/api/v1/taskbar', params: params, as: :json
|
||||||
expect(response).to have_http_status(201)
|
expect(response).to have_http_status(:created)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['client_id']).to eq('123')
|
expect(json_response['client_id']).to eq('123')
|
||||||
expect(json_response['user_id']).to eq(agent_user.id)
|
expect(json_response['user_id']).to eq(agent_user.id)
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
shown: false,
|
shown: false,
|
||||||
}
|
}
|
||||||
put "/api/v1/taskbar/#{taskbar_id}", params: params, as: :json
|
put "/api/v1/taskbar/#{taskbar_id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['client_id']).to eq('123')
|
expect(json_response['client_id']).to eq('123')
|
||||||
expect(json_response['user_id']).to eq(agent_user.id)
|
expect(json_response['user_id']).to eq(agent_user.id)
|
||||||
|
@ -62,19 +62,19 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
put "/api/v1/taskbar/#{taskbar_id}", params: params, as: :json
|
put "/api/v1/taskbar/#{taskbar_id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not allowed to access this task.')
|
expect(json_response['error']).to eq('Not allowed to access this task.')
|
||||||
|
|
||||||
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to eq('Not allowed to access this task.')
|
expect(json_response['error']).to eq('Not allowed to access this task.')
|
||||||
|
|
||||||
# delete with correct user
|
# delete with correct user
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent_user)
|
||||||
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response).to be_blank
|
expect(json_response).to be_blank
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
it 'does csv example - customer no access' do
|
it 'does csv example - customer no access' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer_user)
|
||||||
get '/api/v1/text_modules/import_example', as: :json
|
get '/api/v1/text_modules/import_example', as: :json
|
||||||
expect(response).to have_http_status(401)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('Not authorized (user)!')
|
expect(json_response['error']).to eq('Not authorized (user)!')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
get '/api/v1/text_modules/import_example', as: :json
|
get '/api/v1/text_modules/import_example', as: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
rows = CSV.parse(@response.body)
|
rows = CSV.parse(@response.body)
|
||||||
header = rows.shift
|
header = rows.shift
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
expect(header[3]).to eq('content')
|
expect(header[3]).to eq('content')
|
||||||
expect(header[4]).to eq('note')
|
expect(header[4]).to eq('note')
|
||||||
expect(header[5]).to eq('active')
|
expect(header[5]).to eq('active')
|
||||||
expect(header).to_not include('organization')
|
expect(header).not_to include('organization')
|
||||||
expect(header).to_not include('priority')
|
expect(header).not_to include('priority')
|
||||||
expect(header).to_not include('state')
|
expect(header).not_to include('state')
|
||||||
expect(header).to_not include('owner')
|
expect(header).not_to include('owner')
|
||||||
expect(header).to_not include('customer')
|
expect(header).not_to include('customer')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does csv import - admin access' do
|
it 'does csv import - admin access' do
|
||||||
|
@ -51,7 +51,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin_user)
|
||||||
post '/api/v1/text_modules/import', params: { try: true, file: csv_file, col_sep: ';' }
|
post '/api/v1/text_modules/import', params: { try: true, file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to be_truthy
|
expect(json_response['try']).to be_truthy
|
||||||
|
@ -64,7 +64,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
# valid file try
|
# valid file try
|
||||||
csv_file = fixture_file_upload('csv_import/text_module/simple.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/text_module/simple.csv', 'text/csv')
|
||||||
post '/api/v1/text_modules/import?try=true', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/text_modules/import?try=true', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to be_truthy
|
expect(json_response['try']).to be_truthy
|
||||||
|
@ -77,7 +77,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
# valid file
|
# valid file
|
||||||
csv_file = fixture_file_upload('csv_import/text_module/simple.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/text_module/simple.csv', 'text/csv')
|
||||||
post '/api/v1/text_modules/import', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/text_modules/import', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
|
|
||||||
expect(json_response['try']).to eq(false)
|
expect(json_response['try']).to eq(false)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue