mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add rubocop to our build. (#5004)
This commit is contained in:
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe AllowedIpAddressValidator do
|
||||
|
||||
let(:record) { Fabricate.build(:user, trust_level: TrustLevel[0], ip_address: '99.232.23.123') }
|
||||
let(:validator) { described_class.new({attributes: :ip_address}) }
|
||||
let(:validator) { described_class.new(attributes: :ip_address) }
|
||||
subject(:validate) { validator.validate_each(record, :ip_address, record.ip_address) }
|
||||
|
||||
context "ip address should be blocked" do
|
||||
|
||||
@@ -2,9 +2,9 @@ require 'rails_helper'
|
||||
|
||||
describe EmailValidator do
|
||||
|
||||
let(:record) { }
|
||||
let(:validator) { described_class.new({attributes: :email}) }
|
||||
subject(:validate) { validator.validate_each(record,:email,record.email) }
|
||||
let(:record) {}
|
||||
let(:validator) { described_class.new(attributes: :email) }
|
||||
subject(:validate) { validator.validate_each(record, :email, record.email) }
|
||||
|
||||
def blocks?(email)
|
||||
user = Fabricate.build(:user, email: email)
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
describe IpAddressFormatValidator do
|
||||
|
||||
let(:record) { Fabricate.build(:screened_ip_address, ip_address: '99.232.23.123') }
|
||||
let(:validator) { described_class.new({attributes: :ip_address}) }
|
||||
let(:validator) { described_class.new(attributes: :ip_address) }
|
||||
subject(:validate) { validator.validate_each(record, :ip_address, record.ip_address) }
|
||||
|
||||
['99.232.23.123', '99.232.0.0/16', 'fd12:db8::ff00:42:8329', 'fc00::/7'].each do |arg|
|
||||
|
||||
@@ -7,8 +7,8 @@ describe PasswordValidator do
|
||||
I18n.t("activerecord.errors.models.user.attributes.password.#{key.to_s}")
|
||||
end
|
||||
|
||||
let(:validator) { described_class.new({attributes: :password}) }
|
||||
subject(:validate) { validator.validate_each(record,:password,@password) }
|
||||
let(:validator) { described_class.new(attributes: :password) }
|
||||
subject(:validate) { validator.validate_each(record, :password, @password) }
|
||||
|
||||
context "password required" do
|
||||
let(:record) { u = Fabricate.build(:user, password: @password); u.password_required!; u }
|
||||
|
||||
@@ -7,20 +7,20 @@ require 'ostruct'
|
||||
module QualityTitleValidatorSpec
|
||||
class Validatable < OpenStruct
|
||||
include ActiveModel::Validations
|
||||
validates :title, :quality_title => { :unless => :private_message? }
|
||||
validates :title, quality_title: { unless: :private_message? }
|
||||
end
|
||||
end
|
||||
|
||||
describe "A record validated with QualityTitleValidator" do
|
||||
let(:valid_title){ "hello this is my cool topic! welcome: all;" }
|
||||
let(:short_title){ valid_title.slice(0, SiteSetting.min_topic_title_length - 1) }
|
||||
let(:long_title ){ valid_title.center(SiteSetting.max_topic_title_length + 1, 'x') }
|
||||
let(:xxxxx_title){ valid_title.gsub(/./,'x')}
|
||||
let(:valid_title) { "hello this is my cool topic! welcome: all;" }
|
||||
let(:short_title) { valid_title.slice(0, SiteSetting.min_topic_title_length - 1) }
|
||||
let(:long_title) { valid_title.center(SiteSetting.max_topic_title_length + 1, 'x') }
|
||||
let(:xxxxx_title) { valid_title.gsub(/./, 'x') }
|
||||
|
||||
subject(:topic){ QualityTitleValidatorSpec::Validatable.new }
|
||||
subject(:topic) { QualityTitleValidatorSpec::Validatable.new }
|
||||
|
||||
before(:each) do
|
||||
topic.stubs(:private_message? => false)
|
||||
topic.stubs(private_message?: false)
|
||||
end
|
||||
|
||||
it "allows a regular title with a few ascii characters" do
|
||||
@@ -39,7 +39,7 @@ describe "A record validated with QualityTitleValidator" do
|
||||
end
|
||||
|
||||
it "allows anything in a private message" do
|
||||
topic.stubs(:private_message? => true)
|
||||
topic.stubs(private_message?: true)
|
||||
[short_title, long_title, xxxxx_title].each do |bad_title|
|
||||
topic.title = bad_title
|
||||
expect(topic).to be_valid
|
||||
@@ -75,4 +75,3 @@ describe "A record validated with QualityTitleValidator" do
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ describe TopicTitleLengthValidator do
|
||||
|
||||
# simulate Rails behavior (singleton)
|
||||
def validate
|
||||
@validator ||= TopicTitleLengthValidator.new({ attributes: :title })
|
||||
@validator.validate_each(record,:title,record.title)
|
||||
@validator ||= TopicTitleLengthValidator.new(attributes: :title)
|
||||
@validator.validate_each(record, :title, record.title)
|
||||
end
|
||||
|
||||
shared_examples "validating any topic title" do
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe UserFullNameValidator do
|
||||
let(:validator) { described_class.new({attributes: :name}) }
|
||||
subject(:validate) { validator.validate_each(record,:name,@name) }
|
||||
let(:validator) { described_class.new(attributes: :name) }
|
||||
subject(:validate) { validator.validate_each(record, :name, @name) }
|
||||
let(:record) { Fabricate.build(:user, name: @name) }
|
||||
|
||||
context "name not required" do
|
||||
|
||||
Reference in New Issue
Block a user