docbrown/spec/requests/podcast_episodes_api_spec.rb
rhymes 941ab4178b Articles API: create and update (#2844)
* Add system test to create article from the editor

* Move article creation from API to app controller

* Fix system test to edit posts

* Move article update from API to app controller

* Rewrite create article API using API key

* Add main_image and canonical_url to allowed creation params

* Rewrite update article API using API key

* Fix tests and have Comments API inherit from API
2019-05-16 12:26:24 -04:00

36 lines
1 KiB
Ruby

require "rails_helper"
vcr_option = {
cassette_name: "se_daily_rss_feed",
allow_playback_repeats: "true"
}
RSpec.describe "ArticlesApi", type: :request, vcr: vcr_option do
let(:podcast) { create(:podcast, feed_url: "http://softwareengineeringdaily.com/feed/podcast/") }
before do
PodcastFeed.new.get_episodes(podcast, 2)
end
describe "GET /api/articles" do
it "returns json response" do
get "/api/podcast_episodes"
expect(response.content_type).to eq("application/json")
end
it "returns podcast episodes" do
get "/api/podcast_episodes"
expect(JSON.parse(response.body).size).to eq(2)
end
it "returns podcast episodes of specific podcast if passed username" do
get "/api/podcast_episodes?username=#{podcast.slug}"
expect(JSON.parse(response.body).size).to eq(2)
end
it "returns nothing is passed invalid podcast slug" do
get "/api/podcast_episodes?username=nothing_#{rand(1_000_000_000_000_000)}"
expect(response).to have_http_status(:not_found)
end
end
end