Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed specs and added check for audio availability #81

Merged
merged 1 commit into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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