* Test with Grid layout * Use Flexbox * Replace with utility classes * Wire up Tools -> Emails * Stash: will rebase with a better commit message * Fix transition between Email and Tools component * Refactor Verify Email Ownership button a bit * Use respond_to for verify_email_ownership * Wrap the Preact Snackbar controller in Stimulus and use it from users/tools/email_controller * Add HTML5 validation to EmailComponent * Validation and cleanup * Add Email history list and fix styling * Additional styling cleanups * Add error handling * Close panel after email operations * Actually use <local-time> GitHub time element correctly * Add specs for Tools component and controller * Email to Emails * Add tests for Admin::Users::Tools::EmailsComponent * Fix bug with ToolsComponent instantiation in ToolsController * Add notes to show page * Add ToolsComponent css * Use Rails UJS instead of manual Stimulus to connect remote helpers * Make Notes section come alive by adding its code * Make Credits section come alive by adding its code * Go back to vertical flex * Finalize small restructuring of credits code * Simplify ToolsComponent instantiation * Add basic Add user to org functionality * Make update user permissions form work * Make remove user from org work * Use generic Stimulus AjaxController to cleanup code * Use Stimulus AjaxController for NotesComponent * Use Stimulus AjaxController for CreditsComponent * Use Stimulus AjaxController for OrganizationsController * Add Admin::Users::Tools::ReportsComponent * Do not display snackbar message if there is no message * Add Admin::Users::Tools::ReactionsComponent * Fix EmailsComponent spec * Add CreditsComponent tests * Fix quotes * Add OrganizationsComponent specs * Add ReportsComponent spec * Add ReactionsComponent spec * Fix rubocop violation * Fix ToolsComponent specs * Remove unused variable * More tests * Use keyword argument for ToolsComponent * Fill in Tools requests specs * Use Rspec shared_examples for ToolsController and EmailsController * Add tests for Admin::Users::Tools::CreditsController * Add tests for Admin::Users::Tools::NotesController * Add tests for Admin::Users::Tools::OrganizationsController * Add tests for Admin::Users::Tools::ReactionsController and ReportsController * Fix bugs and add tests to Admin::OrganizationMembershipsController * Add comments to deprecated sections of the UsersController * Fix bugs and add tests to Admin::UsersController #send_email and #verify_email_ownership * Add User model tests * Feature flag fixes * Add Cypress Tools - Emails tests * Add Cypress Tools - Notes tests * Add Cypress Tools - Credits tests * Add Cypress Tools - Organizations tests * Add Cypress Tools - Reports and Reactions tests * Mark the replace target as a polite region * Update view_component gem * Tiny fixes * Fix spec * Wrap component rendering in render_component * Move user.related_negative_reactions to a Reaction scope * Move user.reports to a FeedbackMessage scope * Move user.last_verification_date as EmailAuthorization class method * Revert encapsulation to private * Fix boxes backlinks names * Add keyboard focus styling to boxes * Remove duplicate styling * Remove duplicated header element * Improve heading hiearchy * Fix <legend> and labels * Backlink should be Tools not Users * Announce section change to screen reader and fix focus * Fix specs * Add focus style for backlinks * Enable email sending in e2e mode * Use Settings instead of env variable
84 lines
3 KiB
Ruby
84 lines
3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe FeedbackMessage, type: :model do
|
|
let(:reporter) { create(:user) }
|
|
let(:abuse_report) { create(:feedback_message, :abuse_report, reporter: reporter) }
|
|
|
|
describe "validations" do
|
|
describe "builtin validations" do
|
|
subject(:feedback_message) { create(:feedback_message) }
|
|
|
|
it { is_expected.to belong_to(:offender).class_name("User").inverse_of(:offender_feedback_messages).optional }
|
|
it { is_expected.to belong_to(:reporter).class_name("User").inverse_of(:reporter_feedback_messages).optional }
|
|
it { is_expected.to belong_to(:affected).class_name("User").inverse_of(:affected_feedback_messages).optional }
|
|
|
|
it { is_expected.to have_one(:email_message).dependent(:nullify).optional }
|
|
it { is_expected.to have_many(:notes).inverse_of(:noteable).dependent(:destroy) }
|
|
|
|
it { is_expected.to validate_presence_of(:feedback_type) }
|
|
it { is_expected.to validate_presence_of(:message) }
|
|
it { is_expected.to validate_length_of(:reported_url).is_at_most(250) }
|
|
it { is_expected.to validate_length_of(:message).is_at_most(2500) }
|
|
|
|
it do
|
|
expect(feedback_message).to validate_inclusion_of(:category)
|
|
.in_array(described_class::CATEGORIES)
|
|
end
|
|
|
|
it do
|
|
expect(feedback_message).to validate_inclusion_of(:status)
|
|
.in_array(described_class::STATUSES)
|
|
end
|
|
end
|
|
|
|
describe "validations for an abuse report" do
|
|
subject(:feedback_message) { abuse_report }
|
|
|
|
it { is_expected.to validate_presence_of(:reported_url) }
|
|
|
|
it do
|
|
expect(feedback_message).to validate_uniqueness_of(:reporter_id)
|
|
.scoped_to(described_class::REPORTER_UNIQUENESS_SCOPE)
|
|
.with_message(described_class::REPORTER_UNIQUENESS_MSG)
|
|
end
|
|
|
|
it { is_expected.to validate_length_of(:reported_url).is_at_most(250) }
|
|
it { is_expected.to validate_presence_of(:category) }
|
|
|
|
it "does not check for uniqueness if the new abuse report does not have a reporter id" do
|
|
new_abuse_report = build(:feedback_message, :abuse_report)
|
|
new_abuse_report.reported_url = abuse_report.reported_url
|
|
|
|
expect(new_abuse_report).to be_valid
|
|
end
|
|
end
|
|
|
|
describe "validations for a bug report" do
|
|
subject(:feedback_message) { create(:feedback_message, :bug_report, reporter: reporter) }
|
|
|
|
it { is_expected.not_to validate_presence_of(:reported_url) }
|
|
end
|
|
end
|
|
|
|
describe ".all_user_reports" do
|
|
let(:user) { create(:user) }
|
|
|
|
it "returns reported feedback messages" do
|
|
report = create(:feedback_message, reporter: user)
|
|
|
|
expect(described_class.all_user_reports(user).first.id).to eq(report.id)
|
|
end
|
|
|
|
it "returns affected feedback messages" do
|
|
report = create(:feedback_message, affected: user)
|
|
|
|
expect(described_class.all_user_reports(user).first.id).to eq(report.id)
|
|
end
|
|
|
|
it "returns offender feedback messages" do
|
|
report = create(:feedback_message, offender: user)
|
|
|
|
expect(described_class.all_user_reports(user).first.id).to eq(report.id)
|
|
end
|
|
end
|
|
end
|