مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
style(rubocop): fix all safe auto correctable offenses
هذا الالتزام موجود في:
@@ -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
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم