* Use idempotent update instead of toggle * Update editor guide with new comment instructions * Render the settings button on page load * Add settings button to comment dropdown * Update styles to properly render * Add comment mute function and settings page * Clean up erb spacing * Remove unneccessary user_id param * Add receive_notifications for policy spec * Update name for accuracy * Add request spec for comments_mute * Remove unused permitted attributes * Add actually used permitted attributes
22 lines
713 B
Ruby
22 lines
713 B
Ruby
# http://localhost:3000/api/comments?a_id=23
|
|
require "rails_helper"
|
|
|
|
RSpec.describe "CommentsApi", 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
|
|
expect { get "/api/comments?a_id=gobbledygook" }.to raise_error(ActiveRecord::RecordNotFound)
|
|
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
|