Refactoring: Restore consistency by replacing *_user suffix factories with just customer, admin and agent factory name.
This commit is contained in:
parent
6839d6e3e0
commit
83239518d0
80 changed files with 1092 additions and 1092 deletions
|
@ -1,7 +1,7 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :authorization do
|
factory :authorization do
|
||||||
transient do
|
transient do
|
||||||
user { create(:customer_user) }
|
user { create(:customer) }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :twitter_authorization do
|
factory :twitter_authorization do
|
||||||
|
|
|
@ -11,7 +11,7 @@ FactoryBot.define do
|
||||||
# assign to an existing user, if possible
|
# assign to an existing user, if possible
|
||||||
created_by_id do
|
created_by_id do
|
||||||
User.find { |u| u.role?(user_role.capitalize) }&.id ||
|
User.find { |u| u.role?(user_role.capitalize) }&.id ||
|
||||||
create("#{user_role}_user").id
|
create(user_role).id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,9 @@ FactoryBot.define do
|
||||||
title { 'Title dummy.' }
|
title { 'Title dummy.' }
|
||||||
body { 'Content dummy.' }
|
body { 'Content dummy.' }
|
||||||
sender_type { 'email-out' }
|
sender_type { 'email-out' }
|
||||||
customer { create(:customer_user) }
|
customer { create(:customer) }
|
||||||
group { Group.first }
|
group { Group.first }
|
||||||
owner { create(:agent_user) }
|
owner { create(:agent) }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :dummy_data do
|
trait :dummy_data do
|
||||||
|
|
|
@ -21,7 +21,7 @@ FactoryBot.define do
|
||||||
object.preferences[:intro] = true
|
object.preferences[:intro] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :customer_user, aliases: %i[customer] do
|
factory :customer do
|
||||||
role_ids { Role.signup_role_ids.sort }
|
role_ids { Role.signup_role_ids.sort }
|
||||||
|
|
||||||
trait :with_org do
|
trait :with_org do
|
||||||
|
@ -29,11 +29,11 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :agent_user, aliases: %i[agent] do
|
factory :agent do
|
||||||
roles { Role.where(name: 'Agent') }
|
roles { Role.where(name: 'Agent') }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :admin_user, aliases: %i[admin] do
|
factory :admin do
|
||||||
roles { Role.where(name: %w[Admin Agent]) }
|
roles { Role.where(name: %w[Admin Agent]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ RSpec.describe AutoWizard do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:group_agent) { create(:agent_user) }
|
let(:group_agent) { create(:agent) }
|
||||||
let(:group_signature) { create(:signature) }
|
let(:group_signature) { create(:signature) }
|
||||||
let(:group_email) { create(:email_address) }
|
let(:group_email) { create(:email_address) }
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ RSpec.describe NotificationFactory::Mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'recipient with email address' do
|
context 'recipient with email address' do
|
||||||
let(:user) { create(:agent_user, email: 'somebody@example.com') }
|
let(:user) { create(:agent, email: 'somebody@example.com') }
|
||||||
|
|
||||||
it 'returns a Mail::Message' do
|
it 'returns a Mail::Message' do
|
||||||
expect( result ).to be_kind_of(Mail::Message)
|
expect( result ).to be_kind_of(Mail::Message)
|
||||||
|
@ -109,7 +109,7 @@ RSpec.describe NotificationFactory::Mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'recipient without email address' do
|
context 'recipient without email address' do
|
||||||
let(:user) { create(:agent_user, email: '') }
|
let(:user) { create(:agent, email: '') }
|
||||||
|
|
||||||
it 'raises Exceptions::UnprocessableEntity' do
|
it 'raises Exceptions::UnprocessableEntity' do
|
||||||
expect { result }.to raise_error(Exceptions::UnprocessableEntity)
|
expect { result }.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
|
|
|
@ -19,8 +19,8 @@ RSpec.describe NotificationFactory::Slack do
|
||||||
|
|
||||||
let(:ticket) { article.ticket }
|
let(:ticket) { article.ticket }
|
||||||
let(:article) { create(:ticket_article) }
|
let(:article) { create(:ticket_article) }
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:current_user) { create(:agent_user) }
|
let(:current_user) { create(:agent) }
|
||||||
|
|
||||||
context 'for "ticket_create", with an empty "changes" hash' do
|
context 'for "ticket_create", with an empty "changes" hash' do
|
||||||
let(:action) { 'ticket_create' }
|
let(:action) { 'ticket_create' }
|
||||||
|
|
|
@ -35,7 +35,7 @@ RSpec.describe Sequencer::Unit::Import::Ldap::User::Attributes::RoleIds::Unassig
|
||||||
login: 'jane_doe' }.with_indifferent_access
|
login: 'jane_doe' }.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:instance) { create(:agent_user, mapped) }
|
let(:instance) { create(:agent, mapped) }
|
||||||
|
|
||||||
context 'when user exists from previous import' do
|
context 'when user exists from previous import' do
|
||||||
context 'and is active' do
|
context 'and is active' do
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe Sessions::Backend::ActivityStream do
|
RSpec.describe Sessions::Backend::ActivityStream do
|
||||||
context 'when async processes affect associated objects / DB records (#2066)' do
|
context 'when async processes affect associated objects / DB records (#2066)' do
|
||||||
let(:subject) { described_class.new(user, {}) }
|
let(:subject) { described_class.new(user, {}) }
|
||||||
let(:user) { create(:agent_user, groups: [group]) }
|
let(:user) { create(:agent, groups: [group]) }
|
||||||
let(:group) { Group.find_by(name: 'Users') }
|
let(:group) { Group.find_by(name: 'Users') }
|
||||||
let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) }
|
let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) }
|
||||||
let(:ticket_count) { 20 }
|
let(:ticket_count) { 20 }
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe Sessions::Backend::Base do
|
RSpec.describe Sessions::Backend::Base do
|
||||||
subject(:backend) { described_class.new(agent, {}, false, client_id, ttl) }
|
subject(:backend) { described_class.new(agent, {}, false, client_id, ttl) }
|
||||||
|
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:client_id) { '123-1' }
|
let(:client_id) { '123-1' }
|
||||||
let(:ttl) { 3 } # seconds
|
let(:ttl) { 3 } # seconds
|
||||||
let!(:ticket) { Ticket.first || create(:ticket) }
|
let!(:ticket) { Ticket.first || create(:ticket) }
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe Sessions::Backend::TicketOverviewList do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.push' do
|
describe '.push' do
|
||||||
let(:admin) { create(:admin_user, groups: [group]) }
|
let(:admin) { create(:admin, groups: [group]) }
|
||||||
let(:group) { create(:group) }
|
let(:group) { create(:group) }
|
||||||
let(:client_id) { '12345' }
|
let(:client_id) { '12345' }
|
||||||
let(:ttl) { 3 } # seconds
|
let(:ttl) { 3 } # seconds
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe Sessions::Event::ChatSessionStart do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:agent) do
|
let!(:agent) do
|
||||||
agent = create(:agent_user, preferences: { chat: { active: { chat.id.to_s => 'on' } } })
|
agent = create(:agent, preferences: { chat: { active: { chat.id.to_s => 'on' } } })
|
||||||
file = File.open('test/data/image/1000x1000.png', 'rb')
|
file = File.open('test/data/image/1000x1000.png', 'rb')
|
||||||
contents = file.read
|
contents = file.read
|
||||||
avatar = Avatar.add(
|
avatar = Avatar.add(
|
||||||
|
@ -35,7 +35,7 @@ RSpec.describe Sessions::Event::ChatSessionStart do
|
||||||
agent.save!
|
agent.save!
|
||||||
agent
|
agent
|
||||||
end
|
end
|
||||||
let!(:customer) { create(:customer_user) }
|
let!(:customer) { create(:customer) }
|
||||||
let(:subject_as_agent) do
|
let(:subject_as_agent) do
|
||||||
Sessions.create(client_id, { 'id' => agent.id }, {})
|
Sessions.create(client_id, { 'id' => agent.id }, {})
|
||||||
Sessions.queue(client_id)
|
Sessions.queue(client_id)
|
||||||
|
|
|
@ -15,9 +15,9 @@ RSpec.describe Sessions::Event::ChatTransfer do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:agent) do
|
let!(:agent) do
|
||||||
create(:agent_user, preferences: { chat: { active: { chat.id.to_s => 'on' } } })
|
create(:agent, preferences: { chat: { active: { chat.id.to_s => 'on' } } })
|
||||||
end
|
end
|
||||||
let!(:customer) { create(:customer_user) }
|
let!(:customer) { create(:customer) }
|
||||||
let(:subject_as_agent) do
|
let(:subject_as_agent) do
|
||||||
Sessions.create(client_id, { 'id' => agent.id }, {})
|
Sessions.create(client_id, { 'id' => agent.id }, {})
|
||||||
Sessions.queue(client_id)
|
Sessions.queue(client_id)
|
||||||
|
|
|
@ -158,7 +158,7 @@ RSpec.describe SignatureDetection do
|
||||||
|
|
||||||
describe '.rebuild_all_articles' do
|
describe '.rebuild_all_articles' do
|
||||||
context 'when a user exists with a recorded signature' do
|
context 'when a user exists with a recorded signature' do
|
||||||
let!(:customer) { create(:customer_user, preferences: { signature_detection: "\nbar" }) }
|
let!(:customer) { create(:customer, preferences: { signature_detection: "\nbar" }) }
|
||||||
|
|
||||||
context 'and multiple articles exist for that customer' do
|
context 'and multiple articles exist for that customer' do
|
||||||
let!(:articles) do
|
let!(:articles) do
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Stats::TicketWaitingTime do
|
RSpec.describe Stats::TicketWaitingTime do
|
||||||
describe '.generate' do
|
describe '.generate' do
|
||||||
let(:user) { create(:agent_user, groups: [group]) }
|
let(:user) { create(:agent, groups: [group]) }
|
||||||
let(:group) { create(:group) }
|
let(:group) { create(:group) }
|
||||||
|
|
||||||
context 'when given an agent with no tickets' do
|
context 'when given an agent with no tickets' do
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Stats do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# create a user for which the stats can be generated
|
# create a user for which the stats can be generated
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates stats' do
|
it 'generates stats' do
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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) }
|
||||||
|
|
||||||
describe '#assets (for supplying model data to front-end framework)' do
|
describe '#assets (for supplying model data to front-end framework)' do
|
||||||
shared_examples 'own asset attributes' do
|
shared_examples 'own asset attributes' do
|
||||||
|
|
|
@ -125,7 +125,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when from address matches an existing agent' do
|
context 'when from address matches an existing agent' do
|
||||||
let!(:agent) { create(:agent_user, email: 'foo@bar.com') }
|
let!(:agent) { create(:agent, email: 'foo@bar.com') }
|
||||||
|
|
||||||
it 'sets article.sender to "Agent"' do
|
it 'sets article.sender to "Agent"' do
|
||||||
described_class.new.process({}, raw_mail)
|
described_class.new.process({}, raw_mail)
|
||||||
|
@ -141,7 +141,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when from address matches an existing customer' do
|
context 'when from address matches an existing customer' do
|
||||||
let!(:customer) { create(:customer_user, email: 'foo@bar.com') }
|
let!(:customer) { create(:customer, email: 'foo@bar.com') }
|
||||||
|
|
||||||
it 'sets article.sender to "Customer"' do
|
it 'sets article.sender to "Customer"' do
|
||||||
described_class.new.process({}, raw_mail)
|
described_class.new.process({}, raw_mail)
|
||||||
|
@ -816,8 +816,8 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'assigning ticket.customer' do
|
describe 'assigning ticket.customer' do
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:customer) { create(:customer_user) }
|
let(:customer) { create(:customer) }
|
||||||
|
|
||||||
let(:raw_mail) { <<~RAW.chomp }
|
let(:raw_mail) { <<~RAW.chomp }
|
||||||
From: #{agent.email}
|
From: #{agent.email}
|
||||||
|
@ -1195,7 +1195,7 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
|
|
||||||
describe 'suppressing normal Ticket::Article callbacks' do
|
describe 'suppressing normal Ticket::Article callbacks' do
|
||||||
context 'from sender: "Agent"' do
|
context 'from sender: "Agent"' do
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
|
|
||||||
it 'does not dispatch an email on article creation' do
|
it 'does not dispatch an email on article creation' do
|
||||||
expect(TicketArticleCommunicateEmailJob).not_to receive(:perform_later)
|
expect(TicketArticleCommunicateEmailJob).not_to receive(:perform_later)
|
||||||
|
|
|
@ -91,7 +91,7 @@ RSpec.shared_examples 'HasHistory' do |history_relation_object: nil|
|
||||||
|
|
||||||
describe 'of #owner' do
|
describe 'of #owner' do
|
||||||
let(:attribute) { 'owner' }
|
let(:attribute) { 'owner' }
|
||||||
let(:new_value) { create(:customer_user) } # Ticket#owner is restricted to active agents of the same group
|
let(:new_value) { create(:customer) } # Ticket#owner is restricted to active agents of the same group
|
||||||
|
|
||||||
include_examples 'failed attribute update' if described_class.attribute_names.include?('owner_id')
|
include_examples 'failed attribute update' if described_class.attribute_names.include?('owner_id')
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,7 +146,7 @@ RSpec.describe Cti::CallerId do
|
||||||
|
|
||||||
describe '.rebuild' do
|
describe '.rebuild' do
|
||||||
context 'when a User record contains a valid phone number' do
|
context 'when a User record contains a valid phone number' do
|
||||||
let!(:user) { create(:agent_user, phone: '+49 123 456') }
|
let!(:user) { create(:agent, phone: '+49 123 456') }
|
||||||
|
|
||||||
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
|
||||||
|
@ -173,7 +173,7 @@ RSpec.describe Cti::CallerId do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when two User records contains the same valid phone number' do
|
context 'when two User records contains the same valid phone number' do
|
||||||
let!(:users) { create_list(:agent_user, 2, phone: '+49 123 456') }
|
let!(:users) { create_list(:agent, 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
|
||||||
described_class.destroy_all # CallerId already generated in User callback
|
described_class.destroy_all # CallerId already generated in User callback
|
||||||
|
@ -251,17 +251,17 @@ RSpec.describe Cti::CallerId do
|
||||||
|
|
||||||
describe '.known_agents_by_number' do
|
describe '.known_agents_by_number' do
|
||||||
context 'with known agent caller_id' do
|
context 'with known agent caller_id' do
|
||||||
let!(:agent_user1) { create(:agent_user, phone: '0123456') }
|
let!(:agent1) { create(:agent, phone: '0123456') }
|
||||||
let!(:agent_user2) { create(:agent_user, phone: '0123457') }
|
let!(:agent2) { create(:agent, phone: '0123457') }
|
||||||
|
|
||||||
it 'gives matching agents' do
|
it 'gives matching agents' do
|
||||||
expect(described_class.known_agents_by_number('49123456'))
|
expect(described_class.known_agents_by_number('49123456'))
|
||||||
.to match_array([agent_user1])
|
.to match_array([agent1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with known customer caller_id' do
|
context 'with known customer caller_id' do
|
||||||
let!(:customer_user1) { create(:customer_user, phone: '0123456') }
|
let!(:customer1) { create(:customer, phone: '0123456') }
|
||||||
|
|
||||||
it 'returns an empty array' do
|
it 'returns an empty array' do
|
||||||
expect(described_class.known_agents_by_number('49123456')).to eq([])
|
expect(described_class.known_agents_by_number('49123456')).to eq([])
|
||||||
|
@ -270,11 +270,11 @@ RSpec.describe Cti::CallerId do
|
||||||
|
|
||||||
context 'with maybe caller_id' do
|
context 'with maybe caller_id' do
|
||||||
let(:ticket1) do
|
let(:ticket1) do
|
||||||
create(:ticket_article, created_by_id: customer_user2.id, body: 'some text 0123457') # create ticket
|
create(:ticket_article, created_by_id: customer2.id, body: 'some text 0123457') # create ticket
|
||||||
Observer::Transaction.commit
|
Observer::Transaction.commit
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) { create(:customer_user) }
|
let!(:customer2) { create(:customer) }
|
||||||
|
|
||||||
it 'returns an empty array' do
|
it 'returns an empty array' do
|
||||||
expect(described_class.known_agents_by_number('49123457').count).to eq(0)
|
expect(described_class.known_agents_by_number('49123457').count).to eq(0)
|
||||||
|
|
|
@ -86,7 +86,7 @@ RSpec.describe Cti::Driver::Base do
|
||||||
describe '.push_open_ticket_screen_recipient' do
|
describe '.push_open_ticket_screen_recipient' do
|
||||||
context 'with direct number in answeringNumber params' do
|
context 'with direct number in answeringNumber params' do
|
||||||
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: user.phone } }
|
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: user.phone } }
|
||||||
let!(:user) { create(:agent_user, phone: '1234567') }
|
let!(:user) { create(:agent, phone: '1234567') }
|
||||||
|
|
||||||
it 'returns related user' do
|
it 'returns related user' do
|
||||||
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
||||||
|
@ -95,7 +95,7 @@ RSpec.describe Cti::Driver::Base do
|
||||||
|
|
||||||
context 'with not existing direct number in answeringNumber params' do
|
context 'with not existing direct number in answeringNumber params' do
|
||||||
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: '98765421' } }
|
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: '98765421' } }
|
||||||
let!(:user) { create(:agent_user, phone: '1234567') }
|
let!(:user) { create(:agent, phone: '1234567') }
|
||||||
|
|
||||||
it 'returns nil' do
|
it 'returns nil' do
|
||||||
expect(driver.push_open_ticket_screen_recipient).to be(nil)
|
expect(driver.push_open_ticket_screen_recipient).to be(nil)
|
||||||
|
@ -104,7 +104,7 @@ RSpec.describe Cti::Driver::Base do
|
||||||
|
|
||||||
context 'with real phone number in answeringNumber params' do
|
context 'with real phone number in answeringNumber params' do
|
||||||
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: '491711000001' } }
|
let(:params) { { 'direction' => direction, 'event' => event, answeringNumber: '491711000001' } }
|
||||||
let!(:user) { create(:agent_user, phone: '0171 1000001') }
|
let!(:user) { create(:agent, phone: '0171 1000001') }
|
||||||
|
|
||||||
it 'returns related user' do
|
it 'returns related user' do
|
||||||
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe Cti::Driver::Base do
|
||||||
|
|
||||||
context 'with user in upcase in params' do
|
context 'with user in upcase in params' do
|
||||||
let(:params) { { 'direction' => direction, 'event' => event, user: user.login.upcase } }
|
let(:params) { { 'direction' => direction, 'event' => event, user: user.login.upcase } }
|
||||||
let!(:user) { create(:agent_user) }
|
let!(:user) { create(:agent) }
|
||||||
|
|
||||||
it 'returns related user' do
|
it 'returns related user' do
|
||||||
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
||||||
|
@ -122,7 +122,7 @@ RSpec.describe Cti::Driver::Base do
|
||||||
|
|
||||||
context 'with user_id in params' do
|
context 'with user_id in params' do
|
||||||
let(:params) { { 'direction' => direction, 'event' => event, user_id: user.id } }
|
let(:params) { { 'direction' => direction, 'event' => event, user_id: user.id } }
|
||||||
let!(:user) { create(:agent_user) }
|
let!(:user) { create(:agent) }
|
||||||
|
|
||||||
it 'returns related user' do
|
it 'returns related user' do
|
||||||
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
expect(driver.push_open_ticket_screen_recipient).to eq(user)
|
||||||
|
|
|
@ -242,9 +242,9 @@ RSpec.describe Cti::Log do
|
||||||
described_class.process(attributes)
|
described_class.process(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:customer_user_of_ticket) { create(:customer_user) }
|
let(:customer_of_ticket) { create(:customer) }
|
||||||
let(:ticket_sample) do
|
let(:ticket_sample) do
|
||||||
create(:ticket_article, created_by_id: customer_user_of_ticket.id, body: 'some text 0123457')
|
create(:ticket_article, created_by_id: customer_of_ticket.id, body: 'some text 0123457')
|
||||||
Observer::Transaction.commit
|
Observer::Transaction.commit
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
end
|
end
|
||||||
|
@ -268,28 +268,28 @@ RSpec.describe Cti::Log do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with related known customer' do
|
context 'with related known customer' do
|
||||||
let!(:customer_user) { create(:customer_user, phone: '0123456') }
|
let!(:customer) { create(:customer, phone: '0123456') }
|
||||||
|
|
||||||
it 'gives caller information' do
|
it 'gives caller information' do
|
||||||
expect(log.preferences[:from].count).to eq(1)
|
expect(log.preferences[:from].count).to eq(1)
|
||||||
expect(log.preferences[:from].first)
|
expect(log.preferences[:from].first)
|
||||||
.to include(
|
.to include(
|
||||||
'level' => 'known',
|
'level' => 'known',
|
||||||
'user_id' => customer_user.id,
|
'user_id' => customer.id,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with related known customers' do
|
context 'with related known customers' do
|
||||||
let!(:customer_user1) { create(:customer_user, phone: '0123456') }
|
let!(:customer1) { create(:customer, phone: '0123456') }
|
||||||
let!(:customer_user2) { create(:customer_user, phone: '0123456') }
|
let!(:customer2) { create(:customer, phone: '0123456') }
|
||||||
|
|
||||||
it 'gives caller information' do
|
it 'gives caller information' do
|
||||||
expect(log.preferences[:from].count).to eq(2)
|
expect(log.preferences[:from].count).to eq(2)
|
||||||
expect(log.preferences[:from].first)
|
expect(log.preferences[:from].first)
|
||||||
.to include(
|
.to include(
|
||||||
'level' => 'known',
|
'level' => 'known',
|
||||||
'user_id' => customer_user2.id,
|
'user_id' => customer2.id,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -303,14 +303,14 @@ RSpec.describe Cti::Log do
|
||||||
expect(log.preferences[:from].first)
|
expect(log.preferences[:from].first)
|
||||||
.to include(
|
.to include(
|
||||||
'level' => 'maybe',
|
'level' => 'maybe',
|
||||||
'user_id' => customer_user_of_ticket.id,
|
'user_id' => customer_of_ticket.id,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with related maybe and known customer' do
|
context 'with related maybe and known customer' do
|
||||||
let(:caller_id) { '0123457' }
|
let(:caller_id) { '0123457' }
|
||||||
let!(:customer) { create(:customer_user, phone: '0123457') }
|
let!(:customer) { create(:customer, phone: '0123457') }
|
||||||
let!(:ticket) { ticket_sample }
|
let!(:ticket) { ticket_sample }
|
||||||
|
|
||||||
it 'gives caller information' do
|
it 'gives caller information' do
|
||||||
|
@ -471,12 +471,12 @@ RSpec.describe Cti::Log do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
let!(:agent1) { create(:agent_user, phone: '01234599') }
|
let!(:agent1) { create(:agent, phone: '01234599') }
|
||||||
let!(:customer2) { create(:customer_user, phone: '') }
|
let!(:customer2) { create(:customer, phone: '') }
|
||||||
let!(:ticket_article1) { create(:ticket_article, created_by_id: customer2.id, body: 'some text 01234599') }
|
let!(:ticket_article1) { create(:ticket_article, created_by_id: customer2.id, body: 'some text 01234599') }
|
||||||
|
|
||||||
context 'with agent1 (known), customer1 (known) and customer2 (maybe)' do
|
context 'with agent1 (known), customer1 (known) and customer2 (maybe)' do
|
||||||
let!(:customer1) { create(:customer_user, phone: '01234599') }
|
let!(:customer1) { create(:customer, phone: '01234599') }
|
||||||
|
|
||||||
it 'gives customer1' do
|
it 'gives customer1' do
|
||||||
expect(log1.best_customer_id_of_log_entry).to eq(customer1.id)
|
expect(log1.best_customer_id_of_log_entry).to eq(customer1.id)
|
||||||
|
|
|
@ -204,7 +204,7 @@ RSpec.describe Job, type: :model do
|
||||||
|
|
||||||
context 'when job has pre_condition:current_user.id in selector' do
|
context 'when job has pre_condition:current_user.id in selector' do
|
||||||
let!(:matching_ticket) { create(:ticket, owner_id: 1) }
|
let!(:matching_ticket) { create(:ticket, owner_id: 1) }
|
||||||
let!(:nonmatching_ticket) { create(:ticket, owner_id: create(:agent_user).id) }
|
let!(:nonmatching_ticket) { create(:ticket, owner_id: create(:agent).id) }
|
||||||
|
|
||||||
let(:condition) do
|
let(:condition) do
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ RSpec.describe Job, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
UserInfo.current_user_id = create(:admin_user).id
|
UserInfo.current_user_id = create(:admin).id
|
||||||
job
|
job
|
||||||
UserInfo.current_user_id = nil
|
UserInfo.current_user_id = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ require 'models/contexts/factory_context'
|
||||||
RSpec.describe KnowledgeBase::Answer::Translation, type: :model, current_user_id: 1, searchindex: 1 do
|
RSpec.describe KnowledgeBase::Answer::Translation, type: :model, current_user_id: 1, searchindex: 1 do
|
||||||
include_context 'basic Knowledge Base'
|
include_context 'basic Knowledge Base'
|
||||||
|
|
||||||
let(:user) { create(:admin_user) }
|
let(:user) { create(:admin) }
|
||||||
let(:filename) { 'test.rtf' }
|
let(:filename) { 'test.rtf' }
|
||||||
let(:query) { 'RTF document' }
|
let(:query) { 'RTF document' }
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ RSpec.describe KnowledgeBase, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'skip activity check for editors when filtering by activity' do
|
it 'skip activity check for editors when filtering by activity' do
|
||||||
user = create(:admin_user)
|
user = create(:admin)
|
||||||
expect(described_class.check_active_unless_editor(user).count).to eq(2)
|
expect(described_class.check_active_unless_editor(user).count).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'check activity if user is not editor when filtering by activity' do
|
it 'check activity if user is not editor when filtering by activity' do
|
||||||
user = create(:agent_user)
|
user = create(:agent)
|
||||||
expect(described_class.check_active_unless_editor(user)).to contain_exactly(knowledge_base)
|
expect(described_class.check_active_unless_editor(user)).to contain_exactly(knowledge_base)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe ::ObjectManager::Attribute::Validation::Required do
|
||||||
|
|
||||||
shared_examples 'a permission based validator' do |permission:|
|
shared_examples 'a permission based validator' do |permission:|
|
||||||
|
|
||||||
let(:performing_user) { create(:agent_user) }
|
let(:performing_user) { create(:agent) }
|
||||||
|
|
||||||
before { UserInfo.current_user_id = performing_user.id }
|
before { UserInfo.current_user_id = performing_user.id }
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ RSpec.describe ::ObjectManager::Attribute::Validation::Required do
|
||||||
|
|
||||||
context 'for required => false' do
|
context 'for required => false' do
|
||||||
|
|
||||||
let(:performing_user) { create(:agent_user) }
|
let(:performing_user) { create(:agent) }
|
||||||
|
|
||||||
before { UserInfo.current_user_id = performing_user.id }
|
before { UserInfo.current_user_id = performing_user.id }
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ RSpec.describe Organization, type: :model do
|
||||||
|
|
||||||
describe 'Callbacks, Observers, & Async Transactions -' do
|
describe 'Callbacks, Observers, & Async Transactions -' do
|
||||||
describe 'Touching associations on update:' do
|
describe 'Touching associations on update:' do
|
||||||
let!(:member) { create(:customer_user, organization: organization) }
|
let!(:member) { create(:customer, organization: organization) }
|
||||||
let!(:member_ticket) { create(:ticket, customer: member) }
|
let!(:member_ticket) { create(:ticket, customer: member) }
|
||||||
|
|
||||||
context 'when member associations are added' do
|
context 'when member associations are added' do
|
||||||
let(:user) { create(:customer_user) }
|
let(:user) { create(:customer) }
|
||||||
|
|
||||||
it 'is touched, and touches its other members (but not their tickets)' do
|
it 'is touched, and touches its other members (but not their tickets)' do
|
||||||
expect { organization.members.push(user) }
|
expect { organization.members.push(user) }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe RecentView, type: :model do
|
RSpec.describe RecentView, type: :model do
|
||||||
let(:admin) { create(:admin_user) }
|
let(:admin) { create(:admin) }
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:customer) { create(:customer_user) }
|
let(:customer) { create(:customer) }
|
||||||
let(:ticket) { create(:ticket, owner: owner, customer: customer) }
|
let(:ticket) { create(:ticket, owner: owner, customer: customer) }
|
||||||
let(:tickets) { create_list(:ticket, 15, owner: owner, customer: customer) }
|
let(:tickets) { create_list(:ticket, 15, owner: owner, customer: customer) }
|
||||||
let(:owner) { admin }
|
let(:owner) { admin }
|
||||||
|
|
|
@ -192,8 +192,8 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar3.preferences[:tasks][0][:user_id]).to eq(2)
|
expect(taskbar3.preferences[:tasks][0][:user_id]).to eq(2)
|
||||||
expect(taskbar3.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar3.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
|
|
||||||
agent_user_id = create(:agent_user).id
|
agent_id = create(:agent).id
|
||||||
UserInfo.current_user_id = agent_user_id
|
UserInfo.current_user_id = agent_id
|
||||||
|
|
||||||
taskbar4 = described_class.create(
|
taskbar4 = described_class.create(
|
||||||
client_id: 123,
|
client_id: 123,
|
||||||
|
@ -213,7 +213,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar2.reload
|
taskbar2.reload
|
||||||
|
@ -222,7 +222,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
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)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar3.reload
|
taskbar3.reload
|
||||||
|
@ -236,7 +236,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
|
@ -249,7 +249,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar2.reload
|
taskbar2.reload
|
||||||
|
@ -258,7 +258,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
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)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar3.reload
|
taskbar3.reload
|
||||||
|
@ -272,7 +272,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
UserInfo.current_user_id = 2
|
UserInfo.current_user_id = 2
|
||||||
|
@ -285,7 +285,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar2.reload
|
taskbar2.reload
|
||||||
|
@ -294,7 +294,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
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(true)
|
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar3.reload
|
taskbar3.reload
|
||||||
|
@ -308,7 +308,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
@ -321,7 +321,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(true)
|
expect(taskbar1.preferences[:tasks][0][:changed]).to eq(true)
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar2.reload
|
taskbar2.reload
|
||||||
|
@ -330,7 +330,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(true)
|
expect(taskbar2.preferences[:tasks][0][:changed]).to eq(true)
|
||||||
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(true)
|
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar3.reload
|
taskbar3.reload
|
||||||
|
@ -344,7 +344,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(true)
|
expect(taskbar4.preferences[:tasks][0][:changed]).to eq(true)
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
|
|
||||||
taskbar1_last_contact = taskbar1.last_contact.to_s
|
taskbar1_last_contact = taskbar1.last_contact.to_s
|
||||||
|
@ -366,7 +366,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar1.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
expect(taskbar1.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar1.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
@ -378,7 +378,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(true)
|
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar2.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
expect(taskbar2.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar2.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar2.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar4.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
expect(taskbar4.preferences[:tasks][1][:last_contact].to_s).to eq(taskbar2_last_contact)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar4.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar1.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar1.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar1.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
expect(taskbar1.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
||||||
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar1.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar1.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar1.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar1.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
@ -425,7 +425,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(true)
|
expect(taskbar2.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar2.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
expect(taskbar2.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
||||||
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar2.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar2.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar2.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar2.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ RSpec.describe Taskbar do
|
||||||
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
expect(taskbar4.preferences[:tasks][1][:user_id]).to eq(2)
|
||||||
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
expect(taskbar4.preferences[:tasks][1][:changed]).to eq(true)
|
||||||
expect(taskbar4.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
expect(taskbar4.preferences[:tasks][1][:last_contact].to_s).not_to eq(taskbar2_last_contact)
|
||||||
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_user_id)
|
expect(taskbar4.preferences[:tasks][2][:user_id]).to eq(agent_id)
|
||||||
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
expect(taskbar4.preferences[:tasks][2][:changed]).to eq(false)
|
||||||
expect(taskbar4.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
expect(taskbar4.preferences[:tasks][2][:last_contact].to_s).to eq(taskbar4_last_contact)
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
#
|
#
|
||||||
# Notification triggers should log notification as private or public
|
# Notification triggers should log notification as private or public
|
||||||
# according to given configuration
|
# according to given configuration
|
||||||
let(:user) { create(:admin_user, mobile: '+37061010000') }
|
let(:user) { create(:admin, mobile: '+37061010000') }
|
||||||
|
|
||||||
before { ticket.group.users << user }
|
before { ticket.group.users << user }
|
||||||
|
|
||||||
|
@ -386,13 +386,13 @@ RSpec.describe Ticket, type: :model do
|
||||||
|
|
||||||
describe 'Attributes:' do
|
describe 'Attributes:' do
|
||||||
describe '#owner' do
|
describe '#owner' do
|
||||||
let(:original_owner) { create(:agent_user, groups: [ticket.group]) }
|
let(:original_owner) { create(:agent, groups: [ticket.group]) }
|
||||||
|
|
||||||
before { ticket.update(owner: original_owner) }
|
before { ticket.update(owner: original_owner) }
|
||||||
|
|
||||||
context 'when assigned directly' do
|
context 'when assigned directly' do
|
||||||
context 'to an active agent belonging to ticket.group' do
|
context 'to an active agent belonging to ticket.group' do
|
||||||
let(:agent) { create(:agent_user, groups: [ticket.group]) }
|
let(:agent) { create(:agent, groups: [ticket.group]) }
|
||||||
|
|
||||||
it 'can be set' do
|
it 'can be set' do
|
||||||
expect { ticket.update(owner: agent) }
|
expect { ticket.update(owner: agent) }
|
||||||
|
@ -401,7 +401,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'to an agent not belonging to ticket.group' do
|
context 'to an agent not belonging to ticket.group' do
|
||||||
let(:agent) { create(:agent_user, groups: [other_group]) }
|
let(:agent) { create(:agent, groups: [other_group]) }
|
||||||
let(:other_group) { create(:group) }
|
let(:other_group) { create(:group) }
|
||||||
|
|
||||||
it 'resets to default user (id: 1) instead' do
|
it 'resets to default user (id: 1) instead' do
|
||||||
|
@ -411,7 +411,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'to an inactive agent' do
|
context 'to an inactive agent' do
|
||||||
let(:agent) { create(:agent_user, groups: [ticket.group], active: false) }
|
let(:agent) { create(:agent, groups: [ticket.group], active: false) }
|
||||||
|
|
||||||
it 'resets to default user (id: 1) instead' do
|
it 'resets to default user (id: 1) instead' do
|
||||||
expect { ticket.update(owner: agent) }
|
expect { ticket.update(owner: agent) }
|
||||||
|
@ -420,7 +420,7 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'to a non-agent' do
|
context 'to a non-agent' do
|
||||||
let(:agent) { create(:customer_user, groups: [ticket.group]) }
|
let(:agent) { create(:customer, groups: [ticket.group]) }
|
||||||
|
|
||||||
it 'resets to default user (id: 1) instead' do
|
it 'resets to default user (id: 1) instead' do
|
||||||
expect { ticket.update(owner: agent) }
|
expect { ticket.update(owner: agent) }
|
||||||
|
@ -763,9 +763,9 @@ 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, organization: organization) }
|
||||||
let(:organization) { create(:organization) }
|
let(:organization) { create(:organization) }
|
||||||
let(:other_customer) { create(:customer_user, organization: other_organization) }
|
let(:other_customer) { create(:customer, organization: other_organization) }
|
||||||
let(:other_organization) { create(:organization) }
|
let(:other_organization) { create(:organization) }
|
||||||
|
|
||||||
context 'on creation' do
|
context 'on creation' do
|
||||||
|
|
|
@ -80,7 +80,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) }
|
||||||
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.*
|
||||||
|
|
||||||
context 'with a permission shared by both token.user and token.preferences' do
|
context 'with a permission shared by both token.user and token.preferences' do
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe Trigger do
|
||||||
|
|
||||||
context 'sends interpolated, html-free SMS' do
|
context 'sends interpolated, html-free SMS' do
|
||||||
before do
|
before do
|
||||||
another_agent = create(:admin_user, mobile: '+37061010000')
|
another_agent = create(:admin, mobile: '+37061010000')
|
||||||
Group.lookup(id: 1).users << another_agent
|
Group.lookup(id: 1).users << another_agent
|
||||||
|
|
||||||
create(:channel, area: 'Sms::Notification')
|
create(:channel, area: 'Sms::Notification')
|
||||||
|
@ -30,7 +30,7 @@ RSpec.describe Trigger do
|
||||||
|
|
||||||
let(:message_body) { 'space between #{ticket.title} #{ticket.created_at}' } # rubocop:disable Lint/InterpolationCheck
|
let(:message_body) { 'space between #{ticket.title} #{ticket.created_at}' } # rubocop:disable Lint/InterpolationCheck
|
||||||
|
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:ticket) do
|
let(:ticket) do
|
||||||
ticket = create(:ticket, group: Group.lookup(id: 1), created_by_id: agent.id)
|
ticket = create(:ticket, group: Group.lookup(id: 1), created_by_id: agent.id)
|
||||||
Observer::Transaction.commit
|
Observer::Transaction.commit
|
||||||
|
@ -64,14 +64,14 @@ RSpec.describe Trigger do
|
||||||
|
|
||||||
context 'recipients' do
|
context 'recipients' do
|
||||||
|
|
||||||
let(:recipient1) { create(:agent_user, mobile: '+37061010000', groups: [ticket_group]) }
|
let(:recipient1) { create(:agent, mobile: '+37061010000', groups: [ticket_group]) }
|
||||||
let(:recipient2) { create(:agent_user, mobile: '+37061010001', groups: [ticket_group]) }
|
let(:recipient2) { create(:agent, mobile: '+37061010001', groups: [ticket_group]) }
|
||||||
let(:recipient3) { create(:agent_user, mobile: '+37061010002', groups: [ticket_group]) }
|
let(:recipient3) { create(:agent, mobile: '+37061010002', groups: [ticket_group]) }
|
||||||
|
|
||||||
let(:ticket_group) { create(:group) }
|
let(:ticket_group) { create(:group) }
|
||||||
|
|
||||||
let(:ticket) do
|
let(:ticket) do
|
||||||
ticket = create(:ticket, group: ticket_group, created_by_id: create(:agent_user).id)
|
ticket = create(:ticket, group: ticket_group, created_by_id: create(:agent).id)
|
||||||
Observer::Transaction.commit
|
Observer::Transaction.commit
|
||||||
ticket
|
ticket
|
||||||
end
|
end
|
||||||
|
|
|
@ -197,7 +197,7 @@ RSpec.describe Trigger, type: :model do
|
||||||
let(:email_address) { create(:email_address, email: system_email_address) }
|
let(:email_address) { create(:email_address, email: system_email_address) }
|
||||||
|
|
||||||
let(:group) { create(:group, email_address: email_address) }
|
let(:group) { create(:group, email_address: email_address) }
|
||||||
let(:customer) { create(:customer_user, email: customer_email_address) }
|
let(:customer) { create(:customer, email: customer_email_address) }
|
||||||
|
|
||||||
let(:security_preferences) { Ticket::Article.last.preferences[:security] }
|
let(:security_preferences) { Ticket::Article.last.preferences[:security] }
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ RSpec.describe Trigger, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:user) do
|
let(:user) do
|
||||||
user = create(:agent_user)
|
user = create(:agent)
|
||||||
user.roles.first.groups << group
|
user.roles.first.groups << group
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ RSpec.shared_examples 'CanLookupSearchIndexAttributes' do
|
||||||
describe '.search_index_value_by_attribute' do
|
describe '.search_index_value_by_attribute' do
|
||||||
it 'returns search index value for attribute' do
|
it 'returns search index value for attribute' do
|
||||||
organization = create(:organization, name: 'Tomato42', note: 'special recipe')
|
organization = create(:organization, name: 'Tomato42', note: 'special recipe')
|
||||||
user = create(:agent_user, organization: organization)
|
user = create(:agent, organization: organization)
|
||||||
|
|
||||||
value = user.search_index_value_by_attribute('organization_id')
|
value = user.search_index_value_by_attribute('organization_id')
|
||||||
expect(value).to eq('Tomato42')
|
expect(value).to eq('Tomato42')
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe UserDevice, type: :model do
|
||||||
describe '.add' do
|
describe '.add' do
|
||||||
let(:existing_record) { described_class.add(user_agent, ip, agent.id, fingerprint, type) }
|
let(:existing_record) { described_class.add(user_agent, ip, agent.id, fingerprint, type) }
|
||||||
let(:ip) { '91.115.248.231' }
|
let(:ip) { '91.115.248.231' }
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
|
|
||||||
context 'with existing record of type: "session"' do
|
context 'with existing record of type: "session"' do
|
||||||
before { existing_record } # create existing record
|
before { existing_record } # create existing record
|
||||||
|
@ -184,7 +184,7 @@ RSpec.describe UserDevice, type: :model do
|
||||||
let(:user_device) { described_class.add(user_agent, ip, agent.id, fingerprint, type) }
|
let(:user_device) { described_class.add(user_agent, ip, agent.id, fingerprint, type) }
|
||||||
let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36' }
|
let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36' }
|
||||||
let(:ip) { '91.115.248.231' }
|
let(:ip) { '91.115.248.231' }
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:fingerprint) { 'fingerprint1234' }
|
let(:fingerprint) { 'fingerprint1234' }
|
||||||
let(:type) { 'session' }
|
let(:type) { 'session' }
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ RSpec.describe UserDevice, type: :model do
|
||||||
let(:type) { 'session' }
|
let(:type) { 'session' }
|
||||||
|
|
||||||
context 'user with email address' do
|
context 'user with email address' do
|
||||||
let(:agent) { create(:agent_user, email: 'somebody@example.com') }
|
let(:agent) { create(:agent, email: 'somebody@example.com') }
|
||||||
|
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
expect(user_device.notification_send('user_device_new_location'))
|
expect(user_device.notification_send('user_device_new_location'))
|
||||||
|
@ -237,7 +237,7 @@ RSpec.describe UserDevice, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user without email address' do
|
context 'user without email address' do
|
||||||
let(:agent) { create(:agent_user, email: '') }
|
let(:agent) { create(:agent, email: '') }
|
||||||
|
|
||||||
it 'returns false' do
|
it 'returns false' do
|
||||||
expect(user_device.notification_send('user_device_new_location'))
|
expect(user_device.notification_send('user_device_new_location'))
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'models/concerns/has_group_relation_definition_examples'
|
||||||
|
|
||||||
RSpec.describe UserGroup do
|
RSpec.describe UserGroup do
|
||||||
|
|
||||||
let!(:group_relation_instance) { create(:agent_user) }
|
let!(:group_relation_instance) { create(:agent) }
|
||||||
|
|
||||||
it_behaves_like 'HasGroupRelationDefinition'
|
it_behaves_like 'HasGroupRelationDefinition'
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,14 +13,14 @@ require 'models/user/can_lookup_search_index_attributes_examples'
|
||||||
RSpec.describe User, type: :model do
|
RSpec.describe User, type: :model do
|
||||||
subject(:user) { create(:user) }
|
subject(:user) { create(:user) }
|
||||||
|
|
||||||
let(:customer) { create(:customer_user) }
|
let(:customer) { create(:customer) }
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
let(:admin) { create(:admin_user) }
|
let(:admin) { create(:admin) }
|
||||||
|
|
||||||
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
|
||||||
it_behaves_like 'HasHistory'
|
it_behaves_like 'HasHistory'
|
||||||
it_behaves_like 'HasRoles', group_access_factory: :agent_user
|
it_behaves_like 'HasRoles', group_access_factory: :agent
|
||||||
it_behaves_like 'HasXssSanitizedNote', model_factory: :user
|
it_behaves_like 'HasXssSanitizedNote', model_factory: :user
|
||||||
it_behaves_like 'HasGroups and Permissions', group_access_no_permission_factory: :user
|
it_behaves_like 'HasGroups and Permissions', group_access_no_permission_factory: :user
|
||||||
it_behaves_like 'CanBeImported'
|
it_behaves_like 'CanBeImported'
|
||||||
|
@ -310,7 +310,7 @@ RSpec.describe User, type: :model do
|
||||||
context 'when designated as the substitute' do
|
context 'when designated as the substitute' do
|
||||||
let!(:agent_on_holiday) do
|
let!(:agent_on_holiday) do
|
||||||
create(
|
create(
|
||||||
:agent_user,
|
:agent,
|
||||||
out_of_office_start_at: Time.current.yesterday,
|
out_of_office_start_at: Time.current.yesterday,
|
||||||
out_of_office_end_at: Time.current.tomorrow,
|
out_of_office_end_at: Time.current.tomorrow,
|
||||||
out_of_office_replacement_id: agent.id,
|
out_of_office_replacement_id: agent.id,
|
||||||
|
@ -867,19 +867,19 @@ RSpec.describe User, type: :model do
|
||||||
before { Setting.set('system_agent_limit', current_agents.count + 1) }
|
before { Setting.set('system_agent_limit', current_agents.count + 1) }
|
||||||
|
|
||||||
it 'grants agent creation' do
|
it 'grants agent creation' do
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent) }
|
||||||
.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)
|
||||||
|
|
||||||
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
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
|
|
||||||
it 'grants update by instances' do
|
it 'grants update by instances' do
|
||||||
expect { agent.roles = [admin_role, agent_role] }
|
expect { agent.roles = [admin_role, agent_role] }
|
||||||
|
@ -902,9 +902,9 @@ RSpec.describe User, type: :model do
|
||||||
it 'creation of new agents' do
|
it 'creation of new agents' do
|
||||||
Setting.set('system_agent_limit', current_agents.count + 2)
|
Setting.set('system_agent_limit', current_agents.count + 2)
|
||||||
|
|
||||||
create_list(:agent_user, 2)
|
create_list(:agent, 2)
|
||||||
|
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent) }
|
||||||
.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
|
||||||
|
@ -912,7 +912,7 @@ RSpec.describe User, type: :model do
|
||||||
it 'prevents role change' do
|
it 'prevents role change' do
|
||||||
Setting.set('system_agent_limit', current_agents.count)
|
Setting.set('system_agent_limit', current_agents.count)
|
||||||
|
|
||||||
future_agent = create(:customer_user)
|
future_agent = create(:customer)
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
|
@ -926,19 +926,19 @@ RSpec.describe User, type: :model do
|
||||||
before { Setting.set('system_agent_limit', (current_agents.count + 1).to_s) }
|
before { Setting.set('system_agent_limit', (current_agents.count + 1).to_s) }
|
||||||
|
|
||||||
it 'grants agent creation' do
|
it 'grants agent creation' do
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent) }
|
||||||
.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)
|
||||||
|
|
||||||
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
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
|
|
||||||
it 'grants update by instances' do
|
it 'grants update by instances' do
|
||||||
expect { agent.roles = [admin_role, agent_role] }
|
expect { agent.roles = [admin_role, agent_role] }
|
||||||
|
@ -961,9 +961,9 @@ RSpec.describe User, type: :model do
|
||||||
it 'creation of new agents' do
|
it 'creation of new agents' do
|
||||||
Setting.set('system_agent_limit', (current_agents.count + 2).to_s)
|
Setting.set('system_agent_limit', (current_agents.count + 2).to_s)
|
||||||
|
|
||||||
create_list(:agent_user, 2)
|
create_list(:agent, 2)
|
||||||
|
|
||||||
expect { create(:agent_user) }
|
expect { create(:agent) }
|
||||||
.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
|
||||||
|
@ -971,7 +971,7 @@ RSpec.describe User, type: :model do
|
||||||
it 'prevents role change' do
|
it 'prevents role change' do
|
||||||
Setting.set('system_agent_limit', current_agents.count.to_s)
|
Setting.set('system_agent_limit', current_agents.count.to_s)
|
||||||
|
|
||||||
future_agent = create(:customer_user)
|
future_agent = create(:customer)
|
||||||
|
|
||||||
expect { future_agent.roles = [agent_role] }
|
expect { future_agent.roles = [agent_role] }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
|
@ -987,7 +987,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'when exceeding the agent limit' do
|
context 'when exceeding the agent limit' do
|
||||||
it 'prevents re-activation of agents' do
|
it 'prevents re-activation of agents' do
|
||||||
inactive_agent = create(:agent_user, active: false)
|
inactive_agent = create(:agent, active: false)
|
||||||
|
|
||||||
expect { inactive_agent.update!(active: true) }
|
expect { inactive_agent.update!(active: true) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
|
@ -1001,7 +1001,7 @@ RSpec.describe User, type: :model do
|
||||||
|
|
||||||
context 'when exceeding the agent limit' do
|
context 'when exceeding the agent limit' do
|
||||||
it 'prevents re-activation of agents' do
|
it 'prevents re-activation of agents' do
|
||||||
inactive_agent = create(:agent_user, active: false)
|
inactive_agent = create(:agent, active: false)
|
||||||
|
|
||||||
expect { inactive_agent.update!(active: true) }
|
expect { inactive_agent.update!(active: true) }
|
||||||
.to raise_error(Exceptions::UnprocessableEntity)
|
.to raise_error(Exceptions::UnprocessableEntity)
|
||||||
|
@ -1013,7 +1013,7 @@ RSpec.describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Touching associations on update:' do
|
describe 'Touching associations on update:' do
|
||||||
subject!(:user) { create(:customer_user) }
|
subject!(:user) { create(:customer) }
|
||||||
|
|
||||||
let!(:organization) { create(:organization) }
|
let!(:organization) { create(:organization) }
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe TicketPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when given a user that is neither owner nor customer' do
|
context 'when given a user that is neither owner nor customer' do
|
||||||
let(:user) { create(:agent_user) }
|
let(:user) { create(:agent) }
|
||||||
|
|
||||||
it { is_expected.not_to permit_actions(%i[show full]) }
|
it { is_expected.not_to permit_actions(%i[show full]) }
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ describe TicketPolicy 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
|
||||||
let(:record) { create(:ticket, customer: customer) }
|
let(:record) { create(:ticket, customer: customer) }
|
||||||
let(:customer) { create(:customer_user, organization: create(:organization)) }
|
let(:customer) { create(:customer, organization: create(:organization)) }
|
||||||
let(:user) { create(:customer_user, organization: customer.organization) }
|
let(:user) { create(:customer, organization: customer.organization) }
|
||||||
|
|
||||||
context 'and organization.shared is true (default)' do
|
context 'and organization.shared is true (default)' do
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,19 @@ describe UserPolicy do
|
||||||
context 'wants to read, change, or delete any user' do
|
context 'wants to read, change, or delete any user' do
|
||||||
|
|
||||||
context 'when record is an admin user' do
|
context 'when record is an admin user' do
|
||||||
let(:record) { create(:admin_user) }
|
let(:record) { create(:admin) }
|
||||||
|
|
||||||
it { is_expected.to permit_actions(%i[show update destroy]) }
|
it { is_expected.to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is an agent user' do
|
context 'when record is an agent user' do
|
||||||
let(:record) { create(:agent_user) }
|
let(:record) { create(:agent) }
|
||||||
|
|
||||||
it { is_expected.to permit_actions(%i[show update destroy]) }
|
it { is_expected.to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is a customer user' do
|
context 'when record is a customer user' do
|
||||||
let(:record) { create(:customer_user) }
|
let(:record) { create(:customer) }
|
||||||
|
|
||||||
it { is_expected.to permit_actions(%i[show update destroy]) }
|
it { is_expected.to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
@ -51,21 +51,21 @@ describe UserPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is an admin user' do
|
context 'when record is an admin user' do
|
||||||
let(:record) { create(:admin_user) }
|
let(:record) { create(:admin) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is an agent user' do
|
context 'when record is an agent user' do
|
||||||
let(:record) { create(:agent_user) }
|
let(:record) { create(:agent) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is a customer user' do
|
context 'when record is a customer user' do
|
||||||
let(:record) { create(:customer_user) }
|
let(:record) { create(:customer) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
|
@ -88,24 +88,24 @@ describe UserPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is an agent' do
|
context 'when user is an agent' do
|
||||||
let(:user) { create(:agent_user) }
|
let(:user) { create(:agent) }
|
||||||
|
|
||||||
context 'when record is an admin user' do
|
context 'when record is an admin user' do
|
||||||
let(:record) { create(:admin_user) }
|
let(:record) { create(:admin) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is an agent user' do
|
context 'when record is an agent user' do
|
||||||
let(:record) { create(:agent_user) }
|
let(:record) { create(:agent) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is a customer user' do
|
context 'when record is a customer user' do
|
||||||
let(:record) { create(:customer_user) }
|
let(:record) { create(:customer) }
|
||||||
|
|
||||||
it { is_expected.to permit_actions(%i[show update]) }
|
it { is_expected.to permit_actions(%i[show update]) }
|
||||||
it { is_expected.not_to permit_action(:destroy) }
|
it { is_expected.not_to permit_action(:destroy) }
|
||||||
|
@ -127,22 +127,22 @@ describe UserPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is a customer' do
|
context 'when user is a customer' do
|
||||||
let(:user) { create(:customer_user) }
|
let(:user) { create(:customer) }
|
||||||
|
|
||||||
context 'when record is an admin user' do
|
context 'when record is an admin user' do
|
||||||
let(:record) { create(:admin_user) }
|
let(:record) { create(:admin) }
|
||||||
|
|
||||||
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is an agent user' do
|
context 'when record is an agent user' do
|
||||||
let(:record) { create(:agent_user) }
|
let(:record) { create(:agent) }
|
||||||
|
|
||||||
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is a customer user' do
|
context 'when record is a customer user' do
|
||||||
let(:record) { create(:customer_user) }
|
let(:record) { create(:customer) }
|
||||||
|
|
||||||
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
it { is_expected.not_to permit_actions(%i[show update destroy]) }
|
||||||
end
|
end
|
||||||
|
@ -154,8 +154,8 @@ describe UserPolicy do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when record is a colleague' do
|
context 'when record is a colleague' do
|
||||||
let(:user) { create(:customer_user, :with_org) }
|
let(:user) { create(:customer, :with_org) }
|
||||||
let(:record) { create(:customer_user, organization: user.organization) }
|
let(:record) { create(:customer, organization: user.organization) }
|
||||||
|
|
||||||
it { is_expected.to permit_action(:show) }
|
it { is_expected.to permit_action(:show) }
|
||||||
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
it { is_expected.not_to permit_actions(%i[update destroy]) }
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -20,16 +20,16 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.id)
|
authenticated_as(admin, on_behalf_of: customer.id)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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.id).to eq(json_response['created_by_id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does X-On-Behalf-Of auth - ticket create admin for customer by login' do
|
it 'does X-On-Behalf-Of auth - ticket create admin for customer by login' do
|
||||||
|
@ -40,19 +40,19 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.login)
|
authenticated_as(admin, on_behalf_of: customer.login)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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.id).to eq(json_response_ticket['created_by_id'])
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
json_response_activity = json_response
|
json_response_activity = json_response
|
||||||
|
@ -68,7 +68,7 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(ticket_created).to be_truthy
|
expect(ticket_created).to be_truthy
|
||||||
expect(customer_user.id).to eq(ticket_created.created_by_id)
|
expect(customer.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -85,7 +85,7 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(ticket_created).to be_truthy
|
expect(ticket_created).to be_truthy
|
||||||
expect(customer_user.id).to eq(ticket_created.created_by_id)
|
expect(customer.id).to eq(ticket_created.created_by_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does X-On-Behalf-Of auth - ticket create admin for customer by email' do
|
it 'does X-On-Behalf-Of auth - ticket create admin for customer by email' do
|
||||||
|
@ -94,16 +94,16 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
authenticated_as(admin, on_behalf_of: customer.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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.id).to eq(json_response['created_by_id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does X-On-Behalf-Of auth - ticket create admin for unknown' do
|
it 'does X-On-Behalf-Of auth - ticket create admin for unknown' do
|
||||||
|
@ -112,12 +112,12 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: 99_449_494_949)
|
authenticated_as(admin, 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(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
@ -131,12 +131,12 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(customer_user, on_behalf_of: admin_user.email)
|
authenticated_as(customer, on_behalf_of: admin.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
@ -150,12 +150,12 @@ RSpec.describe 'Api Auth On Behalf Of', type: :request do
|
||||||
group: 'secret1234',
|
group: 'secret1234',
|
||||||
priority: '2 normal',
|
priority: '2 normal',
|
||||||
state: 'new',
|
state: 'new',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some test 123',
|
body: 'some test 123',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, on_behalf_of: customer_user.email)
|
authenticated_as(admin, on_behalf_of: customer.email)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(@response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
|
|
@ -13,14 +13,14 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -28,7 +28,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
it 'does basic auth - admin' do
|
it 'does basic auth - admin' do
|
||||||
|
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
@ -49,7 +49,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
it 'does basic auth - agent' do
|
it 'does basic auth - agent' do
|
||||||
|
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
@ -70,7 +70,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
it 'does basic auth - customer' do
|
it 'does basic auth - customer' do
|
||||||
|
|
||||||
Setting.set('api_password_access', false)
|
Setting.set('api_password_access', false)
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
expect(response.header).not_to be_key('Access-Control-Allow-Origin')
|
||||||
|
@ -94,13 +94,13 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: admin_user.id,
|
user_id: admin.id,
|
||||||
preferences: {
|
preferences: {
|
||||||
permission: ['admin.session'],
|
permission: ['admin.session'],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin, token: admin_token)
|
||||||
|
|
||||||
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
|
||||||
|
@ -136,8 +136,8 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
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)!')
|
||||||
|
|
||||||
admin_user.active = false
|
admin.active = false
|
||||||
admin_user.save!
|
admin.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
@ -152,8 +152,8 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
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!')
|
||||||
|
|
||||||
admin_user.active = true
|
admin.active = true
|
||||||
admin_user.save!
|
admin.save!
|
||||||
|
|
||||||
get '/api/v1/sessions', params: {}, as: :json
|
get '/api/v1/sessions', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -247,10 +247,10 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: agent_user.id,
|
user_id: agent.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(agent_user, token: agent_token)
|
authenticated_as(agent, token: agent_token)
|
||||||
|
|
||||||
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
|
||||||
|
@ -286,10 +286,10 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: customer_user.id,
|
user_id: customer.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(customer_user, token: customer_token)
|
authenticated_as(customer, token: customer_token)
|
||||||
|
|
||||||
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
|
||||||
|
@ -324,13 +324,13 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: admin_user.id,
|
user_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin, token: admin_token)
|
||||||
|
|
||||||
admin_user.active = false
|
admin.active = false
|
||||||
admin_user.save!
|
admin.save!
|
||||||
|
|
||||||
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
|
||||||
|
@ -355,11 +355,11 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: admin_user.id,
|
user_id: admin.id,
|
||||||
expires_at: Time.zone.today
|
expires_at: Time.zone.today
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin, token: admin_token)
|
||||||
|
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
@ -379,11 +379,11 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
:token,
|
:token,
|
||||||
action: 'api',
|
action: 'api',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
user_id: admin_user.id,
|
user_id: admin.id,
|
||||||
expires_at: Time.zone.tomorrow
|
expires_at: Time.zone.tomorrow
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user, token: admin_token)
|
authenticated_as(admin, token: admin_token)
|
||||||
|
|
||||||
get '/api/v1/tickets', params: {}, as: :json
|
get '/api/v1/tickets', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -399,7 +399,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does session auth - admin' do
|
it 'does session auth - admin' do
|
||||||
create(:admin_user, login: 'api-admin@example.com', password: 'adminpw')
|
create(:admin, login: 'api-admin@example.com', password: 'adminpw')
|
||||||
|
|
||||||
get '/'
|
get '/'
|
||||||
token = response.headers['CSRF-TOKEN']
|
token = response.headers['CSRF-TOKEN']
|
||||||
|
@ -416,7 +416,7 @@ RSpec.describe 'Api Auth', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does session auth - admin - only with valid CSRF token' do
|
it 'does session auth - admin - only with valid CSRF token' do
|
||||||
create(:admin_user, login: 'api-admin@example.com', password: 'adminpw')
|
create(:admin, login: 'api-admin@example.com', password: 'adminpw')
|
||||||
|
|
||||||
post '/api/v1/signin', params: { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' }
|
post '/api/v1/signin', params: { username: 'api-admin@example.com', password: 'adminpw', fingerprint: '123456789' }
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Calendars', type: :request do
|
RSpec.describe 'Calendars', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -29,7 +29,7 @@ RSpec.describe 'Calendars', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does calendar index with admin' do
|
it 'does calendar index with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/calendars', as: :json
|
get '/api/v1/calendars', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe 'Error handling', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'agent user' do
|
context 'agent user' do
|
||||||
let(:requesting_user) { create(:agent_user, groups: Group.all) }
|
let(:requesting_user) { create(:agent, groups: Group.all) }
|
||||||
let(:message) { 'Please contact your administrator' }
|
let(:message) { 'Please contact your administrator' }
|
||||||
|
|
||||||
context 'requesting JSON' do
|
context 'requesting JSON' do
|
||||||
|
@ -59,7 +59,7 @@ RSpec.describe 'Error handling', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'admin user' do
|
context 'admin user' do
|
||||||
let(:requesting_user) { create(:admin_user, groups: Group.all) }
|
let(:requesting_user) { create(:admin, groups: Group.all) }
|
||||||
|
|
||||||
if ActiveRecord::Base.connection_config[:adapter] == 'mysql2'
|
if ActiveRecord::Base.connection_config[:adapter] == 'mysql2'
|
||||||
let(:message) { 'Mysql2::Error' }
|
let(:message) { 'Mysql2::Error' }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'External Credentials', type: :request do
|
RSpec.describe 'External Credentials', type: :request do
|
||||||
let(:admin_user) { create(:admin_user) }
|
let(:admin) { create(:admin) }
|
||||||
|
|
||||||
context 'without authentication' do
|
context 'without authentication' do
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
@ -42,7 +42,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'authenticated as admin' do
|
context 'authenticated as admin' do
|
||||||
before { authenticated_as(admin_user, via: :browser) }
|
before { authenticated_as(admin, via: :browser) }
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
it 'responds with an array of ExternalCredential records' do
|
it 'responds with an array of ExternalCredential records' do
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration Check MK', type: :request do
|
RSpec.describe 'Integration Check MK', type: :request do
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let(:group) do
|
let(:group) do
|
||||||
create(:group)
|
create(:group)
|
||||||
|
@ -36,7 +36,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
state: 'down',
|
state: 'down',
|
||||||
host: 'some host',
|
host: 'some host',
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
customer: customer_user.email,
|
customer: customer.email,
|
||||||
}
|
}
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.state.name).to eq('new')
|
expect(ticket.state.name).to eq('new')
|
||||||
expect(ticket.customer.email).to eq(customer_user.email)
|
expect(ticket.customer.email).to eq(customer.email)
|
||||||
expect(ticket.articles.count).to eq(1)
|
expect(ticket.articles.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
state: 'down',
|
state: 'down',
|
||||||
host: 'some host',
|
host: 'some host',
|
||||||
service: 'some service',
|
service: 'some service',
|
||||||
customer: customer_user.login,
|
customer: customer.login,
|
||||||
}
|
}
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -70,7 +70,7 @@ RSpec.describe 'Integration Check MK', type: :request do
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.state.name).to eq('new')
|
expect(ticket.state.name).to eq('new')
|
||||||
expect(ticket.customer.email).to eq(customer_user.email)
|
expect(ticket.customer.email).to eq(customer.email)
|
||||||
expect(ticket.articles.count).to eq(1)
|
expect(ticket.articles.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration CTI', type: :request do
|
RSpec.describe 'Integration CTI', type: :request do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let!(:customer_user1) do
|
let!(:customer1) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer1@example.com',
|
login: 'ticket-caller_id_cti-customer1@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
|
@ -17,18 +17,18 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
note: 'Phone at home: +49 99999 222224',
|
note: 'Phone at home: +49 99999 222224',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer2@example.com',
|
login: 'ticket-caller_id_cti-customer2@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
phone: '+49 99999 222222 2',
|
phone: '+49 99999 222222 2',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user3) do
|
let!(:customer3) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer3@example.com',
|
login: 'ticket-caller_id_cti-customer3@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -615,15 +615,15 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
# get caller list
|
# get caller list
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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
|
||||||
expect(json_response['assets']['User']).to be_truthy
|
expect(json_response['assets']['User']).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user2.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer2.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user3.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer3.id.to_s]).to be_truthy
|
||||||
expect(json_response['list'][0]['call_id']).to eq('1234567890-7')
|
expect(json_response['list'][0]['call_id']).to eq('1234567890-7')
|
||||||
expect(json_response['list'][1]['call_id']).to eq('1234567890-6')
|
expect(json_response['list'][1]['call_id']).to eq('1234567890-6')
|
||||||
expect(json_response['list'][2]['call_id']).to eq('1234567890-5')
|
expect(json_response['list'][2]['call_id']).to eq('1234567890-5')
|
||||||
|
@ -676,10 +676,10 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
|
|
||||||
# get caller list (with notify group with 2 log entries)
|
# get caller list (with notify group with 2 log entries)
|
||||||
cti_config = Setting.get('cti_config')
|
cti_config = Setting.get('cti_config')
|
||||||
cti_config[:notify_map] = [{ queue: '4930777000000', user_ids: [agent_user.id.to_s] }]
|
cti_config[:notify_map] = [{ queue: '4930777000000', user_ids: [agent.id.to_s] }]
|
||||||
Setting.set('cti_config', cti_config)
|
Setting.set('cti_config', cti_config)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -723,10 +723,10 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
|
|
||||||
# get caller list (with notify group without a log entry)
|
# get caller list (with notify group without a log entry)
|
||||||
cti_config = Setting.get('cti_config')
|
cti_config = Setting.get('cti_config')
|
||||||
cti_config[:notify_map] = [{ queue: '4912347114711', user_ids: [agent_user.to_s] }]
|
cti_config[:notify_map] = [{ queue: '4912347114711', user_ids: [agent.to_s] }]
|
||||||
Setting.set('cti_config', cti_config)
|
Setting.set('cti_config', cti_config)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['list']).to eq([])
|
expect(json_response['list']).to eq([])
|
||||||
|
@ -802,7 +802,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
log = Cti::Log.find(cti_log1.id)
|
log = Cti::Log.find(cti_log1.id)
|
||||||
expect(log.done).to eq(false)
|
expect(log.done).to eq(false)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post "/api/v1/cti/done/#{cti_log1.id}", params: {
|
post "/api/v1/cti/done/#{cti_log1.id}", params: {
|
||||||
done: true
|
done: true
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ RSpec.describe 'Integration CTI', type: :request do
|
||||||
log = Cti::Log.find(cti_log1.id)
|
log = Cti::Log.find(cti_log1.id)
|
||||||
expect(log.done).to eq(false)
|
expect(log.done).to eq(false)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/cti/done/bulk', params: {
|
post '/api/v1/cti/done/bulk', params: {
|
||||||
ids: [cti_log1.id, cti_log2.id]
|
ids: [cti_log1.id, cti_log2.id]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Idoit', type: :request do
|
RSpec.describe 'Idoit', type: :request do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:token) do
|
let!(:token) do
|
||||||
'some_token'
|
'some_token'
|
||||||
|
@ -36,7 +36,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
client_id: '',
|
client_id: '',
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
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(:unauthorized)
|
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)
|
||||||
|
@ -52,7 +52,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
client_id: '',
|
client_id: '',
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
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)
|
||||||
|
@ -87,7 +87,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
params = {
|
params = {
|
||||||
method: 'cmdb.object_types',
|
method: 'cmdb.object_types',
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
params = {
|
params = {
|
||||||
method: 'cmdb.object_types',
|
method: 'cmdb.object_types',
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ RSpec.describe 'Idoit', type: :request do
|
||||||
ids: ['33']
|
ids: ['33']
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/integration/idoit', params: params, as: :json
|
post '/api/v1/integration/idoit', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Monitoring', type: :request do
|
RSpec.describe 'Monitoring', type: :request do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:token) do
|
let!(:token) do
|
||||||
SecureRandom.urlsafe_base64(64)
|
SecureRandom.urlsafe_base64(64)
|
||||||
|
@ -231,7 +231,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
it 'does monitoring with admin user' do
|
it 'does monitoring with admin user' do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
it 'does monitoring with agent user' do
|
it 'does monitoring with agent user' do
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
permission.save!
|
permission.save!
|
||||||
|
|
||||||
# health_check
|
# health_check
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
get '/api/v1/monitoring/health_check', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does check restart_failed_jobs' do
|
it 'does check restart_failed_jobs' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
@ -532,7 +532,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)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
|
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
|
||||||
token = @response.headers['CSRF-TOKEN']
|
token = @response.headers['CSRF-TOKEN']
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'ObjectManager Attributes', type: :request do
|
RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
it 'does add new ticket text object' do
|
it 'does add new ticket text object' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
||||||
|
|
||||||
# token based on headers
|
# token based on headers
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does add new ticket text object - no default' do
|
it 'does add new ticket text object - no default' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
||||||
|
|
||||||
# token based on headers
|
# token based on headers
|
||||||
|
@ -109,7 +109,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)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
|
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
|
||||||
|
|
||||||
# parameters for updating
|
# parameters for updating
|
||||||
|
@ -157,7 +157,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does add new ticket boolean object' do
|
it 'does add new ticket boolean object' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
||||||
|
|
||||||
# token based on headers
|
# token based on headers
|
||||||
|
@ -205,7 +205,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does add new user select object' do
|
it 'does add new user select object' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
post '/api/v1/object_manager_attributes', params: {}, as: :json
|
||||||
|
|
||||||
# token based on headers
|
# token based on headers
|
||||||
|
@ -263,7 +263,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
expect(json_response['name']).to eq('test5')
|
expect(json_response['name']).to eq('test5')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does update user select object', authenticated_as: -> { admin_user }, db_strategy: :reset do
|
it 'does update user select object', authenticated_as: -> { admin }, db_strategy: :reset do
|
||||||
# add a new object
|
# add a new object
|
||||||
object = create(:object_manager_attribute_text, object_name: 'User')
|
object = create(:object_manager_attribute_text, object_name: 'User')
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
'id': 'c-201'
|
'id': 'c-201'
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
|
@ -416,7 +416,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
|
@ -471,7 +471,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
|
@ -566,7 +566,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
|
@ -652,7 +652,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
migration = ObjectManager::Attribute.migration_execute
|
migration = ObjectManager::Attribute.migration_execute
|
||||||
|
@ -785,7 +785,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/object_manager_attributes', params: params, as: :json
|
post '/api/v1/object_manager_attributes', params: params, as: :json
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -926,7 +926,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:created) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
@ -988,7 +988,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:created) # created
|
expect(response).to have_http_status(:created) # created
|
||||||
|
@ -1018,7 +1018,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
expect(json_response['data_type']).to eq('select')
|
expect(json_response['data_type']).to eq('select')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't let to update item that doesn't exist", authenticated_as: -> { admin_user } do
|
it "doesn't let to update item that doesn't exist", authenticated_as: -> { admin } do
|
||||||
params = {
|
params = {
|
||||||
active: true,
|
active: true,
|
||||||
data_option: {
|
data_option: {
|
||||||
|
@ -1036,7 +1036,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'position handling', authenticated_as: -> { admin_user } do
|
context 'position handling', authenticated_as: -> { admin } do
|
||||||
let(:params) do
|
let(:params) do
|
||||||
{
|
{
|
||||||
'name': "customerdescription_#{rand(999_999_999)}",
|
'name': "customerdescription_#{rand(999_999_999)}",
|
||||||
|
|
|
@ -2,12 +2,12 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration Placetel', type: :request do
|
RSpec.describe 'Integration Placetel', type: :request do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let!(:customer_user1) do
|
let!(:customer1) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer1@example.com',
|
login: 'ticket-caller_id_cti-customer1@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
|
@ -17,18 +17,18 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
note: 'Phone at home: +49 99999 222224',
|
note: 'Phone at home: +49 99999 222224',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer2@example.com',
|
login: 'ticket-caller_id_cti-customer2@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
phone: '+49 99999 222222 2',
|
phone: '+49 99999 222222 2',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user3) do
|
let!(:customer3) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer3@example.com',
|
login: 'ticket-caller_id_cti-customer3@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -514,15 +514,15 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
get '/api/v1/cti/log'
|
get '/api/v1/cti/log'
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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
|
||||||
expect(json_response['assets']['User']).to be_truthy
|
expect(json_response['assets']['User']).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user2.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer2.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user3.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer3.id.to_s]).to be_truthy
|
||||||
expect(json_response['list'][0]['call_id']).to eq('1234567890-7')
|
expect(json_response['list'][0]['call_id']).to eq('1234567890-7')
|
||||||
expect(json_response['list'][1]['call_id']).to eq('1234567890-6')
|
expect(json_response['list'][1]['call_id']).to eq('1234567890-6')
|
||||||
expect(json_response['list'][2]['call_id']).to eq('1234567890-5')
|
expect(json_response['list'][2]['call_id']).to eq('1234567890-5')
|
||||||
|
|
|
@ -2,12 +2,12 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration Sipgate', type: :request do
|
RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let!(:customer_user1) do
|
let!(:customer1) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer1@example.com',
|
login: 'ticket-caller_id_cti-customer1@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
|
@ -17,18 +17,18 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
note: 'Phone at home: +49 99999 222224',
|
note: 'Phone at home: +49 99999 222224',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer2@example.com',
|
login: 'ticket-caller_id_cti-customer2@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer2',
|
lastname: 'Customer2',
|
||||||
phone: '+49 99999 222222 2',
|
phone: '+49 99999 222222 2',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user3) do
|
let!(:customer3) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'ticket-caller_id_cti-customer3@example.com',
|
login: 'ticket-caller_id_cti-customer3@example.com',
|
||||||
firstname: 'CallerId',
|
firstname: 'CallerId',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -444,15 +444,15 @@ RSpec.describe 'Integration Sipgate', type: :request do
|
||||||
get '/api/v1/cti/log'
|
get '/api/v1/cti/log'
|
||||||
expect(@response).to have_http_status(:unauthorized)
|
expect(@response).to have_http_status(:unauthorized)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/cti/log', as: :json
|
get '/api/v1/cti/log', as: :json
|
||||||
expect(@response).to have_http_status(:ok)
|
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
|
||||||
expect(json_response['assets']['User']).to be_truthy
|
expect(json_response['assets']['User']).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user2.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer2.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user3.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer3.id.to_s]).to be_truthy
|
||||||
expect(json_response['list'][0]['call_id']).to eq('1234567890-6')
|
expect(json_response['list'][0]['call_id']).to eq('1234567890-6')
|
||||||
expect(json_response['list'][1]['call_id']).to eq('1234567890-5')
|
expect(json_response['list'][1]['call_id']).to eq('1234567890-5')
|
||||||
expect(json_response['list'][2]['call_id']).to eq('1234567890-4')
|
expect(json_response['list'][2]['call_id']).to eq('1234567890-4')
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Integration SMIME', type: :request do
|
RSpec.describe 'Integration SMIME', type: :request do
|
||||||
|
|
||||||
let(:admin_user) { create(:admin_user) }
|
let(:admin) { create(:admin) }
|
||||||
let(:email_address) { 'smime1@example.com' }
|
let(:email_address) { 'smime1@example.com' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '/integration/smime/certificate' do
|
describe '/integration/smime/certificate' do
|
||||||
|
|
|
@ -4,8 +4,8 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does basic call' do
|
it 'does basic call' do
|
||||||
|
@ -131,15 +131,15 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
body: 'some test',
|
body: 'some test',
|
||||||
type: 'sms',
|
type: 'sms',
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/ticket_articles', params: params, as: :json
|
post '/api/v1/ticket_articles', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
|
|
||||||
stub_request(:post, 'https://api.twilio.com/2010-04-01/Accounts/111/Messages.json')
|
stub_request(:post, 'https://api.twilio.com/2010-04-01/Accounts/111/Messages.json')
|
||||||
.with(
|
.with(
|
||||||
|
@ -171,7 +171,7 @@ RSpec.describe 'Twilio SMS', type: :request do
|
||||||
it 'does customer based on already existing mobile attibute' do
|
it 'does customer based on already existing mobile attibute' do
|
||||||
|
|
||||||
customer = create(
|
customer = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
email: 'me@example.com',
|
email: 'me@example.com',
|
||||||
mobile: '01710000000',
|
mobile: '01710000000',
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, login: 'user-device-admin', password: 'adminpw', groups: Group.all)
|
create(:admin, login: 'user-device-admin', password: 'adminpw', groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, login: 'user-device-agent', password: 'agentpw', groups: Group.all)
|
create(:agent, login: 'user-device-agent', password: 'agentpw', groups: Group.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -48,15 +48,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does login index with admin with fingerprint - I (03)' do
|
it 'does login index with admin with fingerprint - I (03)' do
|
||||||
|
@ -74,15 +74,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
user_device_first = UserDevice.last
|
user_device_first = UserDevice.last
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
@ -98,15 +98,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
||||||
|
|
||||||
|
@ -124,15 +124,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
expect(user_device_first.updated_at.to_s).to eq(user_device_last.updated_at.to_s)
|
||||||
|
|
||||||
|
@ -149,15 +149,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_last.updated_at.to_s).not_to 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
|
||||||
|
@ -176,15 +176,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
sent(
|
sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
|
|
||||||
# ip reset
|
# ip reset
|
||||||
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
||||||
|
@ -195,7 +195,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
create(
|
create(
|
||||||
:user_device,
|
:user_device,
|
||||||
user_id: admin_user.id,
|
user_id: admin.id,
|
||||||
fingerprint: 'fingerprintI',
|
fingerprint: 'fingerprintI',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -209,15 +209,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
sent(
|
sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
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
|
||||||
|
@ -233,15 +233,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
|
|
||||||
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
|
||||||
|
@ -257,15 +257,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
|
|
||||||
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
ENV['TEST_REMOTE_IP'] = '195.65.29.254' # ch
|
||||||
|
|
||||||
|
@ -279,15 +279,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
sent(
|
sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(3)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(3)
|
||||||
|
|
||||||
# ip reset
|
# ip reset
|
||||||
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
||||||
|
@ -298,12 +298,12 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
UserDevice.add(
|
UserDevice.add(
|
||||||
ENV['HTTP_USER_AGENT'],
|
ENV['HTTP_USER_AGENT'],
|
||||||
ENV['TEST_REMOTE_IP'],
|
ENV['TEST_REMOTE_IP'],
|
||||||
admin_user.id,
|
admin.id,
|
||||||
'my_finger_print_II',
|
'my_finger_print_II',
|
||||||
'session', # session|basic_auth|token_auth|sso
|
'session', # session|basic_auth|token_auth|sso
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
|
|
||||||
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
|
||||||
|
@ -315,15 +315,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
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
|
||||||
|
@ -336,15 +336,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
UserDevice.add(
|
UserDevice.add(
|
||||||
ENV['HTTP_USER_AGENT'],
|
ENV['HTTP_USER_AGENT'],
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
admin_user.id,
|
admin.id,
|
||||||
'',
|
'',
|
||||||
'basic_auth', # session|basic_auth|token_auth|sso
|
'basic_auth', # session|basic_auth|token_auth|sso
|
||||||
)
|
)
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
|
|
||||||
ENV['HTTP_USER_AGENT'] = 'curl 1.2.3'
|
ENV['HTTP_USER_AGENT'] = 'curl 1.2.3'
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin, password: 'adminpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -354,15 +354,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
sent(
|
sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
user_device_first = UserDevice.last
|
user_device_first = UserDevice.last
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -377,15 +377,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_first.id).to eq(user_device_last.id)
|
expect(user_device_first.id).to eq(user_device_last.id)
|
||||||
|
@ -404,15 +404,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(2)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(2)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
user_device_last = UserDevice.last
|
user_device_last = UserDevice.last
|
||||||
expect(user_device_first.id).to eq(user_device_last.id)
|
expect(user_device_first.id).to eq(user_device_last.id)
|
||||||
|
@ -426,15 +426,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
UserDevice.add(
|
UserDevice.add(
|
||||||
ENV['HTTP_USER_AGENT'],
|
ENV['HTTP_USER_AGENT'],
|
||||||
ENV['TEST_REMOTE_IP'],
|
ENV['TEST_REMOTE_IP'],
|
||||||
admin_user.id,
|
admin.id,
|
||||||
'',
|
'',
|
||||||
'basic_auth', # session|basic_auth|token_auth|sso
|
'basic_auth', # session|basic_auth|token_auth|sso
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin, password: 'adminpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -444,15 +444,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -461,7 +461,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
ENV['HTTP_USER_AGENT'] = 'curl 1.2.3'
|
ENV['HTTP_USER_AGENT'] = 'curl 1.2.3'
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(agent_user, password: 'agentpw')
|
authenticated_as(agent, password: 'agentpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -471,15 +471,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(1)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -490,15 +490,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
UserDevice.add(
|
UserDevice.add(
|
||||||
ENV['HTTP_USER_AGENT'],
|
ENV['HTTP_USER_AGENT'],
|
||||||
ENV['TEST_REMOTE_IP'],
|
ENV['TEST_REMOTE_IP'],
|
||||||
agent_user.id,
|
agent.id,
|
||||||
'',
|
'',
|
||||||
'basic_auth', # session|basic_auth|token_auth|sso
|
'basic_auth', # session|basic_auth|token_auth|sso
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(1)
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
authenticated_as(agent_user, password: 'agentpw')
|
authenticated_as(agent, password: 'agentpw')
|
||||||
get '/api/v1/users', params: params, as: :json
|
get '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -508,23 +508,23 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(1)
|
||||||
expect(json_response).to be_a_kind_of(Array)
|
expect(json_response).to be_a_kind_of(Array)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does login with switched_from_user_id (10)' do
|
it 'does login with switched_from_user_id (10)' do
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||||
|
|
||||||
ENV['SWITCHED_FROM_USER_ID'] = admin_user.id.to_s
|
ENV['SWITCHED_FROM_USER_ID'] = admin.id.to_s
|
||||||
|
|
||||||
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
|
||||||
|
@ -536,15 +536,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||||
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
|
||||||
|
@ -555,15 +555,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||||
|
|
||||||
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 = {}
|
||||||
|
@ -577,15 +577,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||||
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
|
||||||
|
@ -599,18 +599,18 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: agent_user,
|
user: agent,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# ip reset
|
# ip reset
|
||||||
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
ENV['TEST_REMOTE_IP'] = '5.9.62.170' # de
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: agent_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: agent.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does login with invalid fingerprint (11)' do
|
it 'does login with invalid fingerprint (11)' do
|
||||||
|
@ -629,15 +629,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does login with integer as fingerprint (12)' do
|
it 'does login with integer as fingerprint (12)' do
|
||||||
|
@ -652,15 +652,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(1)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(1)
|
||||||
expect(json_response).to be_a_kind_of(Hash)
|
expect(json_response).to be_a_kind_of(Hash)
|
||||||
expect(json_response['error']).to be_nil
|
expect(json_response['error']).to be_nil
|
||||||
end
|
end
|
||||||
|
@ -671,7 +671,7 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
params = {
|
params = {
|
||||||
fingerprint: 'long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890'
|
fingerprint: 'long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890long_1234567890'
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user, password: 'adminpw')
|
authenticated_as(admin, 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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -686,15 +686,15 @@ RSpec.describe 'User Device', type: :request, sends_notification_emails: true do
|
||||||
|
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new',
|
template: 'user_device_new',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
not_sent(
|
not_sent(
|
||||||
template: 'user_device_new_location',
|
template: 'user_device_new_location',
|
||||||
user: admin_user,
|
user: admin,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(UserDevice.where(user_id: admin_user.id).count).to eq(0)
|
expect(UserDevice.where(user_id: admin.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe 'KnowledgeBase translation update', type: :request, authenticated
|
||||||
|
|
||||||
describe 'changes KB translation title' do
|
describe 'changes KB translation title' do
|
||||||
describe 'as editor' do
|
describe 'as editor' do
|
||||||
let(:user_identifier) { :admin_user }
|
let(:user_identifier) { :admin }
|
||||||
|
|
||||||
it 'updates title' do
|
it 'updates title' do
|
||||||
expect { request }.to change { knowledge_base.reload.translations.first.title }.to(new_title)
|
expect { request }.to change { knowledge_base.reload.translations.first.title }.to(new_title)
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe 'KnowledgeBase translation update', type: :request, authenticated
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'as reader' do
|
describe 'as reader' do
|
||||||
let(:user_identifier) { :agent_user }
|
let(:user_identifier) { :agent }
|
||||||
|
|
||||||
it 'does not change title' do
|
it 'does not change title' do
|
||||||
expect { request }.not_to change { knowledge_base.reload.translations.first.title }
|
expect { request }.not_to change { knowledge_base.reload.translations.first.title }
|
||||||
|
@ -58,14 +58,14 @@ RSpec.describe 'KnowledgeBase translation update', type: :request, authenticated
|
||||||
before { request }
|
before { request }
|
||||||
|
|
||||||
describe 'as editor' do
|
describe 'as editor' do
|
||||||
let(:user_identifier) { :admin_user }
|
let(:user_identifier) { :admin }
|
||||||
|
|
||||||
it { expect(response).to have_http_status(:ok) }
|
it { expect(response).to have_http_status(:ok) }
|
||||||
it { expect(json_response).to be_a_kind_of(Hash) }
|
it { expect(json_response).to be_a_kind_of(Hash) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'as reader' do
|
describe 'as reader' do
|
||||||
let(:user_identifier) { :agent_user }
|
let(:user_identifier) { :agent }
|
||||||
|
|
||||||
it { expect(response).to have_http_status(:unauthorized) }
|
it { expect(response).to have_http_status(:unauthorized) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'LongPolling', type: :request do
|
RSpec.describe 'LongPolling', type: :request do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -41,7 +41,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'receive without client_id' do
|
it 'receive without client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
get '/api/v1/message_receive', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
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)
|
||||||
|
@ -49,7 +49,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'receive without wrong client_id' do
|
it 'receive without wrong client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
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(:unprocessable_entity)
|
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)
|
||||||
|
@ -57,7 +57,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'send without client_id' do
|
it 'send without client_id' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/message_send', params: { data: {} }, as: :json
|
get '/api/v1/message_send', params: { data: {} }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
|
|
||||||
it 'send with client_id' do
|
it 'send with client_id' do
|
||||||
Sessions.create('123456', {}, { type: 'ajax' })
|
Sessions.create('123456', {}, { type: 'ajax' })
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
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(:ok)
|
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)
|
||||||
|
@ -77,7 +77,7 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
|
|
||||||
# here we use a token for the authentication because the basic auth way with username and password
|
# here we use a token for the authentication because the basic auth way with username and password
|
||||||
# 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, token: create(:token, action: 'api', user_id: agent.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(:ok)
|
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)
|
||||||
|
@ -100,10 +100,10 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
expect(json_response[0]['event']).to eq('spool:sent')
|
expect(json_response[0]['event']).to eq('spool:sent')
|
||||||
expect(json_response.count).to eq(1)
|
expect(json_response.count).to eq(1)
|
||||||
|
|
||||||
spool_list = Sessions.spool_list(Time.now.utc.to_i, agent_user.id)
|
spool_list = Sessions.spool_list(Time.now.utc.to_i, agent.id)
|
||||||
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.id] }, data: { taskbar_id: 9_391_633 } } }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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({})
|
||||||
|
@ -115,10 +115,10 @@ RSpec.describe 'LongPolling', type: :request do
|
||||||
|
|
||||||
travel 2.seconds
|
travel 2.seconds
|
||||||
|
|
||||||
spool_list = Sessions.spool_list(Time.now.utc.to_i, agent_user.id)
|
spool_list = Sessions.spool_list(Time.now.utc.to_i, agent.id)
|
||||||
expect(spool_list).to eq([])
|
expect(spool_list).to eq([])
|
||||||
|
|
||||||
spool_list = Sessions.spool_list(nil, agent_user.id)
|
spool_list = Sessions.spool_list(nil, agent.id)
|
||||||
expect(spool_list).to eq([{ message: { 'taskbar_id' => 9_391_633 }, type: 'direct' }])
|
expect(spool_list).to eq([{ message: { 'taskbar_id' => 9_391_633 }, type: 'direct' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Organization', type: :request, searchindex: true do
|
RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, firstname: 'Search 1234', groups: Group.all)
|
create(:agent, firstname: 'Search 1234', groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:organization) do
|
let!(:organization) do
|
||||||
create(
|
create(
|
||||||
|
@ -35,8 +35,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
created_at: '2017-09-05 12:00:00',
|
created_at: '2017-09-05 12:00:00',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(:customer_user, organization: organization)
|
create(:customer, organization: organization)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -58,7 +58,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
it 'does index with agent' do
|
it 'does index with agent' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -132,7 +132,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
it 'does index with customer1' do
|
it 'does index with customer1' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -158,7 +158,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
it 'does index with customer2' do
|
it 'does index with customer2' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer2)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -182,7 +182,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does organization search sortable' do
|
it 'does organization search sortable' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
result = json_response
|
result = json_response
|
||||||
|
@ -223,21 +223,21 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
organization = create(
|
organization = create(
|
||||||
:organization,
|
:organization,
|
||||||
name: 'Rest Org NEW',
|
name: 'Rest Org NEW',
|
||||||
members: [customer_user],
|
members: [customer],
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
get "/api/v1/organizations/#{organization.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect(json_response['member_ids']).to eq([customer_user.id])
|
expect(json_response['member_ids']).to eq([customer.id])
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -245,9 +245,9 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
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)
|
||||||
expect(json_response['members']).to be_truthy
|
expect(json_response['members']).to be_truthy
|
||||||
expect(json_response['member_ids']).to eq([customer_user.id])
|
expect(json_response['member_ids']).to eq([customer.id])
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -255,9 +255,9 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
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)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect(json_response['member_ids']).to eq([customer_user.id])
|
expect(json_response['member_ids']).to eq([customer.id])
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -278,21 +278,21 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
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)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect(json_response['member_ids']).to eq([customer_user.id])
|
expect(json_response['member_ids']).to eq([customer.id])
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does organization index and response format' do
|
it 'does organization index and response format' do
|
||||||
organization = create(
|
organization = create(
|
||||||
:organization,
|
:organization,
|
||||||
name: 'Rest Org NEW',
|
name: 'Rest Org NEW',
|
||||||
members: [customer_user],
|
members: [customer],
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -301,8 +301,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['name']).to eq(organization.name)
|
expect(json_response.last['name']).to eq(organization.name)
|
||||||
expect(json_response.last['members']).to be_falsey
|
expect(json_response.last['members']).to be_falsey
|
||||||
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -311,9 +311,9 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['id']).to eq(organization.id)
|
expect(json_response.last['id']).to eq(organization.id)
|
||||||
expect(json_response.last['name']).to eq(organization.name)
|
expect(json_response.last['name']).to eq(organization.name)
|
||||||
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
||||||
expect([customer_user.login]).to eq(organization.members.pluck(:login))
|
expect([customer.login]).to eq(organization.members.pluck(:login))
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -323,8 +323,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['name']).to eq(organization.name)
|
expect(json_response.last['name']).to eq(organization.name)
|
||||||
expect(json_response.last['members']).to be_falsey
|
expect(json_response.last['members']).to be_falsey
|
||||||
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -349,17 +349,17 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response.last['name']).to eq(organization.name)
|
expect(json_response.last['name']).to eq(organization.name)
|
||||||
expect(json_response.last['members']).to be_falsey
|
expect(json_response.last['members']).to be_falsey
|
||||||
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
expect(json_response.last['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does ticket create and response format' do
|
it 'does ticket create and response format' do
|
||||||
params = {
|
params = {
|
||||||
name: 'Rest Org NEW',
|
name: 'Rest Org NEW',
|
||||||
members: [customer_user.login],
|
members: [customer.login],
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/organizations', params: params, as: :json
|
post '/api/v1/organizations', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
@ -368,8 +368,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
expect(json_response['member_ids']).to eq(organization.member_ids)
|
expect(json_response['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
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
|
||||||
|
@ -380,8 +380,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['name']).to eq(organization.name)
|
expect(json_response['name']).to eq(organization.name)
|
||||||
expect(json_response['member_ids']).to eq(organization.member_ids)
|
expect(json_response['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response['members']).to eq(organization.members.pluck(:login))
|
expect(json_response['members']).to eq(organization.members.pluck(:login))
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
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
|
||||||
|
@ -403,15 +403,15 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
organization = create(
|
organization = create(
|
||||||
:organization,
|
:organization,
|
||||||
name: 'Rest Org NEW',
|
name: 'Rest Org NEW',
|
||||||
members: [customer_user],
|
members: [customer],
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
name: 'a update name #1',
|
name: 'a update name #1',
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
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)
|
||||||
|
@ -420,8 +420,8 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
expect(json_response['name']).to eq(params[:name])
|
expect(json_response['name']).to eq(params[:name])
|
||||||
expect(json_response['member_ids']).to eq(organization.member_ids)
|
expect(json_response['member_ids']).to eq(organization.member_ids)
|
||||||
expect(json_response['members']).to be_falsey
|
expect(json_response['members']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
name: 'a update name #2',
|
name: 'a update name #2',
|
||||||
|
@ -433,9 +433,9 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
organization = Organization.find(json_response['id'])
|
organization = Organization.find(json_response['id'])
|
||||||
expect(json_response['name']).to eq(params[:name])
|
expect(json_response['name']).to eq(params[:name])
|
||||||
expect(json_response['member_ids']).to eq(organization.member_ids)
|
expect(json_response['member_ids']).to eq(organization.member_ids)
|
||||||
expect([customer_user.login]).to eq(organization.members.pluck(:login))
|
expect([customer.login]).to eq(organization.members.pluck(:login))
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
name: 'a update name #3',
|
name: 'a update name #3',
|
||||||
|
@ -461,7 +461,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
name: 'some org',
|
name: 'some org',
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
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(:ok)
|
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)
|
||||||
|
@ -472,14 +472,14 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does csv example - customer no access' do
|
it 'does csv example - customer no access' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/organizations/import_example', params: {}, as: :json
|
get '/api/v1/organizations/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)
|
||||||
get '/api/v1/organizations/import_example', params: {}, as: :json
|
get '/api/v1/organizations/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
customer1 = create(
|
customer1 = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'customer1-members@example.com',
|
login: 'customer1-members@example.com',
|
||||||
firstname: 'Member',
|
firstname: 'Member',
|
||||||
lastname: 'Customer',
|
lastname: 'Customer',
|
||||||
|
@ -509,7 +509,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
active: true,
|
active: true,
|
||||||
)
|
)
|
||||||
customer2 = create(
|
customer2 = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'customer2-members@example.com',
|
login: 'customer2-members@example.com',
|
||||||
firstname: 'Member',
|
firstname: 'Member',
|
||||||
lastname: 'Customer',
|
lastname: 'Customer',
|
||||||
|
@ -520,7 +520,7 @@ RSpec.describe 'Organization', type: :request, searchindex: true do
|
||||||
UserInfo.current_user_id = nil
|
UserInfo.current_user_id = nil
|
||||||
|
|
||||||
# invalid file
|
# invalid file
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Overviews', type: :request do
|
RSpec.describe 'Overviews', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -31,9 +31,9 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
agent_user = create(:agent_user, password: 'we need a password here')
|
agent = create(:agent, password: 'we need a password here')
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)
|
||||||
|
@ -63,7 +63,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
@ -134,7 +134,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
[overview1.id, 2],
|
[overview1.id, 2],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/overviews_prio', params: params, as: :json
|
post '/api/v1/overviews_prio', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -173,7 +173,7 @@ RSpec.describe 'Overviews', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/overviews', params: params, as: :json
|
post '/api/v1/overviews', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Packages', type: :request do
|
RSpec.describe 'Packages', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -24,7 +24,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does packages index with admin' do
|
it 'does packages index with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -33,7 +33,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does packages index with admin and wrong pw' do
|
it 'does packages index with admin and wrong pw' do
|
||||||
authenticated_as(admin_user, password: 'wrongadminpw')
|
authenticated_as(admin, password: 'wrongadminpw')
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
@ -42,9 +42,9 @@ RSpec.describe 'Packages', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does packages index with inactive admin' do
|
it 'does packages index with inactive admin' do
|
||||||
admin_user = create(:admin_user, active: false, password: 'we need a password here')
|
admin = create(:admin, active: false, password: 'we need a password here')
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
@ -53,7 +53,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does packages index with agent' do
|
it 'does packages index with agent' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
@ -63,7 +63,7 @@ RSpec.describe 'Packages', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does packages index with customer' do
|
it 'does packages index with customer' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/packages', as: :json
|
get '/api/v1/packages', as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Report', type: :request, searchindex: true do
|
RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
let!(:year) do
|
let!(:year) do
|
||||||
DateTime.now.utc.year
|
DateTime.now.utc.year
|
||||||
|
@ -72,7 +72,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
it 'does report example - admin access' do
|
it 'does report example - admin access' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -84,7 +84,7 @@ RSpec.describe 'Report', type: :request, searchindex: true do
|
||||||
it 'does report example - deliver result' do
|
it 'does report example - deliver result' do
|
||||||
skip('No ES configured') if !SearchIndexBackend.enabled?
|
skip('No ES configured') if !SearchIndexBackend.enabled?
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
|
|
||||||
# 2019-03-15 - day interval
|
# 2019-03-15 - day interval
|
||||||
params = {
|
params = {
|
||||||
|
|
|
@ -3,14 +3,14 @@ require 'rails_helper'
|
||||||
RSpec.describe 'Search', type: :request, searchindex: true do
|
RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
let(:group) { create(:group) }
|
let(:group) { create(:group) }
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, groups: [Group.lookup(name: 'Users'), group])
|
create(:admin, groups: [Group.lookup(name: 'Users'), group])
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, firstname: 'Search 1234', groups: [Group.lookup(name: 'Users'), group])
|
create(:agent, firstname: 'Search 1234', groups: [Group.lookup(name: 'Users'), group])
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:organization1) do
|
let!(:organization1) do
|
||||||
create(:organization, name: 'Rest Org')
|
create(:organization, name: 'Rest Org')
|
||||||
|
@ -30,26 +30,26 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
let!(:organization_nested) do
|
let!(:organization_nested) do
|
||||||
create(:organization, name: 'Tomato42 Ltd.', note: 'Tomato42 Ltd.')
|
create(:organization, name: 'Tomato42 Ltd.', note: 'Tomato42 Ltd.')
|
||||||
end
|
end
|
||||||
let!(:customer_user_nested) do
|
let!(:customer_nested) do
|
||||||
create(:customer_user, organization: organization_nested)
|
create(:customer, organization: organization_nested)
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(:customer_user, organization: organization1)
|
create(:customer, organization: organization1)
|
||||||
end
|
end
|
||||||
let!(:customer_user3) do
|
let!(:customer3) do
|
||||||
create(:customer_user, organization: organization1)
|
create(:customer, organization: organization1)
|
||||||
end
|
end
|
||||||
let!(:ticket1) do
|
let!(:ticket1) do
|
||||||
create(:ticket, title: 'test 1234-1', customer: customer_user, group: group)
|
create(:ticket, title: 'test 1234-1', customer: customer, group: group)
|
||||||
end
|
end
|
||||||
let!(:ticket2) do
|
let!(:ticket2) do
|
||||||
create(:ticket, title: 'test 1234-2', customer: customer_user2, group: group)
|
create(:ticket, title: 'test 1234-2', customer: customer2, group: group)
|
||||||
end
|
end
|
||||||
let!(:ticket3) do
|
let!(:ticket3) do
|
||||||
create(:ticket, title: 'test 1234-2', customer: customer_user3, group: group)
|
create(:ticket, title: 'test 1234-2', customer: customer3, group: group)
|
||||||
end
|
end
|
||||||
let!(:ticket_nested) do
|
let!(:ticket_nested) do
|
||||||
create(:ticket, title: 'vegetable request', customer: customer_user_nested, group: group)
|
create(:ticket, title: 'vegetable request', customer: customer_nested, group: group)
|
||||||
end
|
end
|
||||||
let!(:article1) do
|
let!(:article1) do
|
||||||
create(:ticket_article, ticket_id: ticket1.id)
|
create(:ticket_article, ticket_id: ticket1.id)
|
||||||
|
@ -121,7 +121,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
query: '1234*',
|
query: '1234*',
|
||||||
limit: 1,
|
limit: 1,
|
||||||
}
|
}
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -129,7 +129,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
expect(json_response['result'][0]['id']).to eq(ticket3.id)
|
expect(json_response['result'][0]['id']).to eq(ticket3.id)
|
||||||
expect(json_response['result'][1]['type']).to eq('User')
|
expect(json_response['result'][1]['type']).to eq('User')
|
||||||
expect(json_response['result'][1]['id']).to eq(agent_user.id)
|
expect(json_response['result'][1]['id']).to eq(agent.id)
|
||||||
expect(json_response['result'][2]).to be_falsey
|
expect(json_response['result'][2]).to be_falsey
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -148,7 +148,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(json_response['result'][2]['type']).to eq('Ticket')
|
expect(json_response['result'][2]['type']).to eq('Ticket')
|
||||||
expect(json_response['result'][2]['id']).to eq(ticket1.id)
|
expect(json_response['result'][2]['id']).to eq(ticket1.id)
|
||||||
expect(json_response['result'][3]['type']).to eq('User')
|
expect(json_response['result'][3]['type']).to eq('User')
|
||||||
expect(json_response['result'][3]['id']).to eq(agent_user.id)
|
expect(json_response['result'][3]['id']).to eq(agent.id)
|
||||||
expect(json_response['result'][4]).to be_falsey
|
expect(json_response['result'][4]).to be_falsey
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -177,7 +177,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(response).to have_http_status(:ok)
|
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.id)
|
||||||
expect(json_response['result'][1]).to be_falsey
|
expect(json_response['result'][1]).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
limit: 1,
|
limit: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -195,7 +195,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(json_response['result'][0]['type']).to eq('Ticket')
|
expect(json_response['result'][0]['type']).to eq('Ticket')
|
||||||
expect(json_response['result'][0]['id']).to eq(ticket3.id)
|
expect(json_response['result'][0]['id']).to eq(ticket3.id)
|
||||||
expect(json_response['result'][1]['type']).to eq('User')
|
expect(json_response['result'][1]['type']).to eq('User')
|
||||||
expect(json_response['result'][1]['id']).to eq(agent_user.id)
|
expect(json_response['result'][1]['id']).to eq(agent.id)
|
||||||
expect(json_response['result'][2]).to be_falsey
|
expect(json_response['result'][2]).to be_falsey
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -214,7 +214,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(json_response['result'][2]['type']).to eq('Ticket')
|
expect(json_response['result'][2]['type']).to eq('Ticket')
|
||||||
expect(json_response['result'][2]['id']).to eq(ticket1.id)
|
expect(json_response['result'][2]['id']).to eq(ticket1.id)
|
||||||
expect(json_response['result'][3]['type']).to eq('User')
|
expect(json_response['result'][3]['type']).to eq('User')
|
||||||
expect(json_response['result'][3]['id']).to eq(agent_user.id)
|
expect(json_response['result'][3]['id']).to eq(agent.id)
|
||||||
expect(json_response['result'][4]).to be_falsey
|
expect(json_response['result'][4]).to be_falsey
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -243,7 +243,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
expect(response).to have_http_status(:ok)
|
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.id)
|
||||||
expect(json_response['result'][1]).to be_falsey
|
expect(json_response['result'][1]).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
limit: 10,
|
limit: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -292,7 +292,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
limit: 10,
|
limit: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer2)
|
||||||
post '/api/v1/search', params: params, as: :json
|
post '/api/v1/search', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -331,7 +331,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
# Verify fix for Github issue #2058 - Autocomplete hangs on dot in the new user form
|
# Verify fix for Github issue #2058 - Autocomplete hangs on dot in the new user form
|
||||||
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)
|
||||||
get '/api/v1/search/organization?query=tes.', as: :json
|
get '/api/v1/search/organization?query=tes.', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['result'].size).to eq(1)
|
expect(json_response['result'].size).to eq(1)
|
||||||
|
@ -342,7 +342,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
# Search query H& should correctly match H&M
|
# Search query H& should correctly match H&M
|
||||||
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)
|
||||||
get '/api/v1/search/organization?query=abc_', as: :json
|
get '/api/v1/search/organization?query=abc_', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['result'].size).to eq(1)
|
expect(json_response['result'].size).to eq(1)
|
||||||
|
@ -355,20 +355,20 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
|
|
||||||
# because of the initial relation between user and organization
|
# because of the initial relation between user and organization
|
||||||
# both user and organization will be found as result
|
# both user and organization will be found as result
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/search/User', params: { query: 'Tomato42' }, as: :json
|
post '/api/v1/search/User', params: { query: 'Tomato42' }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer_nested.id.to_s]).to be_truthy
|
||||||
|
|
||||||
post '/api/v1/search/User', params: { query: 'organization:Tomato42' }, as: :json
|
post '/api/v1/search/User', params: { query: 'organization:Tomato42' }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer_nested.id.to_s]).to be_truthy
|
||||||
|
|
||||||
organization_nested.update(name: 'Cucumber43 Ltd.')
|
organization_nested.update(name: 'Cucumber43 Ltd.')
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
|
@ -381,18 +381,18 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
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['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer_nested.id.to_s]).to be_truthy
|
||||||
|
|
||||||
post '/api/v1/search/User', params: { query: 'organization:Cucumber43' }, as: :json
|
post '/api/v1/search/User', params: { query: 'organization:Cucumber43' }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][customer_user_nested.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][customer_nested.id.to_s]).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does find the ticket by organization name even if the organization name changes' do
|
it 'does find the ticket by organization name even if the organization name changes' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/search/Ticket', params: { query: 'Tomato42' }, as: :json
|
post '/api/v1/search/Ticket', params: { query: 'Tomato42' }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -432,7 +432,7 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
||||||
limit: 10,
|
limit: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/search/Ticket', params: params, as: :json
|
post '/api/v1/search/Ticket', params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Sessions endpoints', type: :request do
|
||||||
|
|
||||||
context 'user logged in' do
|
context 'user logged in' do
|
||||||
|
|
||||||
subject(:user) { create(:agent_user, password: password) }
|
subject(:user) { create(:agent, password: password) }
|
||||||
|
|
||||||
let(:password) { SecureRandom.urlsafe_base64(20) }
|
let(:password) { SecureRandom.urlsafe_base64(20) }
|
||||||
let(:fingerprint) { SecureRandom.urlsafe_base64(40) }
|
let(:fingerprint) { SecureRandom.urlsafe_base64(40) }
|
||||||
|
|
|
@ -2,20 +2,20 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Settings', type: :request do
|
RSpec.describe 'Settings', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
let(:admin_api_user) do
|
let(:admin_api) do
|
||||||
role_api = create(:role)
|
role_api = create(:role)
|
||||||
role_api.permission_grant('admin.api')
|
role_api.permission_grant('admin.api')
|
||||||
|
|
||||||
create(:admin_user, roles: [role_api])
|
create(:admin, roles: [role_api])
|
||||||
end
|
end
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -38,7 +38,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
it 'does settings index with admin' do
|
it 'does settings index with admin' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -115,7 +115,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
it 'does settings index with admin-api' do
|
it 'does settings index with admin-api' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(admin_api_user)
|
authenticated_as(admin_api)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -187,7 +187,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
it 'does settings index with agent' do
|
it 'does settings index with agent' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)
|
||||||
|
@ -204,7 +204,7 @@ RSpec.describe 'Settings', type: :request do
|
||||||
it 'does settings index with customer' do
|
it 'does settings index with customer' do
|
||||||
|
|
||||||
# index
|
# index
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/settings', params: {}, as: :json
|
get '/api/v1/settings', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)
|
||||||
|
|
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'SLAs', type: :request do
|
RSpec.describe 'SLAs', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -17,7 +17,7 @@ RSpec.describe 'SLAs', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does index sla with admin' do
|
it 'does index sla with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/slas', as: :json
|
get '/api/v1/slas', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
|
|
@ -4,7 +4,7 @@ RSpec.describe Tag, type: :request do
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
let(:agent) { create(:agent_user) }
|
let(:agent) { create(:agent) }
|
||||||
|
|
||||||
context 'tag search' do
|
context 'tag search' do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -2,24 +2,24 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Taskbars', type: :request do
|
RSpec.describe 'Taskbars', type: :request do
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
it 'does task ownership' do
|
it 'does task ownership' do
|
||||||
params = {
|
params = {
|
||||||
user_id: customer_user.id,
|
user_id: customer.id,
|
||||||
client_id: '123',
|
client_id: '123',
|
||||||
key: 'Ticket-5',
|
key: 'Ticket-5',
|
||||||
callback: 'TicketZoom',
|
callback: 'TicketZoom',
|
||||||
state: {
|
state: {
|
||||||
ticket: {
|
ticket: {
|
||||||
owner_id: agent_user.id,
|
owner_id: agent.id,
|
||||||
},
|
},
|
||||||
article: {},
|
article: {},
|
||||||
},
|
},
|
||||||
|
@ -32,17 +32,17 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
active: false,
|
active: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/taskbar', params: params, as: :json
|
post '/api/v1/taskbar', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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.id)
|
||||||
expect(json_response['params']['ticket_id']).to eq(5)
|
expect(json_response['params']['ticket_id']).to eq(5)
|
||||||
expect(json_response['params']['shown']).to eq(true)
|
expect(json_response['params']['shown']).to eq(true)
|
||||||
|
|
||||||
taskbar_id = json_response['id']
|
taskbar_id = json_response['id']
|
||||||
params[:user_id] = customer_user.id
|
params[:user_id] = customer.id
|
||||||
params[:params] = {
|
params[:params] = {
|
||||||
ticket_id: 5,
|
ticket_id: 5,
|
||||||
shown: false,
|
shown: false,
|
||||||
|
@ -51,7 +51,7 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
expect(response).to have_http_status(:ok)
|
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.id)
|
||||||
expect(json_response['params']['ticket_id']).to eq(5)
|
expect(json_response['params']['ticket_id']).to eq(5)
|
||||||
expect(json_response['params']['shown']).to eq(false)
|
expect(json_response['params']['shown']).to eq(false)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
active: true,
|
active: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
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(:unprocessable_entity)
|
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)
|
||||||
|
@ -72,7 +72,7 @@ RSpec.describe 'Taskbars', type: :request do
|
||||||
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)
|
||||||
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
delete "/api/v1/taskbar/#{taskbar_id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
|
|
@ -3,20 +3,20 @@ require 'byebug'
|
||||||
|
|
||||||
RSpec.describe 'Text Module', type: :request do
|
RSpec.describe 'Text Module', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user)
|
create(:admin)
|
||||||
end
|
end
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user)
|
create(:agent)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
it 'does csv example - customer no access' do
|
it 'does csv example - customer no access' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/text_modules/import_example', as: :json
|
get '/api/v1/text_modules/import_example', as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)!')
|
||||||
|
@ -25,7 +25,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
it 'does csv example - admin access' do
|
it 'does csv example - admin access' do
|
||||||
TextModule.load('en-en')
|
TextModule.load('en-en')
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/text_modules/import_example', as: :json
|
get '/api/v1/text_modules/import_example', as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
rows = CSV.parse(@response.body)
|
rows = CSV.parse(@response.body)
|
||||||
|
@ -49,7 +49,7 @@ RSpec.describe 'Text Module', type: :request do
|
||||||
# invalid file
|
# invalid file
|
||||||
csv_file = fixture_file_upload('csv_import/text_module/simple_col_not_existing.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/text_module/simple_col_not_existing.csv', 'text/csv')
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
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(:ok)
|
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)
|
||||||
|
|
|
@ -4,8 +4,8 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||||
|
|
||||||
let(:group) { create(:group) }
|
let(:group) { create(:group) }
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user, groups: [Group.lookup(name: 'Users'), group])
|
create(:agent, groups: [Group.lookup(name: 'Users'), group])
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -26,12 +26,12 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||||
)
|
)
|
||||||
article2 = create(:ticket_article, ticket_id: ticket1.id)
|
article2 = create(:ticket_article, ticket_id: ticket1.id)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect('some content').to eq(@response.body)
|
expect('some content').to eq(@response.body)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.body).to match(/401: Unauthorized/)
|
expect(@response.body).to match(/401: Unauthorized/)
|
||||||
|
@ -42,23 +42,23 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||||
user_id: 1,
|
user_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article1.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article1.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect('some content').to eq(@response.body)
|
expect('some content').to eq(@response.body)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article2.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket2.id}/#{article2.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.body).to match(/401: Unauthorized/)
|
expect(@response.body).to match(/401: Unauthorized/)
|
||||||
|
|
||||||
# allow access via merged ticket id also
|
# allow access via merged ticket id also
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article1.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect('some content').to eq(@response.body)
|
expect('some content').to eq(@response.body)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}
|
get "/api/v1/ticket_attachment/#{ticket1.id}/#{article2.id}/#{store1.id}", params: {}
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(@response.body).to match(/401: Unauthorized/)
|
expect(@response.body).to match(/401: Unauthorized/)
|
||||||
|
@ -70,7 +70,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||||
email_raw_string = File.read(email_file_path)
|
email_raw_string = File.read(email_file_path)
|
||||||
ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
|
ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/ticket_split', params: { form_id: '1234-2', ticket_id: ticket_p.id, article_id: article_p.id }, as: :json
|
get '/api/v1/ticket_split', params: { form_id: '1234-2', ticket_id: ticket_p.id, article_id: article_p.id }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response['assets']).to be_truthy
|
expect(json_response['assets']).to be_truthy
|
||||||
|
@ -85,7 +85,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
|
||||||
email_raw_string = File.read(email_file_path)
|
email_raw_string = File.read(email_file_path)
|
||||||
_ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
|
_ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: {}, as: :json
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
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)
|
||||||
|
|
|
@ -2,16 +2,16 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Ticket Article API endpoints', type: :request do
|
RSpec.describe 'Ticket Article API endpoints', type: :request do
|
||||||
|
|
||||||
let(:admin_user) do
|
let(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:group) { create(:group) }
|
let!(:group) { create(:group) }
|
||||||
|
|
||||||
let(:agent_user) do
|
let(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
let(:customer_user) do
|
let(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
@ -20,12 +20,12 @@ RSpec.describe 'Ticket Article API endpoints', type: :request do
|
||||||
params = {
|
params = {
|
||||||
title: 'a new ticket #1',
|
title: 'a new ticket #1',
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ RSpec.describe 'Ticket Article API endpoints', type: :request do
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body')
|
expect(json_response['body']).to eq('some body')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.articles.count).to eq(2)
|
expect(ticket.articles.count).to eq(2)
|
||||||
|
@ -64,8 +64,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['body']).not_to match(/some body <img src="cid:.+?/)
|
expect(json_response['body']).not_to match(/some body <img src="cid:.+?/)
|
||||||
expect(json_response['body']).to match(%r{some body <img src="/api/v1/ticket_attachment/.+?" alt="Red dot"})
|
expect(json_response['body']).to match(%r{some body <img src="/api/v1/ticket_attachment/.+?" alt="Red dot"})
|
||||||
expect(json_response['content_type']).to eq('text/html')
|
expect(json_response['content_type']).to eq('text/html')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
|
|
||||||
expect(ticket.articles.count).to eq(3)
|
expect(ticket.articles.count).to eq(3)
|
||||||
expect(ticket.articles[0].attachments.count).to eq(0)
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
||||||
|
@ -95,8 +95,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body')
|
expect(json_response['body']).to eq('some body')
|
||||||
expect(json_response['content_type']).to eq('text/html')
|
expect(json_response['content_type']).to eq('text/html')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
|
|
||||||
expect(ticket.articles.count).to eq(4)
|
expect(ticket.articles.count).to eq(4)
|
||||||
expect(ticket.articles[0].attachments.count).to eq(0)
|
expect(ticket.articles[0].attachments.count).to eq(0)
|
||||||
|
@ -128,8 +128,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body')
|
expect(json_response['body']).to eq('some body')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
expect(json_response['preferences']['some_key1']).to eq(123)
|
expect(json_response['preferences']['some_key1']).to eq(123)
|
||||||
expect(ticket.articles.count).to eq(5)
|
expect(ticket.articles.count).to eq(5)
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body 2')
|
expect(json_response['body']).to eq('some body 2')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(agent_user.id)
|
expect(json_response['created_by_id']).to eq(agent.id)
|
||||||
expect(json_response['preferences']['some_key1']).to eq(123)
|
expect(json_response['preferences']['some_key1']).to eq(123)
|
||||||
expect(json_response['preferences']['some_key2']).to eq('abc')
|
expect(json_response['preferences']['some_key2']).to eq('abc')
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body')
|
expect(json_response['body']).to eq('some body')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
expect(json_response['updated_by_id']).to eq(customer.id)
|
||||||
expect(json_response['created_by_id']).to eq(customer_user.id)
|
expect(json_response['created_by_id']).to eq(customer.id)
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.articles.count).to eq(2)
|
expect(ticket.articles.count).to eq(2)
|
||||||
|
@ -198,8 +198,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body')
|
expect(json_response['body']).to eq('some body')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
expect(json_response['updated_by_id']).to eq(customer.id)
|
||||||
expect(json_response['created_by_id']).to eq(customer_user.id)
|
expect(json_response['created_by_id']).to eq(customer.id)
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.articles.count).to eq(3)
|
expect(ticket.articles.count).to eq(3)
|
||||||
|
@ -223,8 +223,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(json_response['subject']).to be_nil
|
expect(json_response['subject']).to be_nil
|
||||||
expect(json_response['body']).to eq('some body 2')
|
expect(json_response['body']).to eq('some body 2')
|
||||||
expect(json_response['content_type']).to eq('text/plain')
|
expect(json_response['content_type']).to eq('text/plain')
|
||||||
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
expect(json_response['updated_by_id']).to eq(customer.id)
|
||||||
expect(json_response['created_by_id']).to eq(customer_user.id)
|
expect(json_response['created_by_id']).to eq(customer.id)
|
||||||
|
|
||||||
ticket = Ticket.find(json_response['ticket_id'])
|
ticket = Ticket.find(json_response['ticket_id'])
|
||||||
expect(ticket.articles.count).to eq(4)
|
expect(ticket.articles.count).to eq(4)
|
||||||
|
@ -269,14 +269,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
params = {
|
params = {
|
||||||
title: 'a new ticket #1',
|
title: 'a new ticket #1',
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
sender: 'Customer',
|
sender: 'Customer',
|
||||||
type: 'phone',
|
type: 'phone',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
@ -285,15 +285,15 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(Ticket::Article.where(ticket_id: json_response['id']).count).to eq(2) # original + auto responder
|
expect(Ticket::Article.where(ticket_id: json_response['id']).count).to eq(2) # original + auto responder
|
||||||
|
|
||||||
article = Ticket::Article.where(ticket_id: json_response['id']).first
|
article = Ticket::Article.where(ticket_id: json_response['id']).first
|
||||||
expect(article.origin_by_id).to eq(customer_user.id)
|
expect(article.origin_by_id).to eq(customer.id)
|
||||||
expect(article.from).to eq("#{customer_user.firstname} #{customer_user.lastname} <#{customer_user.email}>")
|
expect(article.from).to eq("#{customer.firstname} #{customer.lastname} <#{customer.email}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does create phone ticket by customer and manipulate origin_by_id' do
|
it 'does create phone ticket by customer and manipulate origin_by_id' do
|
||||||
params = {
|
params = {
|
||||||
title: 'a new ticket #1',
|
title: 'a new ticket #1',
|
||||||
group: 'Users',
|
group: 'Users',
|
||||||
customer_id: customer_user.id,
|
customer_id: customer.id,
|
||||||
article: {
|
article: {
|
||||||
body: 'some body',
|
body: 'some body',
|
||||||
sender: 'Customer',
|
sender: 'Customer',
|
||||||
|
@ -301,7 +301,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
origin_by_id: 1,
|
origin_by_id: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
@ -309,7 +309,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
expect(Ticket::Article.where(ticket_id: json_response['id']).count).to eq(1) # ony original
|
expect(Ticket::Article.where(ticket_id: json_response['id']).count).to eq(1) # ony original
|
||||||
|
|
||||||
article = Ticket::Article.where(ticket_id: json_response['id']).first
|
article = Ticket::Article.where(ticket_id: json_response['id']).first
|
||||||
expect(article.origin_by_id).to eq(customer_user.id)
|
expect(article.origin_by_id).to eq(customer.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does ticket split with html - check attachments' do
|
it 'does ticket split with html - check attachments' do
|
||||||
|
@ -390,7 +390,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
params = {
|
params = {
|
||||||
form_id: 'new_form_id123',
|
form_id: 'new_form_id123',
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -408,8 +408,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
ticket = create(
|
ticket = create(
|
||||||
:ticket,
|
:ticket,
|
||||||
group: group,
|
group: group,
|
||||||
updated_by_id: agent_user.id,
|
updated_by_id: agent.id,
|
||||||
created_by_id: agent_user.id,
|
created_by_id: agent.id,
|
||||||
)
|
)
|
||||||
article = create(
|
article = create(
|
||||||
:ticket_article,
|
:ticket_article,
|
||||||
|
@ -465,7 +465,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
params = {
|
params = {
|
||||||
form_id: 'new_form_id123',
|
form_id: 'new_form_id123',
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article.id}", params: params, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -488,19 +488,19 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
let(:article_communication) do
|
let(:article_communication) do
|
||||||
create(:ticket_article,
|
create(:ticket_article,
|
||||||
sender_name: 'Agent', type_name: 'email', ticket: ticket,
|
sender_name: 'Agent', type_name: 'email', ticket: ticket,
|
||||||
updated_by_id: agent_user.id, created_by_id: agent_user.id )
|
updated_by_id: agent.id, created_by_id: agent.id )
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:article_note) do
|
let(:article_note) do
|
||||||
create(:ticket_article,
|
create(:ticket_article,
|
||||||
sender_name: 'Agent', internal: true, type_name: 'note', ticket: ticket,
|
sender_name: 'Agent', internal: true, type_name: 'note', ticket: ticket,
|
||||||
updated_by_id: agent_user.id, created_by_id: agent_user.id )
|
updated_by_id: agent.id, created_by_id: agent.id )
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:article_note_customer) do
|
let(:article_note_customer) do
|
||||||
create(:ticket_article,
|
create(:ticket_article,
|
||||||
sender_name: 'Customer', internal: false, type_name: 'note', ticket: ticket,
|
sender_name: 'Customer', internal: false, type_name: 'note', ticket: ticket,
|
||||||
updated_by_id: customer_user.id, created_by_id: customer_user.id )
|
updated_by_id: customer.id, created_by_id: customer.id )
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:article_note_communication) do
|
let(:article_note_communication) do
|
||||||
|
@ -508,7 +508,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
|
|
||||||
create(:ticket_article,
|
create(:ticket_article,
|
||||||
sender_name: 'Agent', internal: true, type_name: 'note_communication', ticket: ticket,
|
sender_name: 'Agent', internal: true, type_name: 'note_communication', ticket: ticket,
|
||||||
updated_by_id: agent_user.id, created_by_id: agent_user.id )
|
updated_by_id: agent.id, created_by_id: agent.id )
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_article_via_rest(article)
|
def delete_article_via_rest(article)
|
||||||
|
@ -548,7 +548,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as admin' do
|
context 'as admin' do
|
||||||
let(:user) { admin_user }
|
let(:user) { admin }
|
||||||
|
|
||||||
include_examples 'deleting',
|
include_examples 'deleting',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -568,7 +568,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
include_examples 'deleting',
|
include_examples 'deleting',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -589,7 +589,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as customer' do
|
context 'as customer' do
|
||||||
let(:user) { customer_user }
|
let(:user) { customer }
|
||||||
|
|
||||||
include_examples 'deleting',
|
include_examples 'deleting',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -615,7 +615,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
let(:article) { article_note }
|
let(:article) { article_note }
|
||||||
|
|
||||||
context 'as admin' do
|
context 'as admin' do
|
||||||
let(:user) { admin_user }
|
let(:user) { admin }
|
||||||
|
|
||||||
context 'deleting after timeframe' do
|
context 'deleting after timeframe' do
|
||||||
before { article && travel(8000.seconds) }
|
before { article && travel(8000.seconds) }
|
||||||
|
@ -625,7 +625,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
context 'deleting before timeframe' do
|
context 'deleting before timeframe' do
|
||||||
before { article && travel(5000.seconds) }
|
before { article && travel(5000.seconds) }
|
||||||
|
@ -647,7 +647,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
|
||||||
let(:article) { article_note }
|
let(:article) { article_note }
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
context 'deleting long after' do
|
context 'deleting long after' do
|
||||||
before { article && travel(99.days) }
|
before { article && travel(99.days) }
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Ticket Escalation', type: :request do
|
RSpec.describe 'Ticket Escalation', type: :request do
|
||||||
|
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:calendar) do
|
let!(:calendar) do
|
||||||
create(
|
create(
|
||||||
|
@ -78,15 +78,15 @@ RSpec.describe 'Ticket Escalation', type: :request do
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
post '/api/v1/tickets', params: params, as: :json
|
post '/api/v1/tickets', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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['state_id']).to eq(Ticket::State.lookup(name: 'new').id)
|
expect(json_response['state_id']).to eq(Ticket::State.lookup(name: 'new').id)
|
||||||
expect(json_response['title']).to eq('some value 123')
|
expect(json_response['title']).to eq('some value 123')
|
||||||
expect(json_response['updated_by_id']).to eq(customer_user.id)
|
expect(json_response['updated_by_id']).to eq(customer.id)
|
||||||
expect(json_response['created_by_id']).to eq(customer_user.id)
|
expect(json_response['created_by_id']).to eq(customer.id)
|
||||||
|
|
||||||
ticket_p = Ticket.find(json_response['id'])
|
ticket_p = Ticket.find(json_response['id'])
|
||||||
|
|
||||||
|
@ -128,14 +128,14 @@ Some Text"
|
||||||
to: 'customer@example.com',
|
to: 'customer@example.com',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
put "/api/v1/tickets/#{ticket_p.id}", params: params, as: :json
|
put "/api/v1/tickets/#{ticket_p.id}", params: params, as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
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_id']).to eq(Ticket::State.lookup(name: 'open').id)
|
expect(json_response['state_id']).to eq(Ticket::State.lookup(name: 'open').id)
|
||||||
expect(json_response['title']).to eq('some value 123 - update')
|
expect(json_response['title']).to eq('some value 123 - update')
|
||||||
expect(json_response['updated_by_id']).to eq(agent_user.id)
|
expect(json_response['updated_by_id']).to eq(agent.id)
|
||||||
expect(json_response['created_by_id']).to eq(user_p.id)
|
expect(json_response['created_by_id']).to eq(user_p.id)
|
||||||
|
|
||||||
ticket_p.reload
|
ticket_p.reload
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Time Accounting API endpoints', type: :request do
|
RSpec.describe 'Time Accounting API endpoints', type: :request do
|
||||||
let(:admin) { create(:admin_user) }
|
let(:admin) { create(:admin) }
|
||||||
let(:customer) { create(:customer_user) }
|
let(:customer) { create(:customer) }
|
||||||
let(:year) { Time.current.year }
|
let(:year) { Time.current.year }
|
||||||
let(:month) { Time.current.month }
|
let(:month) { Time.current.month }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'UploadCache', type: :request do
|
RSpec.describe 'UploadCache', type: :request do
|
||||||
|
|
||||||
let(:user) { create(:customer_user) }
|
let(:user) { create(:customer) }
|
||||||
let(:form_id) { 1337 }
|
let(:form_id) { 1337 }
|
||||||
let(:upload_cache) { UploadCache.new(form_id) }
|
let(:upload_cache) { UploadCache.new(form_id) }
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'User Organization', type: :request, searchindex: true do
|
RSpec.describe 'User Organization', type: :request, searchindex: true do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(:admin_user, groups: Group.all)
|
create(:admin, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(:agent_user, groups: Group.all)
|
create(:agent, groups: Group.all)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(:customer_user)
|
create(:customer)
|
||||||
end
|
end
|
||||||
let!(:organization) do
|
let!(:organization) do
|
||||||
create(:organization, name: 'Rest Org', note: 'Rest Org A')
|
create(:organization, name: 'Rest Org', note: 'Rest Org A')
|
||||||
|
@ -20,8 +20,8 @@ RSpec.describe 'User Organization', type: :request, searchindex: true do
|
||||||
let!(:organization3) do
|
let!(:organization3) do
|
||||||
create(:organization, name: 'Rest Org #3', note: 'Rest Org C')
|
create(:organization, name: 'Rest Org #3', note: 'Rest Org C')
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(:customer_user, organization: organization)
|
create(:customer, organization: organization)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -41,7 +41,7 @@ RSpec.describe 'User Organization', type: :request, searchindex: true do
|
||||||
describe 'request handling' do
|
describe 'request handling' do
|
||||||
|
|
||||||
it 'does organization index with agent' do
|
it 'does organization index with agent' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -113,7 +113,7 @@ RSpec.describe 'User Organization', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does organization index with customer1' do
|
it 'does organization index with customer1' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -137,7 +137,7 @@ RSpec.describe 'User Organization', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does organization index with customer2' do
|
it 'does organization index with customer2' do
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer2)
|
||||||
get '/api/v1/organizations', params: {}, as: :json
|
get '/api/v1/organizations', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
let(:attributes) { attributes_params_for(:user) }
|
let(:attributes) { attributes_params_for(:user) }
|
||||||
|
|
||||||
it 'responds unauthorized for customer' do
|
it 'responds unauthorized for customer' do
|
||||||
requester = create(:customer_user)
|
requester = create(:customer)
|
||||||
authenticated_as(requester)
|
authenticated_as(requester)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
|
@ -71,7 +71,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds successful for agent but removes assignment' do
|
it 'responds successful for agent but removes assignment' do
|
||||||
requester = create(:agent_user)
|
requester = create(:agent)
|
||||||
authenticated_as(requester)
|
authenticated_as(requester)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
|
@ -144,7 +144,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds successful for agent but removes assignment' do
|
it 'responds successful for agent but removes assignment' do
|
||||||
requester = create(:agent_user)
|
requester = create(:agent)
|
||||||
authenticated_as(requester)
|
authenticated_as(requester)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
|
@ -228,21 +228,21 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is successful for other admin' do
|
it 'is successful for other admin' do
|
||||||
authorized_update_request(
|
authorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful for agent' do
|
it 'is successful for agent' do
|
||||||
authorized_update_request(
|
authorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful for customer' do
|
it 'is successful for customer' do
|
||||||
authorized_update_request(
|
authorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -261,33 +261,33 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other admin' do
|
it 'is unauthorized for other admin' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for agent' do
|
it 'is unauthorized for agent' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for customer' do
|
it 'is unauthorized for customer' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'request by agent' do
|
context 'request by agent' do
|
||||||
|
|
||||||
let(:requester) { create(:agent_user) }
|
let(:requester) { create(:agent) }
|
||||||
|
|
||||||
it 'is unauthorized for admin' do
|
it 'is unauthorized for admin' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -301,33 +301,33 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other agent' do
|
it 'is unauthorized for other agent' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful for customer' do
|
it 'is successful for customer' do
|
||||||
authorized_update_request(
|
authorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'request by customer' do
|
context 'request by customer' do
|
||||||
|
|
||||||
let(:requester) { create(:customer_user) }
|
let(:requester) { create(:customer) }
|
||||||
|
|
||||||
it 'is unauthorized for admin' do
|
it 'is unauthorized for admin' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for agent' do
|
it 'is unauthorized for agent' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other customer' do
|
it 'is unauthorized for other customer' do
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
|
|
||||||
unauthorized_update_request(
|
unauthorized_update_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user, organization: same_organization),
|
requested: create(:customer, organization: same_organization),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -399,7 +399,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
shared_examples 'permitted agent update' do
|
shared_examples 'permitted agent update' do
|
||||||
|
|
||||||
it 'responds successful for agent but removes assignment' do
|
it 'responds successful for agent but removes assignment' do
|
||||||
requester = create(:agent_user)
|
requester = create(:agent)
|
||||||
authenticated_as(requester)
|
authenticated_as(requester)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
|
@ -415,7 +415,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
shared_examples 'forbidden agent update' do
|
shared_examples 'forbidden agent update' do
|
||||||
|
|
||||||
it 'responds successful for agent but removes assignment' do
|
it 'responds successful for agent but removes assignment' do
|
||||||
requester = create(:agent_user)
|
requester = create(:agent)
|
||||||
authenticated_as(requester)
|
authenticated_as(requester)
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
|
@ -545,21 +545,21 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is successful for other admin' do
|
it 'is successful for other admin' do
|
||||||
authorized_destroy_request(
|
authorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful for agent' do
|
it 'is successful for agent' do
|
||||||
authorized_destroy_request(
|
authorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is successful for customer' do
|
it 'is successful for customer' do
|
||||||
authorized_destroy_request(
|
authorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -578,33 +578,33 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other admin' do
|
it 'is unauthorized for other admin' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for agent' do
|
it 'is unauthorized for agent' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for customer' do
|
it 'is unauthorized for customer' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'request by agent' do
|
context 'request by agent' do
|
||||||
|
|
||||||
let(:requester) { create(:agent_user) }
|
let(:requester) { create(:agent) }
|
||||||
|
|
||||||
it 'is unauthorized for admin' do
|
it 'is unauthorized for admin' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -618,33 +618,33 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other agent' do
|
it 'is unauthorized for other agent' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for customer' do
|
it 'is unauthorized for customer' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'request by customer' do
|
context 'request by customer' do
|
||||||
|
|
||||||
let(:requester) { create(:customer_user) }
|
let(:requester) { create(:customer) }
|
||||||
|
|
||||||
it 'is unauthorized for admin' do
|
it 'is unauthorized for admin' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:admin_user),
|
requested: create(:admin),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is unauthorized for agent' do
|
it 'is unauthorized for agent' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:agent_user),
|
requested: create(:agent),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
it 'is unauthorized for other customer' do
|
it 'is unauthorized for other customer' do
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user),
|
requested: create(:customer),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ RSpec.describe 'User endpoint', type: :request do
|
||||||
|
|
||||||
unauthorized_destroy_request(
|
unauthorized_destroy_request(
|
||||||
requester: requester,
|
requester: requester,
|
||||||
requested: create(:customer_user, organization: same_organization),
|
requested: create(:customer, organization: same_organization),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,9 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'User', type: :request, searchindex: true do
|
RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
|
|
||||||
let!(:admin_user) do
|
let!(:admin) do
|
||||||
create(
|
create(
|
||||||
:admin_user,
|
:admin,
|
||||||
groups: Group.all,
|
groups: Group.all,
|
||||||
login: 'rest-admin',
|
login: 'rest-admin',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
|
@ -12,9 +12,9 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
email: 'rest-admin@example.com',
|
email: 'rest-admin@example.com',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:admin_user_pw) do
|
let!(:admin_with_pw) do
|
||||||
create(
|
create(
|
||||||
:admin_user,
|
:admin,
|
||||||
groups: Group.all,
|
groups: Group.all,
|
||||||
login: 'rest-admin-pw',
|
login: 'rest-admin-pw',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
|
@ -23,9 +23,9 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
password: 'adminpw',
|
password: 'adminpw',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:agent_user) do
|
let!(:agent) do
|
||||||
create(
|
create(
|
||||||
:agent_user,
|
:agent,
|
||||||
groups: Group.all,
|
groups: Group.all,
|
||||||
login: 'rest-agent@example.com',
|
login: 'rest-agent@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
|
@ -33,9 +33,9 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
email: 'rest-agent@example.com',
|
email: 'rest-agent@example.com',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let!(:customer_user) do
|
let!(:customer) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-customer1@example.com',
|
login: 'rest-customer1@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
|
@ -51,9 +51,9 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
let!(:organization3) do
|
let!(:organization3) do
|
||||||
create(:organization, name: 'Rest Org #3')
|
create(:organization, name: 'Rest Org #3')
|
||||||
end
|
end
|
||||||
let!(:customer_user2) do
|
let!(:customer2) do
|
||||||
create(
|
create(
|
||||||
:customer_user,
|
:customer,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
login: 'rest-customer2@example.com',
|
login: 'rest-customer2@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
|
@ -191,7 +191,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does auth tests - username auth, wrong pw' do
|
it 'does auth tests - username auth, wrong pw' do
|
||||||
authenticated_as(admin_user, password: 'not_existing')
|
authenticated_as(admin, password: 'not_existing')
|
||||||
get '/api/v1/users', params: {}, as: :json
|
get '/api/v1/users', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(json_response['error']).to eq('authentication failed')
|
expect(json_response['error']).to eq('authentication failed')
|
||||||
|
@ -219,7 +219,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does user index and create with admin' do
|
it 'does user index and create with admin' do
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/users/me', params: {}, as: :json
|
get '/api/v1/users/me', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -238,13 +238,13 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response.length >= 3).to be_truthy
|
expect(json_response.length >= 3).to be_truthy
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/users/#{agent_user.id}", params: {}, as: :json
|
get "/api/v1/users/#{agent.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('rest-agent@example.com').to eq(json_response['email'])
|
expect('rest-agent@example.com').to eq(json_response['email'])
|
||||||
|
|
||||||
get "/api/v1/users/#{customer_user.id}", params: {}, as: :json
|
get "/api/v1/users/#{customer.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
|
@ -327,7 +327,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does user index and create with agent' do
|
it 'does user index and create with agent' do
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get '/api/v1/users/me', params: {}, as: :json
|
get '/api/v1/users/me', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -367,42 +367,42 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
params = { firstname: "Admin#{firstname}", lastname: 'Admin Last', email: 'new_admin_by_agent@example.com', role_ids: [ role.id ] }
|
params = { firstname: "Admin#{firstname}", lastname: 'Admin Last', email: 'new_admin_by_agent@example.com', role_ids: [ role.id ] }
|
||||||
post '/api/v1/users', params: params, as: :json
|
post '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
json_response_user1 = JSON.parse(@response.body)
|
json_response1 = JSON.parse(@response.body)
|
||||||
expect(json_response_user1).to be_truthy
|
expect(json_response1).to be_truthy
|
||||||
user = User.find(json_response_user1['id'])
|
user = User.find(json_response1['id'])
|
||||||
expect(user).not_to be_role('Admin')
|
expect(user).not_to be_role('Admin')
|
||||||
expect(user).not_to be_role('Agent')
|
expect(user).not_to be_role('Agent')
|
||||||
expect(user).to be_role('Customer')
|
expect(user).to be_role('Customer')
|
||||||
expect(json_response_user1['login']).to eq('new_admin_by_agent@example.com')
|
expect(json_response1['login']).to eq('new_admin_by_agent@example.com')
|
||||||
expect(json_response_user1['email']).to eq('new_admin_by_agent@example.com')
|
expect(json_response1['email']).to eq('new_admin_by_agent@example.com')
|
||||||
|
|
||||||
# create user with agent role
|
# create user with agent role
|
||||||
role = Role.lookup(name: 'Agent')
|
role = Role.lookup(name: 'Agent')
|
||||||
params = { firstname: "Agent#{firstname}", lastname: 'Agent Last', email: 'new_agent_by_agent@example.com', role_ids: [ role.id ] }
|
params = { firstname: "Agent#{firstname}", lastname: 'Agent Last', email: 'new_agent_by_agent@example.com', role_ids: [ role.id ] }
|
||||||
post '/api/v1/users', params: params, as: :json
|
post '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
json_response_user1 = JSON.parse(@response.body)
|
json_response1 = JSON.parse(@response.body)
|
||||||
expect(json_response_user1).to be_truthy
|
expect(json_response1).to be_truthy
|
||||||
user = User.find(json_response_user1['id'])
|
user = User.find(json_response1['id'])
|
||||||
expect(user).not_to be_role('Admin')
|
expect(user).not_to be_role('Admin')
|
||||||
expect(user).not_to be_role('Agent')
|
expect(user).not_to be_role('Agent')
|
||||||
expect(user).to be_role('Customer')
|
expect(user).to be_role('Customer')
|
||||||
expect(json_response_user1['login']).to eq('new_agent_by_agent@example.com')
|
expect(json_response1['login']).to eq('new_agent_by_agent@example.com')
|
||||||
expect(json_response_user1['email']).to eq('new_agent_by_agent@example.com')
|
expect(json_response1['email']).to eq('new_agent_by_agent@example.com')
|
||||||
|
|
||||||
# create user with customer role
|
# create user with customer role
|
||||||
role = Role.lookup(name: 'Customer')
|
role = Role.lookup(name: 'Customer')
|
||||||
params = { firstname: "Customer#{firstname}", lastname: 'Customer Last', email: 'new_customer_by_agent@example.com', role_ids: [ role.id ] }
|
params = { firstname: "Customer#{firstname}", lastname: 'Customer Last', email: 'new_customer_by_agent@example.com', role_ids: [ role.id ] }
|
||||||
post '/api/v1/users', params: params, as: :json
|
post '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
json_response_user1 = JSON.parse(@response.body)
|
json_response1 = JSON.parse(@response.body)
|
||||||
expect(json_response_user1).to be_truthy
|
expect(json_response1).to be_truthy
|
||||||
user = User.find(json_response_user1['id'])
|
user = User.find(json_response1['id'])
|
||||||
expect(user).not_to be_role('Admin')
|
expect(user).not_to be_role('Admin')
|
||||||
expect(user).not_to be_role('Agent')
|
expect(user).not_to be_role('Agent')
|
||||||
expect(user).to be_role('Customer')
|
expect(user).to be_role('Customer')
|
||||||
expect(json_response_user1['login']).to eq('new_customer_by_agent@example.com')
|
expect(json_response1['login']).to eq('new_customer_by_agent@example.com')
|
||||||
expect(json_response_user1['email']).to eq('new_customer_by_agent@example.com')
|
expect(json_response1['email']).to eq('new_customer_by_agent@example.com')
|
||||||
|
|
||||||
# search as agent
|
# search as agent
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
|
@ -411,7 +411,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['firstname']).to eq("Customer#{firstname}")
|
expect(json_response[0]['firstname']).to eq("Customer#{firstname}")
|
||||||
expect(json_response[0]['lastname']).to eq('Customer Last')
|
expect(json_response[0]['lastname']).to eq('Customer Last')
|
||||||
expect(json_response[0]['role_ids']).to be_truthy
|
expect(json_response[0]['role_ids']).to be_truthy
|
||||||
|
@ -420,7 +420,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&expand=true", params: {}, as: :json
|
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&expand=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['firstname']).to eq("Customer#{firstname}")
|
expect(json_response[0]['firstname']).to eq("Customer#{firstname}")
|
||||||
expect(json_response[0]['lastname']).to eq('Customer Last')
|
expect(json_response[0]['lastname']).to eq('Customer Last')
|
||||||
expect(json_response[0]['role_ids']).to be_truthy
|
expect(json_response[0]['role_ids']).to be_truthy
|
||||||
|
@ -429,7 +429,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&label=true", params: {}, as: :json
|
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&label=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['role_ids']).to be_falsey
|
expect(json_response[0]['role_ids']).to be_falsey
|
||||||
|
@ -438,7 +438,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
get "/api/v1/users/search?term=#{CGI.escape("Customer#{firstname}")}", params: {}, as: :json
|
get "/api/v1/users/search?term=#{CGI.escape("Customer#{firstname}")}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['value']).to eq('new_customer_by_agent@example.com')
|
expect(json_response[0]['value']).to eq('new_customer_by_agent@example.com')
|
||||||
expect(json_response[0]['role_ids']).to be_falsey
|
expect(json_response[0]['role_ids']).to be_falsey
|
||||||
|
@ -447,12 +447,12 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
# Regression test for issue #2539 - search pagination broken in users_controller.rb
|
# Regression test for issue #2539 - search pagination broken in users_controller.rb
|
||||||
# Get the total number of users N, then search with one result per page, so there should N pages with one result each
|
# Get the total number of users N, then search with one result per page, so there should N pages with one result each
|
||||||
get '/api/v1/users/search', params: { query: '*' }, as: :json
|
get '/api/v1/users/search', params: { query: '*' }, as: :json
|
||||||
total_user_number = json_response.count
|
total_number = json_response.count
|
||||||
(1..total_user_number).each do |i|
|
(1..total_number).each do |i|
|
||||||
get '/api/v1/users/search', params: { query: '*', per_page: 1, page: i }, as: :json
|
get '/api/v1/users/search', params: { query: '*', per_page: 1, page: i }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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.count).to eq(1), "Page #{i}/#{total_user_number} of the user search pagination test have the wrong result!"
|
expect(json_response.count).to eq(1), "Page #{i}/#{total_number} of the user search pagination test have the wrong result!"
|
||||||
end
|
end
|
||||||
|
|
||||||
role = Role.find_by(name: 'Agent')
|
role = Role.find_by(name: 'Agent')
|
||||||
|
@ -465,7 +465,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&role_ids=#{role.id}&label=true", params: {}, as: :json
|
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&role_ids=#{role.id}&label=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['role_ids']).to be_falsey
|
expect(json_response[0]['role_ids']).to be_falsey
|
||||||
|
@ -481,7 +481,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&permissions=#{permission.name}&label=true", params: {}, as: :json
|
get "/api/v1/users/search?query=#{CGI.escape("Customer#{firstname}")}&permissions=#{permission.name}&label=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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]['id']).to eq(json_response_user1['id'])
|
expect(json_response[0]['id']).to eq(json_response1['id'])
|
||||||
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['label']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
expect(json_response[0]['value']).to eq("Customer#{firstname} Customer Last <new_customer_by_agent@example.com>")
|
||||||
expect(json_response[0]['role_ids']).to be_falsey
|
expect(json_response[0]['role_ids']).to be_falsey
|
||||||
|
@ -489,7 +489,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does user index and create with customer1' do
|
it 'does user index and create with customer1' do
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/users/me', params: {}, as: :json
|
get '/api/v1/users/me', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -502,12 +502,12 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(1).to eq(json_response.length)
|
expect(1).to eq(json_response.length)
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/users/#{customer_user.id}", params: {}, as: :json
|
get "/api/v1/users/#{customer.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('rest-customer1@example.com').to eq(json_response['email'])
|
expect('rest-customer1@example.com').to eq(json_response['email'])
|
||||||
|
|
||||||
get "/api/v1/users/#{customer_user2.id}", params: {}, as: :json
|
get "/api/v1/users/#{customer2.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_truthy
|
||||||
|
@ -531,7 +531,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does user index with customer2' do
|
it 'does user index with customer2' do
|
||||||
authenticated_as(customer_user2)
|
authenticated_as(customer2)
|
||||||
get '/api/v1/users/me', params: {}, as: :json
|
get '/api/v1/users/me', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(json_response).to be_truthy
|
expect(json_response).to be_truthy
|
||||||
|
@ -544,12 +544,12 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(1).to eq(json_response.length)
|
expect(1).to eq(json_response.length)
|
||||||
|
|
||||||
# show/:id
|
# show/:id
|
||||||
get "/api/v1/users/#{customer_user2.id}", params: {}, as: :json
|
get "/api/v1/users/#{customer2.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect('rest-customer2@example.com').to eq(json_response['email'])
|
expect('rest-customer2@example.com').to eq(json_response['email'])
|
||||||
|
|
||||||
get "/api/v1/users/#{customer_user.id}", params: {}, as: :json
|
get "/api/v1/users/#{customer.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
expect(Hash).to eq(json_response.class)
|
expect(Hash).to eq(json_response.class)
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_truthy
|
||||||
|
@ -562,7 +562,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
|
|
||||||
it 'does users show and response format (04.01)' do
|
it 'does users show and response format (04.01)' do
|
||||||
user = create(
|
user = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-customer3@example.com',
|
login: 'rest-customer3@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -570,11 +570,11 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
password: 'customer3pw',
|
password: 'customer3pw',
|
||||||
active: true,
|
active: true,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get "/api/v1/users/#{user.id}", params: {}, as: :json
|
get "/api/v1/users/#{user.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -584,8 +584,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['role_ids']).to eq(user.role_ids)
|
expect(json_response['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get "/api/v1/users/#{user.id}?expand=true", params: {}, as: :json
|
get "/api/v1/users/#{user.id}?expand=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -596,8 +596,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization']).to eq(user.organization.name)
|
expect(json_response['organization']).to eq(user.organization.name)
|
||||||
expect(json_response['role_ids']).to eq(user.role_ids)
|
expect(json_response['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get "/api/v1/users/#{user.id}?expand=false", params: {}, as: :json
|
get "/api/v1/users/#{user.id}?expand=false", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -608,8 +608,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['role_ids']).to eq(user.role_ids)
|
expect(json_response['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get "/api/v1/users/#{user.id}?full=true", params: {}, as: :json
|
get "/api/v1/users/#{user.id}?full=true", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -633,13 +633,13 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['role_ids']).to eq(user.role_ids)
|
expect(json_response['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does user index and response format (04.02)' do
|
it 'does user index and response format (04.02)' do
|
||||||
user = create(
|
user = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-customer3@example.com',
|
login: 'rest-customer3@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -647,11 +647,11 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
password: 'customer3pw',
|
password: 'customer3pw',
|
||||||
active: true,
|
active: true,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/users', params: {}, as: :json
|
get '/api/v1/users', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -662,8 +662,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response.last['password']).to be_falsey
|
expect(json_response.last['password']).to be_falsey
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get '/api/v1/users?expand=true', params: {}, as: :json
|
get '/api/v1/users?expand=true', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -674,8 +674,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response.last['organization']).to eq(user.organization.name)
|
expect(json_response.last['organization']).to eq(user.organization.name)
|
||||||
expect(json_response.last['password']).to be_falsey
|
expect(json_response.last['password']).to be_falsey
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get '/api/v1/users?expand=false', params: {}, as: :json
|
get '/api/v1/users?expand=false', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -687,8 +687,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response.last['password']).to be_falsey
|
expect(json_response.last['password']).to be_falsey
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
get '/api/v1/users?full=true', params: {}, as: :json
|
get '/api/v1/users?full=true', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
@ -715,8 +715,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
expect(json_response.last['role_ids']).to eq(user.role_ids)
|
||||||
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
expect(json_response.last['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response.last['password']).to be_falsey
|
expect(json_response.last['password']).to be_falsey
|
||||||
expect(json_response.last['updated_by_id']).to eq(admin_user.id)
|
expect(json_response.last['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response.last['created_by_id']).to eq(admin_user.id)
|
expect(json_response.last['created_by_id']).to eq(admin.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does ticket create and response format (04.03)' do
|
it 'does ticket create and response format (04.03)' do
|
||||||
|
@ -727,7 +727,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
organization: organization.name,
|
organization: organization.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/users', params: params, as: :json
|
post '/api/v1/users', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
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)
|
||||||
|
@ -737,8 +737,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['organization']).to be_falsey
|
expect(json_response['organization']).to be_falsey
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
post '/api/v1/users?expand=true', params: params, as: :json
|
post '/api/v1/users?expand=true', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
|
@ -749,8 +749,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['organization']).to eq(user.organization.name)
|
expect(json_response['organization']).to eq(user.organization.name)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
post '/api/v1/users?full=true', params: params, as: :json
|
post '/api/v1/users?full=true', params: params, as: :json
|
||||||
expect(response).to have_http_status(:created)
|
expect(response).to have_http_status(:created)
|
||||||
|
@ -765,17 +765,17 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['assets']['User'][user.id.to_s]['lastname']).to eq(user.lastname)
|
expect(json_response['assets']['User'][user.id.to_s]['lastname']).to eq(user.lastname)
|
||||||
expect(json_response['assets']['User'][user.id.to_s]['password']).to be_falsey
|
expect(json_response['assets']['User'][user.id.to_s]['password']).to be_falsey
|
||||||
|
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][admin.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['id']).to eq(admin_user.id)
|
expect(json_response['assets']['User'][admin.id.to_s]['id']).to eq(admin.id)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['firstname']).to eq(admin_user.firstname)
|
expect(json_response['assets']['User'][admin.id.to_s]['firstname']).to eq(admin.firstname)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['lastname']).to eq(admin_user.lastname)
|
expect(json_response['assets']['User'][admin.id.to_s]['lastname']).to eq(admin.lastname)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['password']).to be_falsey
|
expect(json_response['assets']['User'][admin.id.to_s]['password']).to be_falsey
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does ticket update and response formats (04.04)' do
|
it 'does ticket update and response formats (04.04)' do
|
||||||
user = create(
|
user = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-customer3@example.com',
|
login: 'rest-customer3@example.com',
|
||||||
firstname: 'Rest',
|
firstname: 'Rest',
|
||||||
lastname: 'Customer3',
|
lastname: 'Customer3',
|
||||||
|
@ -783,11 +783,11 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
password: 'customer3pw',
|
password: 'customer3pw',
|
||||||
active: true,
|
active: true,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
updated_by_id: admin_user.id,
|
updated_by_id: admin.id,
|
||||||
created_by_id: admin_user.id,
|
created_by_id: admin.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
params = {
|
params = {
|
||||||
firstname: 'a update firstname #1',
|
firstname: 'a update firstname #1',
|
||||||
}
|
}
|
||||||
|
@ -801,8 +801,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['organization']).to be_falsey
|
expect(json_response['organization']).to be_falsey
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
firstname: 'a update firstname #2',
|
firstname: 'a update firstname #2',
|
||||||
|
@ -817,8 +817,8 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['organization_id']).to eq(user.organization_id)
|
expect(json_response['organization_id']).to eq(user.organization_id)
|
||||||
expect(json_response['organization']).to eq(user.organization.name)
|
expect(json_response['organization']).to eq(user.organization.name)
|
||||||
expect(json_response['password']).to be_falsey
|
expect(json_response['password']).to be_falsey
|
||||||
expect(json_response['updated_by_id']).to eq(admin_user.id)
|
expect(json_response['updated_by_id']).to eq(admin.id)
|
||||||
expect(json_response['created_by_id']).to eq(admin_user.id)
|
expect(json_response['created_by_id']).to eq(admin.id)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
firstname: 'a update firstname #3',
|
firstname: 'a update firstname #3',
|
||||||
|
@ -836,17 +836,17 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
expect(json_response['assets']['User'][user.id.to_s]['lastname']).to eq(user.lastname)
|
expect(json_response['assets']['User'][user.id.to_s]['lastname']).to eq(user.lastname)
|
||||||
expect(json_response['assets']['User'][user.id.to_s]['password']).to be_falsey
|
expect(json_response['assets']['User'][user.id.to_s]['password']).to be_falsey
|
||||||
|
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]).to be_truthy
|
expect(json_response['assets']['User'][admin.id.to_s]).to be_truthy
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['id']).to eq(admin_user.id)
|
expect(json_response['assets']['User'][admin.id.to_s]['id']).to eq(admin.id)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['firstname']).to eq(admin_user.firstname)
|
expect(json_response['assets']['User'][admin.id.to_s]['firstname']).to eq(admin.firstname)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['lastname']).to eq(admin_user.lastname)
|
expect(json_response['assets']['User'][admin.id.to_s]['lastname']).to eq(admin.lastname)
|
||||||
expect(json_response['assets']['User'][admin_user.id.to_s]['password']).to be_falsey
|
expect(json_response['assets']['User'][admin.id.to_s]['password']).to be_falsey
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does csv example - customer no access (05.01)' do
|
it 'does csv example - customer no access (05.01)' do
|
||||||
|
|
||||||
authenticated_as(customer_user)
|
authenticated_as(customer)
|
||||||
get '/api/v1/users/import_example', params: {}, as: :json
|
get '/api/v1/users/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:unauthorized)
|
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)!')
|
||||||
|
@ -854,7 +854,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
|
|
||||||
it 'does csv example - admin access (05.02)' do
|
it 'does csv example - admin access (05.02)' do
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get '/api/v1/users/import_example', params: {}, as: :json
|
get '/api/v1/users/import_example', params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
|
|
||||||
# invalid file
|
# invalid file
|
||||||
csv_file = fixture_file_upload('csv_import/user/simple_col_not_existing.csv', 'text/csv')
|
csv_file = fixture_file_upload('csv_import/user/simple_col_not_existing.csv', 'text/csv')
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
post '/api/v1/users/import?try=true', params: { file: csv_file, col_sep: ';' }
|
post '/api/v1/users/import?try=true', params: { file: csv_file, col_sep: ';' }
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -929,14 +929,14 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
|
|
||||||
it 'does user history' do
|
it 'does user history' do
|
||||||
user1 = create(
|
user1 = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'history@example.com',
|
login: 'history@example.com',
|
||||||
firstname: 'History',
|
firstname: 'History',
|
||||||
lastname: 'Customer1',
|
lastname: 'Customer1',
|
||||||
email: 'history@example.com',
|
email: 'history@example.com',
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticated_as(agent_user)
|
authenticated_as(agent)
|
||||||
get "/api/v1/users/history/#{user1.id}", params: {}, as: :json
|
get "/api/v1/users/history/#{user1.id}", params: {}, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -950,7 +950,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
firstname = "user_search_sortable #{rand(999_999_999)}"
|
firstname = "user_search_sortable #{rand(999_999_999)}"
|
||||||
|
|
||||||
user1 = create(
|
user1 = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-user_search_sortableA@example.com',
|
login: 'rest-user_search_sortableA@example.com',
|
||||||
firstname: "#{firstname} A",
|
firstname: "#{firstname} A",
|
||||||
lastname: 'user_search_sortableA',
|
lastname: 'user_search_sortableA',
|
||||||
|
@ -962,7 +962,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
created_at: '2016-02-05 17:42:00',
|
created_at: '2016-02-05 17:42:00',
|
||||||
)
|
)
|
||||||
user2 = create(
|
user2 = create(
|
||||||
:customer_user,
|
:customer,
|
||||||
login: 'rest-user_search_sortableB@example.com',
|
login: 'rest-user_search_sortableB@example.com',
|
||||||
firstname: "#{firstname} B",
|
firstname: "#{firstname} B",
|
||||||
lastname: 'user_search_sortableB',
|
lastname: 'user_search_sortableB',
|
||||||
|
@ -979,7 +979,7 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
sleep 2 # let es time to come ready
|
sleep 2 # let es time to come ready
|
||||||
|
|
||||||
authenticated_as(admin_user)
|
authenticated_as(admin)
|
||||||
get "/api/v1/users/search?query=#{CGI.escape(firstname)}", params: { sort_by: 'created_at', order_by: 'asc' }, as: :json
|
get "/api/v1/users/search?query=#{CGI.escape(firstname)}", params: { sort_by: 'created_at', order_by: 'asc' }, as: :json
|
||||||
expect(response).to have_http_status(:ok)
|
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)
|
||||||
|
@ -1038,10 +1038,10 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'does password reset send work' do
|
context 'does password reset send work' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: 'somebody@example.com') }
|
let(:user) { create(:customer, login: 'somebody', email: 'somebody@example.com') }
|
||||||
|
|
||||||
context 'for user without email address' do
|
context 'for user without email address' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: '') }
|
let(:user) { create(:customer, login: 'somebody', email: '') }
|
||||||
|
|
||||||
it 'return failed' do
|
it 'return failed' do
|
||||||
post '/api/v1/users/password_reset', params: { username: user.login }, as: :json
|
post '/api/v1/users/password_reset', params: { username: user.login }, as: :json
|
||||||
|
@ -1076,11 +1076,11 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'does password reset by token work' do
|
context 'does password reset by token work' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: 'somebody@example.com') }
|
let(:user) { create(:customer, login: 'somebody', email: 'somebody@example.com') }
|
||||||
let(:token) { create(:token, action: 'PasswordReset', user_id: user.id) }
|
let(:token) { create(:token, action: 'PasswordReset', user_id: user.id) }
|
||||||
|
|
||||||
context 'for user without email address' do
|
context 'for user without email address' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: '') }
|
let(:user) { create(:customer, login: 'somebody', email: '') }
|
||||||
|
|
||||||
it 'return failed' do
|
it 'return failed' do
|
||||||
post '/api/v1/users/password_reset_verify', params: { username: user.login, token: token.name, password: 'Test1234#.' }, as: :json
|
post '/api/v1/users/password_reset_verify', params: { username: user.login, token: token.name, password: 'Test1234#.' }, as: :json
|
||||||
|
@ -1115,12 +1115,12 @@ RSpec.describe 'User', type: :request, searchindex: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'password change' do
|
context 'password change' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: 'somebody@example.com', password: 'Test1234#.') }
|
let(:user) { create(:customer, login: 'somebody', email: 'somebody@example.com', password: 'Test1234#.') }
|
||||||
|
|
||||||
before { authenticated_as(user, login: 'somebody', password: 'Test1234#.') }
|
before { authenticated_as(user, login: 'somebody', password: 'Test1234#.') }
|
||||||
|
|
||||||
context 'user without email address' do
|
context 'user without email address' do
|
||||||
let(:user) { create(:customer_user, login: 'somebody', email: '', password: 'Test1234#.') }
|
let(:user) { create(:customer, login: 'somebody', email: '', password: 'Test1234#.') }
|
||||||
|
|
||||||
it 'return ok' do
|
it 'return ok' do
|
||||||
post '/api/v1/users/password_change', params: { password_old: 'Test1234#.', password_new: 'Test12345#.' }, as: :json
|
post '/api/v1/users/password_change', params: { password_old: 'Test1234#.', password_new: 'Test12345#.' }, as: :json
|
||||||
|
|
|
@ -98,7 +98,7 @@ module ZammadSpecSupportRequest
|
||||||
# @see FactoryBot#attributes_for
|
# @see FactoryBot#attributes_for
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
# attributes_params_for(:admin_user, email: 'custom@example.com')
|
# attributes_params_for(:admin, email: 'custom@example.com')
|
||||||
# # => {firstname: 'Nicole', email: 'custom@example.com', ...}
|
# # => {firstname: 'Nicole', email: 'custom@example.com', ...}
|
||||||
#
|
#
|
||||||
# @return [Hash{Symbol => <String, Array, Hash>}] request cleaned attributes
|
# @return [Hash{Symbol => <String, Array, Hash>}] request cleaned attributes
|
||||||
|
@ -145,7 +145,7 @@ RSpec.configure do |config|
|
||||||
#
|
#
|
||||||
# In order for this to work, you must define the user in a `let` block first:
|
# In order for this to work, you must define the user in a `let` block first:
|
||||||
#
|
#
|
||||||
# let(:user) { create(:customer_user) }
|
# let(:user) { create(:customer) }
|
||||||
#
|
#
|
||||||
config.before(:each, :authenticated_as, type: :request) do |example|
|
config.before(:each, :authenticated_as, type: :request) do |example|
|
||||||
user = authenticated_as_get_user example.metadata[:authenticated_as], return_type: :user
|
user = authenticated_as_get_user example.metadata[:authenticated_as], return_type: :user
|
||||||
|
|
|
@ -11,7 +11,7 @@ module SendsNotificationEmailsHelper
|
||||||
#
|
#
|
||||||
# sent(
|
# sent(
|
||||||
# template: 'user_device_new',
|
# template: 'user_device_new',
|
||||||
# user: admin_user,
|
# user: admin,
|
||||||
# )
|
# )
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
|
@ -31,7 +31,7 @@ module SendsNotificationEmailsHelper
|
||||||
# @example
|
# @example
|
||||||
# not_sent(
|
# not_sent(
|
||||||
# template: 'user_device_new_location',
|
# template: 'user_device_new_location',
|
||||||
# user: admin_user,
|
# user: admin,
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
|
@ -50,7 +50,7 @@ module SendsNotificationEmailsHelper
|
||||||
# @example
|
# @example
|
||||||
# sent(
|
# sent(
|
||||||
# template: 'user_device_new_location',
|
# template: 'user_device_new_location',
|
||||||
# user: admin_user,
|
# user: admin,
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'system/examples/text_modules_examples'
|
||||||
|
|
||||||
RSpec.describe 'Ticket Create', type: :system do
|
RSpec.describe 'Ticket Create', type: :system do
|
||||||
context 'when applying ticket templates' do
|
context 'when applying ticket templates' do
|
||||||
let(:agent) { create(:agent_user, groups: [permitted_group]) }
|
let(:agent) { create(:agent, groups: [permitted_group]) }
|
||||||
let(:permitted_group) { create(:group) }
|
let(:permitted_group) { create(:group) }
|
||||||
let(:unpermitted_group) { create(:group) }
|
let(:unpermitted_group) { create(:group) }
|
||||||
let!(:template) { create(:template, :dummy_data, group: unpermitted_group, owner: agent) }
|
let!(:template) { create(:template, :dummy_data, group: unpermitted_group, owner: agent) }
|
||||||
|
@ -64,7 +64,7 @@ RSpec.describe 'Ticket Create', type: :system do
|
||||||
let(:email_address) { create(:email_address, email: system_email_address) }
|
let(:email_address) { create(:email_address, email: system_email_address) }
|
||||||
let(:group) { create(:group, email_address: email_address) }
|
let(:group) { create(:group, email_address: email_address) }
|
||||||
let(:agent_groups) { [group] }
|
let(:agent_groups) { [group] }
|
||||||
let(:agent) { create(:agent_user, groups: agent_groups) }
|
let(:agent) { create(:agent, groups: agent_groups) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create(:smime_certificate, :with_private, fixture: system_email_address)
|
create(:smime_certificate, :with_private, fixture: system_email_address)
|
||||||
|
@ -73,7 +73,7 @@ RSpec.describe 'Ticket Create', type: :system do
|
||||||
context 'recipient certificate present' do
|
context 'recipient certificate present' do
|
||||||
|
|
||||||
let(:recipient_email_address) { 'smime2@example.com' }
|
let(:recipient_email_address) { 'smime2@example.com' }
|
||||||
let(:customer) { create(:customer_user, email: recipient_email_address) }
|
let(:customer) { create(:customer, email: recipient_email_address) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create(:smime_certificate, fixture: recipient_email_address)
|
create(:smime_certificate, fixture: recipient_email_address)
|
||||||
|
|
|
@ -178,7 +178,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
context 'Group without signature' do
|
context 'Group without signature' do
|
||||||
|
|
||||||
let(:ticket) { create(:ticket) }
|
let(:ticket) { create(:ticket) }
|
||||||
let(:current_user) { create(:agent_user, password: 'test', groups: [ticket.group]) }
|
let(:current_user) { create(:agent, password: 'test', groups: [ticket.group]) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# initial article to reply to
|
# initial article to reply to
|
||||||
|
@ -208,28 +208,28 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'delete article', authenticated_as: :user do
|
describe 'delete article', authenticated_as: :user do
|
||||||
let(:admin_user) { create :admin, groups: [Group.first] }
|
let(:admin) { create :admin, groups: [Group.first] }
|
||||||
let(:agent_user) { create :agent, groups: [Group.first] }
|
let(:agent) { create :agent, groups: [Group.first] }
|
||||||
let(:customer_user) { create :customer }
|
let(:customer) { create :customer }
|
||||||
let(:ticket) { create :ticket, group: agent_user.groups.first, customer: customer_user }
|
let(:ticket) { create :ticket, group: agent.groups.first, customer: customer }
|
||||||
let(:article) { send(item) }
|
let(:article) { send(item) }
|
||||||
|
|
||||||
def article_communication
|
def article_communication
|
||||||
create_ticket_article(sender_name: 'Agent', internal: false, type_name: 'email', updated_by: customer_user)
|
create_ticket_article(sender_name: 'Agent', internal: false, type_name: 'email', updated_by: customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def article_note
|
def article_note
|
||||||
create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note', updated_by: agent_user)
|
create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note', updated_by: agent)
|
||||||
end
|
end
|
||||||
|
|
||||||
def article_note_customer
|
def article_note_customer
|
||||||
create_ticket_article(sender_name: 'Customer', internal: false, type_name: 'note', updated_by: customer_user)
|
create_ticket_article(sender_name: 'Customer', internal: false, type_name: 'note', updated_by: customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def article_note_communication
|
def article_note_communication
|
||||||
create(:ticket_article_type, name: 'note_communication', communication: true)
|
create(:ticket_article_type, name: 'note_communication', communication: true)
|
||||||
|
|
||||||
create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note_communication', updated_by: agent_user)
|
create_ticket_article(sender_name: 'Agent', internal: true, type_name: 'note_communication', updated_by: agent)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_ticket_article(sender_name:, internal:, type_name:, updated_by:)
|
def create_ticket_article(sender_name:, internal:, type_name:, updated_by:)
|
||||||
|
@ -242,7 +242,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
|
|
||||||
context 'going through full stack' do
|
context 'going through full stack' do
|
||||||
context 'as admin' do
|
context 'as admin' do
|
||||||
let(:user) { admin_user }
|
let(:user) { admin }
|
||||||
let(:item) { 'article_communication' }
|
let(:item) { 'article_communication' }
|
||||||
let(:offset) { 0.minutes }
|
let(:offset) { 0.minutes }
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as admin' do
|
context 'as admin' do
|
||||||
let(:user) { admin_user }
|
let(:user) { admin }
|
||||||
|
|
||||||
include_examples 'deleting ticket article',
|
include_examples 'deleting ticket article',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -314,7 +314,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
include_examples 'deleting ticket article',
|
include_examples 'deleting ticket article',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -334,7 +334,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as customer' do
|
context 'as customer' do
|
||||||
let(:user) { customer_user }
|
let(:user) { customer }
|
||||||
|
|
||||||
include_examples 'deleting ticket article',
|
include_examples 'deleting ticket article',
|
||||||
item: 'article_communication',
|
item: 'article_communication',
|
||||||
|
@ -350,13 +350,13 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 6000 }
|
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 6000 }
|
||||||
|
|
||||||
context 'as admin' do
|
context 'as admin' do
|
||||||
let(:user) { admin_user }
|
let(:user) { admin }
|
||||||
|
|
||||||
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 8000.seconds, description: 'outside of delete timeframe'
|
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 8000.seconds, description: 'outside of delete timeframe'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 5000.seconds, description: 'outside of delete timeframe'
|
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 5000.seconds, description: 'outside of delete timeframe'
|
||||||
include_examples 'according to permission matrix', item: 'article_note', expects_visible: false, offset: 8000.seconds, description: 'outside of delete timeframe'
|
include_examples 'according to permission matrix', item: 'article_note', expects_visible: false, offset: 8000.seconds, description: 'outside of delete timeframe'
|
||||||
|
@ -367,7 +367,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 0 }
|
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 0 }
|
||||||
|
|
||||||
context 'as agent' do
|
context 'as agent' do
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
|
|
||||||
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 99.days, description: 'long after'
|
include_examples 'according to permission matrix', item: 'article_note', expects_visible: true, offset: 99.days, description: 'long after'
|
||||||
end
|
end
|
||||||
|
@ -377,7 +377,7 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
context 'button is hidden on the go' do
|
context 'button is hidden on the go' do
|
||||||
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 5 }
|
before { Setting.set 'ui_ticket_zoom_article_delete_timeframe', 5 }
|
||||||
|
|
||||||
let(:user) { agent_user }
|
let(:user) { agent }
|
||||||
let(:item) { 'article_note' }
|
let(:item) { 'article_note' }
|
||||||
let!(:article) { send(item) }
|
let!(:article) { send(item) }
|
||||||
let(:offset) { 0.seconds }
|
let(:offset) { 0.seconds }
|
||||||
|
@ -400,10 +400,10 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
let(:email_address) { create(:email_address, email: system_email_address) }
|
let(:email_address) { create(:email_address, email: system_email_address) }
|
||||||
let(:group) { create(:group, email_address: email_address) }
|
let(:group) { create(:group, email_address: email_address) }
|
||||||
let(:agent_groups) { [group] }
|
let(:agent_groups) { [group] }
|
||||||
let(:agent) { create(:agent_user, groups: agent_groups) }
|
let(:agent) { create(:agent, groups: agent_groups) }
|
||||||
|
|
||||||
let(:sender_email_address) { 'smime2@example.com' }
|
let(:sender_email_address) { 'smime2@example.com' }
|
||||||
let(:customer) { create(:customer_user, email: sender_email_address) }
|
let(:customer) { create(:customer, email: sender_email_address) }
|
||||||
|
|
||||||
let!(:ticket) { create(:ticket, group: group, owner: agent, customer: customer) }
|
let!(:ticket) { create(:ticket, group: group, owner: agent, customer: customer) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue