* Rubocop enabled style/alias * Enabled Style/ArrayJoin Cop * Enabled Style/Attr * Enabled Case Equality * Enabled CharacterLiteral * Enabled ColonMethodCall Cop * Enabled CommentAnnotation cop * Enabled PreferredHashMethods Cop * Enabled DoubleNegation Cop * Enabled EachWithObject Cop * Enabled EmptyLiteral Cop * Enabled EvenOdd Cop * Enabled IfWithSemicolon Cop * Enabled Lambda and LambdaCall Cop * Enabled LineEndConcatenation Cop * Enabled ModuleFunction Cop; * Enable NegatedIf and NegatedWhile Cop * Enabled NilComparison Cop * Enabled Not Cop * Enabled NumericLiterals Cop * Enabled OneLineConditional Cop * Enabled PercentLiteralDelimiters Cop * Excluded internal/users_controller from negated_if cop * Reverted the double negation change from github_issue_tag and github_issue.rb" * Enabled PerlBackrefs Cop * Changed Regexp.last_match(1) to Regexp.last_match(0) * Enabled proc cop * Enabled RaiseArgs Cop * Reverted Regexp.last_match(0) to Regexp.last_match(1) * Enabled SelfAssignment Cop * Enabled SingleLineMethods Cop * Enabled SpecialGlobalVars Cop * Enabled VariableInterpolation Cop * Enabled WhenThen Cop * Enabled WhileUntilModifier Cop * Enabled WordArray Cop * Enabled IfUnlessModifier Cop * Enabled GuardClause Cop
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "/internal/reactions", type: :request do
|
|
let(:user) { create(:user) }
|
|
let(:article) { create(:article, user_id: user.id) }
|
|
let(:admin) { create(:user, :super_admin) }
|
|
|
|
describe "PUT /internal/reactions as admin" do
|
|
before do
|
|
user.add_role(:trusted)
|
|
login_as admin
|
|
end
|
|
|
|
let(:reaction) { create(:reaction, category: "vomit", user_id: user.id, reactable_id: article.id) }
|
|
|
|
it "updates reaction to be confirmed" do
|
|
put "/internal/reactions/#{reaction.id}", params: {
|
|
reaction: { status: "confirmed" }
|
|
}
|
|
expect(reaction.reload.status).to eq("confirmed")
|
|
end
|
|
|
|
it "does not set invalid status" do
|
|
put "/internal/reactions/#{reaction.id}", params: {
|
|
reaction: { status: "confirmedsssss" }
|
|
}
|
|
expect(reaction.reload.status).not_to eq("confirmedsssss")
|
|
end
|
|
end
|
|
|
|
describe "PUT /internal/reactions as non-admin" do
|
|
before do
|
|
user.add_role(:trusted)
|
|
login_as user
|
|
end
|
|
|
|
let(:reaction) { create(:reaction, category: "vomit", user_id: user.id, reactable_id: article.id) }
|
|
|
|
it "updates reaction to be confirmed" do
|
|
invalid_request = lambda do
|
|
put "/internal/reactions/#{reaction.id}", params: {
|
|
reaction: { status: "confirmed" }
|
|
}
|
|
end
|
|
|
|
expect(invalid_request).to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
end
|