docbrown/spec/requests/internal_feedback_messages_update_spec.rb
Andy Zhao ecbb9d4ab1 [Done] New Reporting System MVP (#408)
* Move validations from controller to model

* Add new columns to feedback message model

* Use polymorphic notes relationship

* MVP of ticketing system

* Use new URL for reported_url param

* Add missing files

* Add validations and tests for feedback_messages

* Clean up some html

* Update create spec and add update spec

* Add mail tests and lint

* Add link to user profile
2018-06-19 16:41:31 -04:00

42 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe "/internal/feedback_messages", type: :request do
describe "PUTS /internal/feedback_messages" do
context "with a valid request" do
let(:feedback_message) { create(:feedback_message, :abuse_report) }
let(:admin) { create(:user, :super_admin) }
valid_abuse_report_params = {
feedback_message: {
id: 1,
status: "Resolved",
note: {
content: "this is valid",
reason: "abuse-reports",
},
},
}
before do
login_as(admin)
valid_abuse_report_params[:feedback_message][:reviewer_id] = admin.id
patch "/internal/feedback_messages/#{feedback_message.id}", params:
valid_abuse_report_params
end
it "adds a note to a report" do
expect(FeedbackMessage.last.note.content).to eq(
valid_abuse_report_params[:feedback_message][:note][:content],
)
end
it "adds the current user as the reviewer" do
expect(FeedbackMessage.find_by(reviewer_id: admin.id)).not_to eq(nil)
end
it "updates the last_reviewed_at timestamp" do
expect(FeedbackMessage.last.last_reviewed_at).not_to eq(nil)
end
end
end
end