* 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
22 lines
673 B
Ruby
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
|