Skip to content

Commit 50ea582

Browse files
authored
Merge pull request #2 from basit3407/fix-list-chapter-reciters-api
Fix eager loading for chapter reciters
2 parents b7f3f57 + 47b13be commit 50ea582

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

app/presenters/audio/recitation_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class Audio::RecitationPresenter < BasePresenter
99

1010
def recitations
1111
relation = Audio::Recitation
12-
.includes(:recitation_style, :qirat_type, reciter: :translated_name)
13-
.eager_load(reciter: :translated_name)
12+
.includes(:translated_name, :recitation_style, :qirat_type, reciter: :translated_name)
13+
.eager_load(:translated_name, reciter: :translated_name)
1414
.order('priority ASC, language_priority DESC')
1515

1616
eager_load_translated_name filter_recitations(relation)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe 'Chapter reciters endpoint', type: :api do
4+
context 'when no recitations exist' do
5+
it 'returns an empty list' do
6+
get '/api/v4/resources/chapter_reciters', chapter_id: 1
7+
expect(last_response.status).to eq(200)
8+
expect(Oj.load(last_response.body)['reciters']).to eq([])
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)