* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
29 lines
846 B
Ruby
29 lines
846 B
Ruby
# http://localhost:3000/api/comments?a_id=23
|
|
require "rails_helper"
|
|
|
|
RSpec.describe "ArticlesApi", type: :request do
|
|
let(:user) { create(:user) }
|
|
let(:article) { create(:article) }
|
|
|
|
before do
|
|
user.update(secret: "TEST_SECRET")
|
|
user.add_role(:super_admin)
|
|
end
|
|
|
|
describe "POST /api/reactions" do
|
|
it "creates a new reactions" do
|
|
post "/api/reactions", params: {
|
|
reactable_id: article.id, reactable_type: "Article", category: "like", key: user.secret
|
|
}
|
|
expect(Reaction.last.reactable_id).to eq(article.id)
|
|
end
|
|
|
|
it "rejects non-authorized users" do
|
|
user.remove_role(:super_admin)
|
|
post "/api/reactions", params: {
|
|
reactable_id: article.id, reactable_type: "Article", category: "like", key: user.secret
|
|
}
|
|
expect(response).to have_http_status(422)
|
|
end
|
|
end
|
|
end
|