1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2026-01-19 06:09:47 +00:00

style(rubocop): fix all safe auto correctable offenses

هذا الالتزام موجود في:
Charlie Smurthwaite
2023-03-16 15:50:53 +00:00
الأصل 02c93a4850
التزام fd289c46fd
204 ملفات معدلة مع 2611 إضافات و2486 حذوفات

عرض الملف

@@ -1,7 +1,6 @@
require 'rails_helper'
require "rails_helper"
describe Organization do
context "model" do
subject(:organization) { create(:organization) }
@@ -10,5 +9,4 @@ describe Organization do
expect(organization.uuid.length).to eq 36
end
end
end

عرض الملف

@@ -1,23 +1,21 @@
require 'rails_helper'
require "rails_helper"
describe OutgoingMessagePrototype do
it "should create a new message" do
with_global_server do |server|
domain = create(:domain, :owner => server)
prototype = OutgoingMessagePrototype.new(server, '127.0.0.1', 'TestSuite', {
:from => "test@#{domain.name}",
:to => "test@example.com",
:subject => "Test Message",
:plain_body => "A plain body!"
domain = create(:domain, owner: server)
prototype = OutgoingMessagePrototype.new(server, "127.0.0.1", "TestSuite", {
from: "test@#{domain.name}",
to: "test@example.com",
subject: "Test Message",
plain_body: "A plain body!"
})
expect(prototype.valid?).to be true
message = prototype.create_message('test@example.com')
message = prototype.create_message("test@example.com")
expect(message).to be_a Hash
expect(message[:id]).to be_a Integer
expect(message[:token]).to be_a String
end
end
end

عرض الملف

@@ -1,7 +1,6 @@
require 'rails_helper'
require "rails_helper"
describe Server do
context "model" do
subject(:server) { create(:server) }
@@ -10,5 +9,4 @@ describe Server do
expect(server.uuid.length).to eq 36
end
end
end

عرض الملف

@@ -1,7 +1,6 @@
require 'rails_helper'
require "rails_helper"
describe User do
context "model" do
subject(:user) { create(:user) }
@@ -13,24 +12,23 @@ describe User do
context ".authenticate" do
it "should not authenticate users with invalid emails" do
expect { User.authenticate('nothing@nothing.com', 'hello') }.to raise_error(Postal::Errors::AuthenticationError) do |e|
expect(e.error).to eq 'InvalidEmailAddress'
expect { User.authenticate("nothing@nothing.com", "hello") }.to raise_error(Postal::Errors::AuthenticationError) do |e|
expect(e.error).to eq "InvalidEmailAddress"
end
end
it "should not authenticate users with invalid passwords" do
user = create(:user)
expect { User.authenticate(user.email_address, 'hello') }.to raise_error(Postal::Errors::AuthenticationError) do |e|
expect(e.error).to eq 'InvalidPassword'
expect { User.authenticate(user.email_address, "hello") }.to raise_error(Postal::Errors::AuthenticationError) do |e|
expect(e.error).to eq "InvalidPassword"
end
end
it "should authenticate valid users" do
user = create(:user)
auth_user = nil
expect { auth_user = User.authenticate(user.email_address, 'passw0rd') }.to_not raise_error
expect { auth_user = User.authenticate(user.email_address, "passw0rd") }.to_not raise_error
expect(auth_user).to eq user
end
end
end

عرض الملف

@@ -35,16 +35,14 @@
#
FactoryBot.define do
factory :domain do
association :owner, :factory => :user
association :owner, factory: :user
sequence(:name) { |n| "example#{n}.com" }
verification_method { 'DNS' }
verification_method { "DNS" }
verified_at { Time.now }
end
factory :organization_domain, :parent => :domain do
association :owner, :factory => :organization
factory :organization_domain, parent: :domain do
association :owner, factory: :organization
end
end

عرض الملف

@@ -22,11 +22,9 @@
#
FactoryBot.define do
factory :organization do
name { "Acme Inc" }
sequence(:permalink) { |n| "org#{n}" }
association :owner, :factory => :user
association :owner, factory: :user
end
end

عرض الملف

@@ -40,7 +40,6 @@
#
FactoryBot.define do
factory :server do
association :organization
name { "Mail Server" }
@@ -48,5 +47,4 @@ FactoryBot.define do
provision_database { false }
sequence(:permalink) { |n| "server#{n}" }
end
end

عرض الملف

@@ -19,15 +19,13 @@
#
FactoryBot.define do
factory :track_domain do
name { "click" }
dns_status { 'OK' }
dns_status { "OK" }
association :server
after(:build) do |track_domain|
track_domain.domain ||= create(:domain, :owner => track_domain.server)
track_domain.domain ||= create(:domain, owner: track_domain.server)
end
end
end

عرض الملف

@@ -24,7 +24,6 @@
#
FactoryBot.define do
factory :user do
first_name { "John" }
last_name { "Doe" }
@@ -32,5 +31,4 @@ FactoryBot.define do
email_verified_at { Time.now }
sequence(:email_address) { |n| "user#{n}@example.com" }
end
end

عرض الملف

@@ -1,29 +1,28 @@
# frozen_string_literal: true
require 'rails_helper'
require "rails_helper"
describe Postal::DKIMHeader do
examples = Rails.root.join('spec/examples/dkim_signing/*.msg')
examples = Rails.root.join("spec/examples/dkim_signing/*.msg")
Dir[examples].each do |path|
contents = File.read(path)
frontmatter, email = contents.split(/^---\n/m, 2)
frontmatter = YAML.load(frontmatter)
email.strip
it "works with #{path.split('/').last}" do
mocked_time = Time.at(frontmatter['time'].to_i)
mocked_time = Time.at(frontmatter["time"].to_i)
allow(Time).to receive(:now).and_return(mocked_time)
domain = instance_double('Domain')
allow(domain).to receive(:dkim_status).and_return('OK')
allow(domain).to receive(:name).and_return(frontmatter['domain'])
allow(domain).to receive(:dkim_key).and_return(OpenSSL::PKey::RSA.new(frontmatter['private_key']))
allow(domain).to receive(:dkim_identifier).and_return(frontmatter['dkim_identifier'])
domain = instance_double("Domain")
allow(domain).to receive(:dkim_status).and_return("OK")
allow(domain).to receive(:name).and_return(frontmatter["domain"])
allow(domain).to receive(:dkim_key).and_return(OpenSSL::PKey::RSA.new(frontmatter["private_key"]))
allow(domain).to receive(:dkim_identifier).and_return(frontmatter["dkim_identifier"])
expectation = "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n" \
expectation = "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n" \
"\td=#{frontmatter['domain']};\r\n" \
"\ts=#{frontmatter['dkim_identifier']}; t=#{mocked_time.to_i};\r\n" \
"\tbh=#{frontmatter['bh']};\r\n"\
"\tbh=#{frontmatter['bh']};\r\n" \
"\th=#{frontmatter['headers']};\r\n" \
"\tb=#{frontmatter['b'].scan(/.{1,72}/).join("\r\n\t")}"
@@ -32,5 +31,4 @@ describe Postal::DKIMHeader do
expect(header.dkim_header).to eq expectation
end
end
end

عرض الملف

@@ -1,7 +1,6 @@
require 'rails_helper'
require "rails_helper"
describe Postal::MessageDB::Database do
context "when provisioned" do
subject(:database) { GLOBAL_SERVER.message_db }
@@ -13,5 +12,4 @@ describe Postal::MessageDB::Database do
expect(database.schema_version).to be_a Integer
end
end
end

عرض الملف

@@ -1,11 +1,10 @@
require 'rails_helper'
require "rails_helper"
describe Postal::MessageParser do
it "should not do anything when there are no tracking domains" do
with_global_server do |server|
expect(server.track_domains.size).to eq 0
message = create_plain_text_message(server, 'Hello world!', 'test@example.com')
message = create_plain_text_message(server, "Hello world!", "test@example.com")
parser = Postal::MessageParser.new(message)
expect(parser.actioned?).to be false
expect(parser.tracked_links).to eq 0
@@ -15,13 +14,12 @@ describe Postal::MessageParser do
it "should replace links in messages" do
with_global_server do |server|
message = create_plain_text_message(server, 'Hello world! http://github.com/atech/postal', 'test@example.com')
track_domain = create(:track_domain, :server => server, :domain => message.domain)
message = create_plain_text_message(server, "Hello world! http://github.com/atech/postal", "test@example.com")
track_domain = create(:track_domain, server: server, domain: message.domain)
parser = Postal::MessageParser.new(message)
expect(parser.actioned?).to be true
expect(parser.new_body).to match(/^Hello world! https:\/\/click\.#{message.domain.name}/)
expect(parser.tracked_links).to eq 1
end
end
end

عرض الملف

@@ -1,45 +1,42 @@
require 'rails_helper'
require "rails_helper"
describe Postal::QueryString do
it "should work with a single item" do
qs = Postal::QueryString.new("to: test@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
expect(qs.to_hash["to"]).to eq "test@example.com"
end
it "should work with a multiple items" do
qs = Postal::QueryString.new("to: test@example.com from: another@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
expect(qs.to_hash['from']).to eq 'another@example.com'
expect(qs.to_hash["to"]).to eq "test@example.com"
expect(qs.to_hash["from"]).to eq "another@example.com"
end
it "should not require a space after the field name" do
qs = Postal::QueryString.new("to:test@example.com from:another@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
expect(qs.to_hash['from']).to eq 'another@example.com'
expect(qs.to_hash["to"]).to eq "test@example.com"
expect(qs.to_hash["from"]).to eq "another@example.com"
end
it "should return nil when it receives blank" do
qs = Postal::QueryString.new("to:[blank]")
expect(qs.to_hash['to']).to eq nil
expect(qs.to_hash["to"]).to eq nil
end
it "should handle dates with spaces" do
qs = Postal::QueryString.new("date: 2017-02-12 15:20")
expect(qs.to_hash['date']).to eq("2017-02-12 15:20")
expect(qs.to_hash["date"]).to eq("2017-02-12 15:20")
end
it "should return an array for multiple items" do
qs = Postal::QueryString.new("to: test@example.com to: another@example.com")
expect(qs.to_hash['to']).to be_a(Array)
expect(qs.to_hash['to'][0]).to eq 'test@example.com'
expect(qs.to_hash['to'][1]).to eq 'another@example.com'
expect(qs.to_hash["to"]).to be_a(Array)
expect(qs.to_hash["to"][0]).to eq "test@example.com"
expect(qs.to_hash["to"][1]).to eq "another@example.com"
end
it "should work with a z in the string" do
qs = Postal::QueryString.new("to: testaz@example.com")
expect(qs.to_hash['to']).to eq "testaz@example.com"
expect(qs.to_hash["to"]).to eq "testaz@example.com"
end
end

عرض الملف

@@ -1,16 +1,16 @@
ENV['POSTAL_ENV'] = 'test'
ENV["POSTAL_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'spec_helper'
require 'factory_bot'
require 'database_cleaner'
require File.expand_path("../config/environment", __dir__)
require "rspec/rails"
require "spec_helper"
require "factory_bot"
require "database_cleaner"
DatabaseCleaner.allow_remote_database_url = true
ActiveRecord::Base.logger = Logger.new("/dev/null")
FACTORIES_EXCLUDED_FROM_LINT = []
Dir[File.expand_path('../factories/*.rb', __FILE__)].each { |f| require f }
Dir[File.expand_path("factories/*.rb", __dir__)].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
@@ -33,7 +33,7 @@ RSpec.configure do |config|
# Because the mail databases don't use any transactions, all data left in the
# database will be left there unless removed.
DatabaseCleaner.start
GLOBAL_SERVER = FactoryBot.create(:server, :provision_database => true)
GLOBAL_SERVER = FactoryBot.create(:server, provision_database: true)
end
config.after(:suite) do
@@ -44,5 +44,4 @@ RSpec.configure do |config|
DatabaseCleaner.clean
end
end
end