docbrown/spec/models/feedback_message_spec.rb
rhymes 6553f08d94 Rubocop cleanups (#1415)
* Update rubocop-todo.yml with new violations

* Fix Layout/EmptyLine* rules

* Fix Layout/Indentation* rules

* Fix remaining Layout/* rules

* Fix Lint/DuplicateMethods by removing unused accessor

* Fix Lint/IneffectiveAccessModifier

* Fix Lint/MissingCopEnableDirective

* Re-run rubocop auto gen config

* Fix Layout/RescueEnsureAlignment

* Fix Naming/* rules

* Fix some RSpec/* rules

* Fix typos

* Fix RSpec/LetBeforeExamples

* Series should only be an attr_writer, not an attr_accessor

* Fix RSpec/InstanceVariable

* Fix RSpec/InstanceVariable

* Fix RSpec/RepeatedDescription and RSpec/RepeatedExample

* Fix Style/ClassAndModuleChildren

* Fix Style/ConditionalAssignment

* Fix some Style/* rules

* Trigger Travis CI build because failing tests are not failing locally

* Revert "Fix Style/ClassAndModuleChildren"

This reverts commit 1686801d8a1516ba1894f79e24401a20dea65f99.
2019-01-02 11:20:02 -05:00

45 lines
1.3 KiB
Ruby

require "rails_helper"
RSpec.describe FeedbackMessage, type: :model do
let(:user) { create(:user) }
let(:abuse_report) { create(:feedback_message, :abuse_report) }
describe "validations for an abuse report" do
subject(:feedback_message) do
FeedbackMessage.new(
feedback_type: "abuse-reports",
reported_url: "https://dev.to",
category: "spam",
message: "something",
)
end
it { is_expected.to validate_presence_of(:feedback_type) }
it { is_expected.to validate_presence_of(:reported_url) }
it { is_expected.to validate_presence_of(:message) }
it do
expect(feedback_message).to validate_inclusion_of(:category).
in_array(["spam", "other", "rude or vulgar", "harassment", "bug"])
end
end
describe "validations for a bug report" do
subject(:feedback_message) do
FeedbackMessage.new(
feedback_type: "bug-reports",
category: "bug",
message: "something",
)
end
it { is_expected.to validate_presence_of(:feedback_type) }
it { is_expected.to validate_presence_of(:message) }
it { is_expected.not_to validate_presence_of(:reported_url) }
it do
expect(feedback_message).to validate_inclusion_of(:category).
in_array(["spam", "other", "rude or vulgar", "harassment", "bug"])
end
end
end