docbrown/spec/requests/reactions_api_spec.rb
Andy Zhao 2db2dd1e5a WIP Refactor/notifications (#1131)
* Add new columns to notifications table

* Remove stream from notifications and add new methods

* Turn off moderation comment notifications

* Add notifiable_type index to migration

* Stop creation of Stream-based notification model instances

* Add notification model create hooks

* Add badge achievement notification creation hook

* Fix some specs

* Add missing @ symbol

* Fix for tests and rename a few things

* forgot to uncomment code sigh
2018-11-19 16:09:02 -05:00

29 lines
845 B
Ruby

# http://localhost:3000/api/comments?a_id=23
require "rails_helper"
RSpec.describe "ArticlesApi", type: :request do
let(:user) { create(:user, :super_admin) }
let(:article) { create(:article) }
before do
user.update(secret: "TEST_SECRET")
sign_in user
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