Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 10, 2024
2 parents bd72868 + f018c4b commit f07cf8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def thread
resource = client.get_messages_for_thread(message_id)
raise Common::Exceptions::RecordNotFound, message_id if resource.blank?

resource.data = resource.data.filter { |m| m.message_id.to_s != params[:id] } if params[:excludeProvidedMessage]
if ActiveModel::Type::Boolean.new.cast(params[:excludeProvidedMessage])
resource.data = resource.data.filter { |m| m.message_id.to_s != params[:id] }
end
resource.metadata.merge!(message_counts(resource))

render json: resource.data,
Expand Down
14 changes: 13 additions & 1 deletion modules/mobile/spec/request/v1/messages_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
expect(response.parsed_body['data'].any? { |m| m['id'] == thread_id.to_s }).to be true
end

it 'filters the provided message' do
it 'filters the provided message when excludeProvidedMessage is true' do
VCR.use_cassette('mobile/messages/v1_get_thread') do
get "/mobile/v1/messaging/health/messages/#{thread_id}/thread",
headers: sis_headers,
Expand All @@ -165,6 +165,18 @@
expect(response.parsed_body['data'].any? { |m| m['id'] == thread_id.to_s }).to be false
end

it 'does not filter the provided message when excludeProvidedMessage is false' do
VCR.use_cassette('mobile/messages/v1_get_thread') do
get "/mobile/v1/messaging/health/messages/#{thread_id}/thread",
headers: sis_headers,
params: { excludeProvidedMessage: false }
end

expect(response).to be_successful
expect(response.parsed_body).to eq(thread_response)
expect(response.parsed_body['data'].any? { |m| m['id'] == thread_id.to_s }).to be true
end

it 'provides a count in the meta of read' do
VCR.use_cassette('mobile/messages/v1_get_thread') do
get "/mobile/v1/messaging/health/messages/#{thread_id}/thread",
Expand Down

0 comments on commit f07cf8e

Please sign in to comment.