|
@@ -352,15 +352,18 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
|
|
end
|
|
|
|
|
|
it 'does find the user of the nested organization and also even if the organization name changes' do
|
|
|
- params = {
|
|
|
- query: 'Tomato42',
|
|
|
- limit: 10,
|
|
|
- }
|
|
|
|
|
|
# because of the initial relation between user and organization
|
|
|
# both user and organization will be found as result
|
|
|
authenticated_as(agent_user)
|
|
|
- post '/api/v1/search/User', params: params, as: :json
|
|
|
+ post '/api/v1/search/User', params: { query: 'Tomato42' }, as: :json
|
|
|
+ expect(response).to have_http_status(:ok)
|
|
|
+ expect(json_response).to be_a_kind_of(Hash)
|
|
|
+ expect(json_response).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
|
|
|
+
|
|
|
+ post '/api/v1/search/User', params: { query: 'organization:Tomato42' }, as: :json
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
expect(json_response).to be_truthy
|
|
@@ -371,14 +374,16 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
|
|
Scheduler.worker(true)
|
|
|
SearchIndexBackend.refresh
|
|
|
|
|
|
- params = {
|
|
|
- query: 'Cucumber43',
|
|
|
- limit: 10,
|
|
|
- }
|
|
|
-
|
|
|
# even after a change of the organization name we should find
|
|
|
# the customer user because of the nested organization data
|
|
|
- post '/api/v1/search/User', params: params, as: :json
|
|
|
+ post '/api/v1/search/User', params: { query: 'Cucumber43' }, as: :json
|
|
|
+ expect(response).to have_http_status(:ok)
|
|
|
+ expect(json_response).to be_a_kind_of(Hash)
|
|
|
+ expect(json_response).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
|
|
|
+
|
|
|
+ post '/api/v1/search/User', params: { query: 'organization:Cucumber43' }, as: :json
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
expect(json_response).to be_truthy
|
|
@@ -387,13 +392,15 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
|
|
end
|
|
|
|
|
|
it 'does find the ticket by organization name even if the organization name changes' do
|
|
|
- params = {
|
|
|
- query: 'Tomato42',
|
|
|
- limit: 10,
|
|
|
- }
|
|
|
-
|
|
|
authenticated_as(agent_user)
|
|
|
- post '/api/v1/search/Ticket', params: params, as: :json
|
|
|
+ post '/api/v1/search/Ticket', params: { query: 'Tomato42' }, as: :json
|
|
|
+ expect(response).to have_http_status(:ok)
|
|
|
+ expect(json_response).to be_a_kind_of(Hash)
|
|
|
+ expect(json_response).to be_truthy
|
|
|
+ expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
|
|
+ expect(json_response['assets']['Ticket'][ticket_nested.id.to_s]).to be_truthy
|
|
|
+
|
|
|
+ post '/api/v1/search/Ticket', params: { query: 'organization:Tomato42' }, as: :json
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
expect(json_response).to be_truthy
|
|
@@ -404,12 +411,14 @@ RSpec.describe 'Search', type: :request, searchindex: true do
|
|
|
Scheduler.worker(true)
|
|
|
SearchIndexBackend.refresh
|
|
|
|
|
|
- params = {
|
|
|
- query: 'Cucumber43',
|
|
|
- limit: 10,
|
|
|
- }
|
|
|
+ post '/api/v1/search/Ticket', params: { query: 'Cucumber43' }, as: :json
|
|
|
+ expect(response).to have_http_status(:ok)
|
|
|
+ expect(json_response).to be_a_kind_of(Hash)
|
|
|
+ expect(json_response).to be_truthy
|
|
|
+ expect(json_response['assets']['Organization'][organization_nested.id.to_s]).to be_truthy
|
|
|
+ expect(json_response['assets']['Ticket'][ticket_nested.id.to_s]).to be_truthy
|
|
|
|
|
|
- post '/api/v1/search/Ticket', params: params, as: :json
|
|
|
+ post '/api/v1/search/Ticket', params: { query: 'organization:Cucumber43' }, as: :json
|
|
|
expect(response).to have_http_status(:ok)
|
|
|
expect(json_response).to be_a_kind_of(Hash)
|
|
|
expect(json_response).to be_truthy
|