docbrown/spec/requests/api/v0/comments_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

22 lines
673 B
Ruby

require "rails_helper"
RSpec.describe "Api::V0::Comments", type: :request do
let(:article) { create(:article) }
before do
FactoryBot.create(:comment, commentable_type: "Article", commentable_id: article.id)
FactoryBot.create(:comment, commentable_type: "Article", commentable_id: article.id)
end
describe "GET /api/comments" do
it "returns not found if inproper article id" do
get "/api/comments?a_id=gobbledygook"
expect(response).to have_http_status(:not_found)
end
it "returns comments for article passed" do
get "/api/comments?a_id=#{article.id}"
expect(JSON.parse(response.body).size).to eq(2)
end
end
end