Routine rubocop fix on /spec (#19217)
* Softrun rubocop * Hardrun rubocop (-A) * Change a rubocop rule * Add missing cops * Undo & redo rubocop -A
This commit is contained in:
parent
ce6f30b9de
commit
842e6880b8
202 changed files with 300 additions and 302 deletions
10
.rubocop.yml
10
.rubocop.yml
|
|
@ -6,6 +6,7 @@ require:
|
|||
- rubocop-performance
|
||||
- rubocop-rails
|
||||
- rubocop-rspec
|
||||
- rubocop-capybara
|
||||
|
||||
AllCops:
|
||||
Exclude:
|
||||
|
|
@ -925,10 +926,11 @@ RSpec/DescribeClass:
|
|||
Enabled: true
|
||||
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
|
||||
Exclude:
|
||||
- 'spec/requests/**/*'
|
||||
- 'spec/system/**/*'
|
||||
- 'spec/tasks/**/*'
|
||||
- 'spec/views/**/*'
|
||||
- '**/spec/features/**/*'
|
||||
- '**/spec/requests/**/*'
|
||||
- '**/spec/routing/**/*'
|
||||
- '**/spec/system/**/*'
|
||||
- '**/spec/views/**/*'
|
||||
|
||||
RSpec/DescribedClassModuleWrapping:
|
||||
Description: Avoid opening modules and defining specs within them.
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ FactoryBot.define do
|
|||
factory :github_repo do
|
||||
user
|
||||
name { Faker::Book.title }
|
||||
url { generate :url }
|
||||
url { generate(:url) }
|
||||
description { Faker::Book.title }
|
||||
language { Faker::Book.title }
|
||||
bytes_size { rand(100_000) }
|
||||
watchers_count { rand(100_000) }
|
||||
github_id_code { generate :github_id_code }
|
||||
github_id_code { generate(:github_id_code) }
|
||||
stargazers_count { rand(100_000) }
|
||||
featured { true }
|
||||
fork { false }
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ FactoryBot.define do
|
|||
factory :organization do
|
||||
name { Faker::Company.name }
|
||||
summary { Faker::Hipster.paragraph(sentence_count: 1)[0..150] }
|
||||
profile_image { File.open(Rails.root.join("app/assets/images/android-icon-36x36.png")) }
|
||||
profile_image { Rails.root.join("app/assets/images/android-icon-36x36.png").open }
|
||||
nav_image { Faker::Avatar.image }
|
||||
url { Faker::Internet.url }
|
||||
slug { generate :slug }
|
||||
slug { generate(:slug) }
|
||||
github_username { "org#{rand(10_000)}" }
|
||||
twitter_username { "org#{rand(10_000)}" }
|
||||
bg_color_hex { Faker::Color.hex_color }
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ FactoryBot.define do
|
|||
title { Faker::Beer.name }
|
||||
image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") }
|
||||
description { Faker::Hipster.paragraph(sentence_count: 1) }
|
||||
slug { generate :podcast_slug }
|
||||
slug { generate(:podcast_slug) }
|
||||
feed_url { Faker::Internet.url }
|
||||
main_color_hex { "ffffff" }
|
||||
published { true }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ FactoryBot.define do
|
|||
user
|
||||
type_of { "personal_comment" }
|
||||
content_type { "body_markdown" }
|
||||
title { generate :title }
|
||||
title { generate(:title) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
|||
sequence(:name) { |n| "tag#{n}" }
|
||||
|
||||
factory :tag do
|
||||
name { generate :name }
|
||||
name { generate(:name) }
|
||||
supported { true }
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ FactoryBot.define do
|
|||
name do
|
||||
"#{Faker::Name.first_name} \"#{Faker::Name.first_name}\" \\:/ #{Faker::Name.last_name}"
|
||||
end
|
||||
email { generate :email }
|
||||
username { generate :username }
|
||||
email { generate(:email) }
|
||||
username { generate(:username) }
|
||||
profile_image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") }
|
||||
twitter_username { generate :twitter_username }
|
||||
github_username { generate :github_username }
|
||||
twitter_username { generate(:twitter_username) }
|
||||
github_username { generate(:github_username) }
|
||||
confirmed_at { Time.current }
|
||||
saw_onboarding { true }
|
||||
checked_code_of_conduct { true }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Services", type: :generator do
|
||||
RSpec.describe "Services" do
|
||||
pending "add some scenarios (or delete) #{__FILE__}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ApplicationHelper, type: :helper do
|
||||
RSpec.describe ApplicationHelper do
|
||||
include CloudinaryHelper
|
||||
|
||||
describe "constant definitions" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe AuthenticationHelper, type: :helper do
|
||||
RSpec.describe AuthenticationHelper do
|
||||
let(:user) { create(:user, :with_identity) }
|
||||
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe CrayonsHelper, type: :helper do
|
||||
RSpec.describe CrayonsHelper do
|
||||
describe "#crayons_icon_tag" do
|
||||
let(:icon_tag) { helper.crayons_icon_tag("twitter.svg") }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe DisplayAdHelper, type: :helper do
|
||||
describe DisplayAdHelper do
|
||||
describe ".display_ads_placement_area_options_array" do
|
||||
it "returns proper human value" do
|
||||
expect(helper.display_ads_placement_area_options_array[1]).to eq ["Sidebar Left (Second Position)",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe FeedbackMessagesHelper, type: :helper do
|
||||
RSpec.describe FeedbackMessagesHelper do
|
||||
describe "#offender_email_details" do
|
||||
it "has the proper subject and body" do
|
||||
expect(helper.offender_email_details).to include(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ListingHelper, type: :helper do
|
||||
RSpec.describe ListingHelper do
|
||||
let!(:cat1) { create(:listing_category, cost: 1) }
|
||||
let!(:cat2) { create(:listing_category, :cfp, cost: 5) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe OrganizationHelper, type: :helper do
|
||||
describe OrganizationHelper do
|
||||
it "displays the correct options" do
|
||||
org1 = create(:organization, name: "ACME")
|
||||
org2 = create(:organization, name: "Pied Piper")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
describe RateLimitCheckerHelper, type: :helper do
|
||||
describe RateLimitCheckerHelper do
|
||||
describe "#configurable_rate_limits" do
|
||||
it "returns a hash with the right structure" do
|
||||
settings_keys = Settings::RateLimit.keys.map(&:to_sym)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ require Rails.root.join(
|
|||
|
||||
describe DataUpdateScripts::RenameModeratorToSuperModerator do
|
||||
before do
|
||||
create :user
|
||||
create :user, :tag_moderator
|
||||
create :user, :super_admin
|
||||
create(:user)
|
||||
create(:user, :tag_moderator)
|
||||
create(:user, :super_admin)
|
||||
end
|
||||
|
||||
context "when there are no moderators" do
|
||||
|
|
@ -36,7 +36,7 @@ describe DataUpdateScripts::RenameModeratorToSuperModerator do
|
|||
end
|
||||
|
||||
context "when rename has already run" do
|
||||
let!(:super_moderator) { create :user, :super_moderator }
|
||||
let!(:super_moderator) { create(:user, :super_moderator) }
|
||||
|
||||
it "does nothing" do
|
||||
expect(described_class.new.run).to eq(0)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ApplicationMailer, type: :mailer do
|
||||
RSpec.describe ApplicationMailer do
|
||||
let(:user) { create(:user) }
|
||||
let(:email) { VerificationMailer.with(user_id: user.id).account_ownership_verification_email }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe DeviseMailer, type: :mailer do
|
||||
RSpec.describe DeviseMailer do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe "#reset_password_instructions" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe DigestMailer, type: :mailer do
|
||||
RSpec.describe DigestMailer do
|
||||
let(:user) { create(:user) }
|
||||
let(:article) { build_stubbed(:article) }
|
||||
let(:from_email_address) { "custom_noreply@forem.com" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe NotifyMailer, type: :mailer do
|
||||
RSpec.describe NotifyMailer do
|
||||
let(:user) { create(:user) }
|
||||
let(:user2) { create(:user) }
|
||||
let(:article) { create(:article, user_id: user.id) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe VerificationMailer, type: :mailer do
|
||||
RSpec.describe VerificationMailer do
|
||||
let(:user) { create(:user) }
|
||||
let(:from_email_address) { "custom_noreply@forem.com" }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Ahoy::Visit, type: :model do
|
||||
RSpec.describe Ahoy::Visit do
|
||||
let(:visit) { create(:ahoy_visit) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ApiSecret, type: :model do
|
||||
RSpec.describe ApiSecret do
|
||||
describe "validations" do
|
||||
subject { create(:api_secret) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require "rails_helper"
|
||||
|
||||
# ApplicationRecord is an abstract class, tests will use one of the core models
|
||||
RSpec.describe ApplicationRecord, type: :model do
|
||||
RSpec.describe ApplicationRecord do
|
||||
describe ".estimated_count" do
|
||||
it "does not raise errors if there are no rows" do
|
||||
expect { User.estimated_count }.not_to raise_error
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Article, type: :model do
|
||||
RSpec.describe Article do
|
||||
context "when no organization" do
|
||||
# Setting published explicitly to true to pass guard clause in the async_score_calc method on
|
||||
# the Article model that returns early if the article is unpublished
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Articles::CachedEntity, type: :model do
|
||||
RSpec.describe Articles::CachedEntity do
|
||||
subject(:struct) { described_class.from_object(object) }
|
||||
|
||||
let(:object) { build(:user) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe AuditLog, type: :model do
|
||||
RSpec.describe AuditLog do
|
||||
let(:audit_log) { create(:audit_log) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe BadgeAchievement, type: :model do
|
||||
RSpec.describe BadgeAchievement do
|
||||
let(:badge_with_credits) { create(:badge, credits_awarded: 10) }
|
||||
let(:badge) { create(:badge, credits_awarded: 0) }
|
||||
let(:achievement) { create(:badge_achievement, badge: badge) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Badge, type: :model do
|
||||
RSpec.describe Badge do
|
||||
let(:badge) { create(:badge) }
|
||||
let(:cache_bust) { instance_double(EdgeCache::Bust) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe BanishedUser, type: :model do
|
||||
RSpec.describe BanishedUser do
|
||||
describe "validations" do
|
||||
describe "builtin validations" do
|
||||
it { is_expected.to belong_to(:banished_by).class_name("User").optional }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Broadcast, type: :model do
|
||||
RSpec.describe Broadcast do
|
||||
it { is_expected.to validate_presence_of(:title) }
|
||||
it { is_expected.to validate_presence_of(:type_of) }
|
||||
it { is_expected.to validate_presence_of(:processed_html) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Collection, type: :model do
|
||||
RSpec.describe Collection do
|
||||
let(:user) { create(:user) }
|
||||
let(:collection) { create(:collection, :with_articles, user: user) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ConsumerApp, type: :model do
|
||||
RSpec.describe ConsumerApp do
|
||||
let(:consumer_app_android) { create(:consumer_app, platform: :android) }
|
||||
let(:consumer_app_ios) { create(:consumer_app, platform: :ios) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ContextNotification, type: :model do
|
||||
RSpec.describe ContextNotification do
|
||||
let(:context_notification) { create(:context_notification) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Credit, type: :model do
|
||||
RSpec.describe Credit do
|
||||
let(:user) { create(:user) }
|
||||
let(:organization) { create(:organization) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Device, type: :model do
|
||||
RSpec.describe Device do
|
||||
let(:device) { create(:device) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe DiscussionLock, type: :model do
|
||||
RSpec.describe DiscussionLock do
|
||||
let(:discussion_lock) { create(:discussion_lock) }
|
||||
|
||||
describe "relationships" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe DisplayAdEvent, type: :model do
|
||||
RSpec.describe DisplayAdEvent do
|
||||
it { is_expected.to validate_inclusion_of(:category).in_array(described_class::VALID_CATEGORIES) }
|
||||
|
||||
it { is_expected.to validate_inclusion_of(:context_type).in_array(described_class::VALID_CONTEXT_TYPES) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe EmailAuthorization, type: :model do
|
||||
RSpec.describe EmailAuthorization do
|
||||
let(:email_authorization) { create(:email_authorization) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe EmailMessage, type: :model do
|
||||
RSpec.describe EmailMessage do
|
||||
describe "validations" do
|
||||
subject { create(:email_message) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe FeedbackMessage, type: :model do
|
||||
RSpec.describe FeedbackMessage do
|
||||
let(:reporter) { create(:user) }
|
||||
let(:abuse_report) { create(:feedback_message, :abuse_report, reporter: reporter) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Follow, type: :model do
|
||||
RSpec.describe Follow do
|
||||
let(:user) { create(:user) }
|
||||
let(:tag) { create(:tag) }
|
||||
let(:user_2) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ForemInstance, type: :model do
|
||||
RSpec.describe ForemInstance do
|
||||
describe "deployed_at" do
|
||||
before do
|
||||
allow(ENV).to receive(:[])
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe GithubIssue, type: :model, vcr: true do
|
||||
RSpec.describe GithubIssue, vcr: true do
|
||||
let(:url_issue) { "https://api.github.com/repos/forem/forem/issues/7434" }
|
||||
let(:url_pull_request) { "https://api.github.com/repos/forem/forem/pulls/7653" }
|
||||
let(:url_comment) { "https://api.github.com/repos/forem/forem/issues/comments/621043602" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe GithubRepo, type: :model do
|
||||
RSpec.describe GithubRepo do
|
||||
let(:user) { create(:user, :with_identity, identities: ["github"]) }
|
||||
let(:repo) { create(:github_repo, user: user) }
|
||||
let(:cache_bust) { instance_double(EdgeCache::Bust) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe HtmlVariant, type: :model do
|
||||
RSpec.describe HtmlVariant do
|
||||
let(:html_variant) { create(:html_variant, approved: true, published: true) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Identity, type: :model do
|
||||
RSpec.describe Identity do
|
||||
let(:identity) { create(:identity, user: create(:user), uid: SecureRandom.hex) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ListingCategory, type: :model do
|
||||
RSpec.describe ListingCategory do
|
||||
describe "validations" do
|
||||
# The uniqueness validation didn't work without this, see section "Caveat" at
|
||||
# https://www.rubydoc.info/github/thoughtbot/shoulda-matchers/Shoulda%2FMatchers%2FActiveRecord:validate_uniqueness_of
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Listing, type: :model do
|
||||
RSpec.describe Listing do
|
||||
let(:user) { create(:user) }
|
||||
let(:organization) { create(:organization) }
|
||||
let(:listing) { create(:listing, user: user) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Mention, type: :model do
|
||||
RSpec.describe Mention do
|
||||
let(:comment) { create(:comment, commentable: create(:podcast_episode)) }
|
||||
|
||||
describe "#create_all" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe NavigationLink, type: :model do
|
||||
RSpec.describe NavigationLink do
|
||||
let(:navigation_link) { create(:navigation_link) }
|
||||
|
||||
describe ".create_or_update_by_identity" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Note, type: :model do
|
||||
RSpec.describe Note do
|
||||
it { is_expected.to belong_to(:noteable) }
|
||||
it { is_expected.to belong_to(:author).class_name("User").optional }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require "rails_helper"
|
||||
require "sidekiq/testing"
|
||||
|
||||
RSpec.describe Notification, type: :model do
|
||||
RSpec.describe Notification do
|
||||
let(:user) { create(:user) }
|
||||
let(:user2) { create(:user) }
|
||||
let(:user3) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe NotificationSubscription, type: :model do
|
||||
RSpec.describe NotificationSubscription do
|
||||
let(:user) { create(:user) }
|
||||
let(:article) { create(:article, user: user) }
|
||||
let(:notification_subscription) { create(:notification_subscription, user: user, notifiable: article) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe OrganizationMembership, type: :model do
|
||||
RSpec.describe OrganizationMembership do
|
||||
describe "validations" do
|
||||
subject { build(:organization_membership) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Page, type: :model do
|
||||
RSpec.describe Page do
|
||||
describe ".render_safe_html_for" do
|
||||
let(:slug) { "the-given-slug" }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PageView, type: :model do
|
||||
RSpec.describe PageView do
|
||||
let(:page_view) { create(:page_view, referrer: "http://example.com/page") }
|
||||
|
||||
it { is_expected.to belong_to(:user).optional }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PinnedArticle, type: :model do
|
||||
RSpec.describe PinnedArticle do
|
||||
let(:article) { create(:article) }
|
||||
|
||||
describe ".exists?" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PodcastEpisodeAppearance, type: :model do
|
||||
RSpec.describe PodcastEpisodeAppearance do
|
||||
let(:podcast_episode_appearance) { create(:podcast_episode_appearance) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PodcastEpisode, type: :model do
|
||||
RSpec.describe PodcastEpisode do
|
||||
let(:podcast_episode) { create(:podcast_episode) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PodcastOwnership, type: :model do
|
||||
RSpec.describe PodcastOwnership do
|
||||
let(:podcast_ownership) { create(:podcast_ownership) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Podcast, type: :model do
|
||||
RSpec.describe Podcast do
|
||||
let(:podcast) { create(:podcast) }
|
||||
|
||||
it "has a creator" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PollOption, type: :model do
|
||||
RSpec.describe PollOption do
|
||||
let(:article) { build(:article, featured: true) }
|
||||
let(:poll) { build(:poll, article: article) }
|
||||
let(:poll_option) { build(:poll_option, poll: poll) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PollSkip, type: :model do
|
||||
RSpec.describe PollSkip do
|
||||
let(:article) { create(:article, featured: true) }
|
||||
let(:user) { create(:user) }
|
||||
let(:poll) { create(:poll, article: article) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Poll, type: :model do
|
||||
RSpec.describe Poll do
|
||||
let(:article) { create(:article, featured: true) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe PollVote, type: :model do
|
||||
RSpec.describe PollVote do
|
||||
let(:article) { create(:article, featured: true) }
|
||||
let(:user) { create(:user) }
|
||||
let(:poll) { create(:poll, article_id: article.id) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ProfileFieldGroup, type: :model do
|
||||
RSpec.describe ProfileFieldGroup do
|
||||
subject { group }
|
||||
|
||||
let!(:group) { create(:profile_field_group) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ProfileField, type: :model do
|
||||
RSpec.describe ProfileField do
|
||||
describe "associations" do
|
||||
it { is_expected.to belong_to(:profile_field_group) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ProfilePin, type: :model do
|
||||
RSpec.describe ProfilePin do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe "validations" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Profile, type: :model do
|
||||
RSpec.describe Profile do
|
||||
let(:user) { create(:user) }
|
||||
let(:profile) { user.profile }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe RatingVote, type: :model do
|
||||
RSpec.describe RatingVote do
|
||||
let(:user) { create(:user, :trusted) }
|
||||
let(:user2) { create(:user, :trusted) }
|
||||
let(:article) { create(:article, user: user) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ResponseTemplate, type: :model do
|
||||
RSpec.describe ResponseTemplate do
|
||||
let(:comment_validation_message) { I18n.t("models.response_template.comment_markdown") }
|
||||
|
||||
it { is_expected.to validate_inclusion_of(:type_of).in_array(ResponseTemplate::TYPE_OF_TYPES) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Role, type: :model do
|
||||
RSpec.describe Role do
|
||||
it { is_expected.to belong_to(:resource).optional }
|
||||
it { is_expected.to validate_inclusion_of(:resource_type).in_array(Rolify.resource_types) }
|
||||
it { is_expected.to validate_inclusion_of(:name).in_array(described_class::ROLES) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Settings::Authentication, type: :model do
|
||||
RSpec.describe Settings::Authentication do
|
||||
describe "#acceptable_domain?" do
|
||||
subject { described_class.acceptable_domain?(domain: domain) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Settings::Base, type: :model do
|
||||
RSpec.describe Settings::Base do
|
||||
with_model :TestSetting, superclass: described_class do
|
||||
table do |t|
|
||||
t.string :var, null: false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Settings::General, type: :model do
|
||||
RSpec.describe Settings::General do
|
||||
describe "validations" do
|
||||
describe "validating URLs" do
|
||||
let(:url_fields) do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Settings::RateLimit, type: :model do
|
||||
RSpec.describe Settings::RateLimit do
|
||||
describe ".user_considered_new?" do
|
||||
subject(:function_call) { described_class.user_considered_new?(user: user) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe TagAdjustment, type: :model do
|
||||
RSpec.describe TagAdjustment do
|
||||
before do
|
||||
mod_user.add_role(:tag_moderator, tag)
|
||||
admin_user.add_role(:admin)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Tag, type: :model do
|
||||
RSpec.describe Tag do
|
||||
let(:tag) { build(:tag) }
|
||||
|
||||
describe "#class_name" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Timeframe, type: :model do
|
||||
RSpec.describe Timeframe do
|
||||
it "sets timeframe for week to 1 week ago" do
|
||||
Timecop.freeze(Time.current) do
|
||||
timeframe = described_class.datetime("week")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Tweet, type: :model, vcr: true do
|
||||
RSpec.describe Tweet, vcr: true do
|
||||
let(:tweet_id) { "1018911886862057472" }
|
||||
let(:tweet_reply_id) { "1242938461784608770" }
|
||||
let(:retweet_id) { "1262395854469677058" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe UserBlock, type: :model do
|
||||
RSpec.describe UserBlock do
|
||||
let(:blocker) { create(:user) }
|
||||
let(:blocked_user) { create(:user) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe UserRole, type: :model do
|
||||
RSpec.describe UserRole do
|
||||
it { is_expected.to belong_to(:user) }
|
||||
it { is_expected.to belong_to(:role) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Users::DeletedUser, type: :model do
|
||||
RSpec.describe Users::DeletedUser do
|
||||
subject(:deleted_user) { described_class }
|
||||
|
||||
describe "#class_name" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Users::NotificationSetting, type: :model do
|
||||
RSpec.describe Users::NotificationSetting do
|
||||
let!(:user) { create(:user) }
|
||||
let(:notification_setting) { user.notification_setting.reload }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
# rubocop:disable Layout/LineLength
|
||||
RSpec.describe Users::Setting, type: :model do
|
||||
RSpec.describe Users::Setting do
|
||||
let(:user) { create(:user) }
|
||||
let(:setting) { described_class.find_by(user_id: user.id) }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Users::SuspendedUsername, type: :model do
|
||||
RSpec.describe Users::SuspendedUsername do
|
||||
describe "validations" do
|
||||
subject { create(:suspended_username) }
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ RSpec.describe Admin::UsersQuery, type: :query do
|
|||
let(:joining_end) { nil }
|
||||
|
||||
describe ".find" do
|
||||
let!(:user1) { create :user, username: "user1" }
|
||||
let!(:user2) { create :user, username: "user12" }
|
||||
let!(:user1) { create(:user, username: "user1") }
|
||||
let!(:user2) { create(:user, username: "user12") }
|
||||
|
||||
context "when identifier is blank" do
|
||||
it "returns nil" do
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ RSpec.describe Comments::CommunityWellnessQuery, type: :query do
|
|||
it "returns users with correct data on their corresponding hash" do
|
||||
result = described_class.call
|
||||
|
||||
result_user_ids = result.map { |hash| hash["user_id"] }
|
||||
result_user_ids = result.pluck("user_id")
|
||||
expect(result_user_ids).to contain_exactly(user1.id, user2.id, user5.id)
|
||||
|
||||
index1 = result.index { |hash| hash["user_id"] == user1.id }
|
||||
|
|
@ -119,7 +119,7 @@ RSpec.describe Comments::CommunityWellnessQuery, type: :query do
|
|||
it "matches the correct comment count for each week in result hash" do
|
||||
result = described_class.call
|
||||
|
||||
result_user_ids = result.map { |hash| hash["user_id"] }
|
||||
result_user_ids = result.pluck("user_id")
|
||||
# Result includes both users because they have > 1 comment per week
|
||||
expect(result_user_ids).to contain_exactly(user1.id, user2.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ RSpec.describe "/admin/reactions" do
|
|||
|
||||
it "returns expected JSON upon status update" do
|
||||
put admin_reaction_path(reaction.id), params: { id: reaction.id, status: "confirmed" }
|
||||
expect(JSON.parse(response.body)).to eq("outcome" => "Success")
|
||||
expect(response.parsed_body).to eq("outcome" => "Success")
|
||||
end
|
||||
|
||||
it "returns error upon status update failure" do
|
||||
put admin_reaction_path(reaction.id), params: { id: reaction.id, status: "confirmedsssss" }
|
||||
expect(JSON.parse(response.body)).to include("error")
|
||||
expect(response.parsed_body).to include("error")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ RSpec.describe "Api::V0::Analytics" do
|
|||
|
||||
it "renders the proper error message in JSON" do
|
||||
error_message = "Required 'start' parameter is missing"
|
||||
expect(JSON.parse(response.body)["error"]).to eq(error_message)
|
||||
expect(response.parsed_body["error"]).to eq(error_message)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ RSpec.describe "Api::V0::Analytics" do
|
|||
|
||||
it "renders the proper error message in JSON" do
|
||||
error_message = "Date parameters 'start' or 'end' must be in the format of 'yyyy-mm-dd'"
|
||||
expect(JSON.parse(response.body)["error"]).to eq(error_message)
|
||||
expect(response.parsed_body["error"]).to eq(error_message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ RSpec.describe "Api::V0::FeatureFlagsController" do
|
|||
|
||||
get api_feature_flags_path(flag: flag)
|
||||
|
||||
parsed_response = JSON.parse(response.body)
|
||||
parsed_response = response.parsed_body
|
||||
expect(parsed_response[flag]).to be true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ RSpec.describe "Api::V1::Analytics" do
|
|||
|
||||
it "renders the proper error message in JSON" do
|
||||
error_message = "Required 'start' parameter is missing"
|
||||
expect(JSON.parse(response.body)["error"]).to eq(error_message)
|
||||
expect(response.parsed_body["error"]).to eq(error_message)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ RSpec.describe "Api::V1::Analytics" do
|
|||
|
||||
it "renders the proper error message in JSON" do
|
||||
error_message = "Date parameters 'start' or 'end' must be in the format of 'yyyy-mm-dd'"
|
||||
expect(JSON.parse(response.body)["error"]).to eq(error_message)
|
||||
expect(response.parsed_body["error"]).to eq(error_message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ RSpec.describe "Api::V1::FeatureFlagsController" do
|
|||
|
||||
get api_feature_flags_path(flag: flag), headers: headers
|
||||
|
||||
parsed_response = JSON.parse(response.body)
|
||||
parsed_response = response.parsed_body
|
||||
expect(parsed_response[flag]).to be true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ RSpec.describe "Api::V1::Reactions" do
|
|||
|
||||
it "responds with expected JSON" do
|
||||
post api_reactions_toggle_path, params: params.to_json, headers: auth_header
|
||||
expect(JSON.parse(response.body).keys).to contain_exactly("id", "result", "category", "reactable_type",
|
||||
"reactable_id")
|
||||
expect(response.parsed_body.keys).to contain_exactly("id", "result", "category", "reactable_type",
|
||||
"reactable_id")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -103,8 +103,8 @@ RSpec.describe "Api::V1::Reactions" do
|
|||
|
||||
it "responds with expected JSON" do
|
||||
post api_reactions_path, params: params.to_json, headers: auth_header
|
||||
expect(JSON.parse(response.body).keys).to contain_exactly("id", "result", "category", "reactable_type",
|
||||
"reactable_id")
|
||||
expect(response.parsed_body.keys).to contain_exactly("id", "result", "category", "reactable_type",
|
||||
"reactable_id")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ RSpec.describe "Follows #create" do
|
|||
|
||||
it "returns an error for too many follows in a day" do
|
||||
post "/follows", headers: headers, params: follow_payload
|
||||
json_response = JSON.parse(response.body)
|
||||
json_response = response.parsed_body
|
||||
|
||||
expect(response).to have_http_status(:too_many_requests)
|
||||
expect(json_response["error"]).to eq("Daily account follow limit reached!")
|
||||
|
|
@ -43,7 +43,7 @@ RSpec.describe "Follows #create" do
|
|||
post "/follows", headers: headers, params: follow_payload
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)["outcome"]).to eq("followed")
|
||||
expect(response.parsed_body["outcome"]).to eq("followed")
|
||||
end
|
||||
|
||||
it "unfollows" do
|
||||
|
|
@ -52,6 +52,6 @@ RSpec.describe "Follows #create" do
|
|||
params: { followable_type: "User", followable_id: user.id, verb: "unfollow" }.to_json
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)["outcome"]).to eq("unfollowed")
|
||||
expect(response.parsed_body["outcome"]).to eq("unfollowed")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ RSpec.describe "NotificationSubscriptions" do
|
|||
it "returns the correct subscription boolean as JSON" do
|
||||
get "/notification_subscriptions/Article/#{article.id}",
|
||||
headers: headers
|
||||
expect(JSON.parse(response.body)["config"]).to eq "all_comments"
|
||||
expect(response.parsed_body["config"]).to eq "all_comments"
|
||||
end
|
||||
|
||||
it "returns the correct subscription boolean as JSON if unsubscribed" do
|
||||
article.notification_subscriptions.first.delete
|
||||
get "/notification_subscriptions/Article/#{article.id}",
|
||||
headers: headers
|
||||
expect(JSON.parse(response.body)["config"]).to eq "not_subscribed"
|
||||
expect(response.parsed_body["config"]).to eq "not_subscribed"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ RSpec.describe "PollVotes" do
|
|||
describe "GET /poll_votes" do
|
||||
it "returns proper results for poll" do
|
||||
get "/poll_votes/#{poll.id}"
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_count"]).to eq(0)
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 0])
|
||||
expect(JSON.parse(response.body)["poll_id"]).to eq(poll.id)
|
||||
expect(JSON.parse(response.body)["voted"]).to be(false)
|
||||
expect(response.parsed_body["voting_data"]["votes_count"]).to eq(0)
|
||||
expect(response.parsed_body["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 0])
|
||||
expect(response.parsed_body["poll_id"]).to eq(poll.id)
|
||||
expect(response.parsed_body["voted"]).to be(false)
|
||||
end
|
||||
|
||||
it "returns proper results for poll if voted" do
|
||||
create(:poll_vote, user_id: user.id, poll_option_id: poll.poll_options.first.id, poll_id: poll.id)
|
||||
get "/poll_votes/#{poll.id}"
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(JSON.parse(response.body)["poll_id"]).to eq(poll.id)
|
||||
expect(JSON.parse(response.body)["voted"]).to be(true)
|
||||
expect(response.parsed_body["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(response.parsed_body["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(response.parsed_body["poll_id"]).to eq(poll.id)
|
||||
expect(response.parsed_body["voted"]).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -31,10 +31,10 @@ RSpec.describe "PollVotes" do
|
|||
post "/poll_votes", params: {
|
||||
poll_vote: { poll_option_id: poll.poll_options.first.id }
|
||||
}
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(JSON.parse(response.body)["poll_id"]).to eq(poll.id)
|
||||
expect(JSON.parse(response.body)["voted"]).to be(true)
|
||||
expect(response.parsed_body["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(response.parsed_body["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(response.parsed_body["poll_id"]).to eq(poll.id)
|
||||
expect(response.parsed_body["voted"]).to be(true)
|
||||
expect(user.poll_votes.size).to eq(1)
|
||||
end
|
||||
|
||||
|
|
@ -45,9 +45,9 @@ RSpec.describe "PollVotes" do
|
|||
post "/poll_votes", params: {
|
||||
poll_vote: { poll_option_id: poll.poll_options.first.id }
|
||||
}
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(JSON.parse(response.body)["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(JSON.parse(response.body)["voted"]).to be(true)
|
||||
expect(response.parsed_body["voting_data"]["votes_count"]).to eq(1)
|
||||
expect(response.parsed_body["voting_data"]["votes_distribution"]).to include([poll.poll_options.first.id, 1])
|
||||
expect(response.parsed_body["voted"]).to be(true)
|
||||
expect(user.poll_votes.size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ RSpec.describe "ResponseTemplate" do
|
|||
create_list(:response_template, 2, user: nil, type_of: "mod_comment")
|
||||
create_list(:response_template, 2, user: user, type_of: "personal_comment")
|
||||
get response_templates_path, params: { type_of: nil }, headers: { HTTP_ACCEPT: "application/json" }
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.keys).to contain_exactly("personal_comment")
|
||||
expect(json.values.flatten.count).to eq(2)
|
||||
end
|
||||
|
|
@ -83,14 +83,14 @@ RSpec.describe "ResponseTemplate" do
|
|||
create_list(:response_template, 2, user: nil, type_of: "mod_comment")
|
||||
create_list(:response_template, 2, user: moderator, type_of: "personal_comment")
|
||||
get response_templates_path, params: { type_of: "mod_comment" }, headers: { HTTP_ACCEPT: "application/json" }
|
||||
expect(JSON.parse(response.body).length).to eq 2
|
||||
expect(response.parsed_body.length).to eq 2
|
||||
end
|
||||
|
||||
it "returns both personal and moderator response templates if type_of unspecified" do
|
||||
create_list(:response_template, 2, user: nil, type_of: "mod_comment")
|
||||
create_list(:response_template, 2, user: moderator, type_of: "personal_comment")
|
||||
get response_templates_path, params: { type_of: nil }, headers: { HTTP_ACCEPT: "application/json" }
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.keys).to contain_exactly("mod_comment", "personal_comment")
|
||||
expect(json.values.flatten.count).to eq(4)
|
||||
end
|
||||
|
|
@ -114,7 +114,7 @@ RSpec.describe "ResponseTemplate" do
|
|||
it "allows access and returns an array of admin level response templates" do
|
||||
create_list(:response_template, 2, user: nil, type_of: "email_reply", content_type: "html")
|
||||
get response_templates_path, params: { type_of: "email_reply" }, headers: { HTTP_ACCEPT: "application/json" }
|
||||
expect(JSON.parse(response.body).length).to eq 2
|
||||
expect(response.parsed_body.length).to eq 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue