Skip to content

Commit

Permalink
fixed specs and added check for audio availability (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
naveed-ahmad authored and mmahalwy committed Dec 30, 2016
1 parent bfa4218 commit a765ff1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/models/quran/ayah.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def self.as_json_with_resources(ayahs, options = {})
ayah_json.merge({
content: content_option && content[ayah.ayah_key] ?
content[ayah.ayah_key] : [],
audio: audio_option ? audio[ayah.ayah_key].first : {},
audio: audio_option && audio[ayah.ayah_key] ? audio[ayah.ayah_key].first : {},
})
end
end
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

resources :surahs, only: [:index, :show], defaults: { format: 'json' } do
resources :ayahs, only: [:index], defaults: { format: 'json' }

member do
get :info
end
end

resources :options, only: [], defaults: { format: 'json' } do
Expand Down
2 changes: 1 addition & 1 deletion db
Submodule db updated from 8dbe99 to 5dbfe0
2 changes: 1 addition & 1 deletion spec/controllers/v2/ayahs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
context "getting surah #{id}" do
before { get :index, { surah_id: id, from: 1, to: 30, content: [19], audio: 8 } }

it 'returns http success and returns corret number of ayahs' do
it 'returns http success and returns correct number of ayahs' do
expect(response).to have_http_status(:success)

if surah.ayat > 30
Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/v2/surahs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@
end
end

describe 'GET #info' do
before { get :info, { id: 1 } }

it 'returns http success' do
expect(response).to have_http_status(:success)
end

it 'returns information of first surah' do
expect(response_json['surah_id']).to eql(1)
end
end

end
19 changes: 0 additions & 19 deletions spec/models/content/ayah_detail_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

require 'rails_helper'

RSpec.describe Content::SuraDetail, type: :model do
RSpec.describe Content::SurahInfo, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit a765ff1

Please sign in to comment.