Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
This commit is contained in:
@@ -8,7 +8,7 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||
|
||||
shared_examples 'localized subject' do |*args, **kwrest|
|
||||
it 'renders subject localized for the locale of the receiver' do
|
||||
locale = I18n.available_locales.sample
|
||||
locale = %i(de en).sample
|
||||
receiver.update!(locale: locale)
|
||||
expect(mail.subject).to eq I18n.t(*args, kwrest.merge(locale: locale))
|
||||
end
|
||||
|
@@ -42,11 +42,6 @@ RSpec.describe Setting, type: :model do
|
||||
described_class[key]
|
||||
end
|
||||
|
||||
it 'calls Rails.cache.fetch' do
|
||||
expect(Rails).to receive_message_chain(:cache, :fetch).with(cache_key)
|
||||
described_class[key]
|
||||
end
|
||||
|
||||
context 'Rails.cache does not exists' do
|
||||
before do
|
||||
allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
|
||||
@@ -103,6 +98,14 @@ RSpec.describe Setting, type: :model do
|
||||
Rails.cache.write(cache_key, cache_value)
|
||||
end
|
||||
|
||||
it 'does not query the database' do
|
||||
expect do |callback|
|
||||
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
|
||||
described_class[key]
|
||||
end
|
||||
end.not_to yield_control
|
||||
end
|
||||
|
||||
it 'returns the cached value' do
|
||||
expect(described_class[key]).to eq cache_value
|
||||
end
|
||||
|
@@ -90,9 +90,7 @@ describe InstancePresenter do
|
||||
|
||||
describe "user_count" do
|
||||
it "returns the number of site users" do
|
||||
cache = double
|
||||
allow(Rails).to receive(:cache).and_return(cache)
|
||||
allow(cache).to receive(:fetch).with("user_count").and_return(123)
|
||||
Rails.cache.write 'user_count', 123
|
||||
|
||||
expect(instance_presenter.user_count).to eq(123)
|
||||
end
|
||||
@@ -100,9 +98,7 @@ describe InstancePresenter do
|
||||
|
||||
describe "status_count" do
|
||||
it "returns the number of local statuses" do
|
||||
cache = double
|
||||
allow(Rails).to receive(:cache).and_return(cache)
|
||||
allow(cache).to receive(:fetch).with("local_status_count").and_return(234)
|
||||
Rails.cache.write 'local_status_count', 234
|
||||
|
||||
expect(instance_presenter.status_count).to eq(234)
|
||||
end
|
||||
@@ -110,9 +106,7 @@ describe InstancePresenter do
|
||||
|
||||
describe "domain_count" do
|
||||
it "returns the number of known domains" do
|
||||
cache = double
|
||||
allow(Rails).to receive(:cache).and_return(cache)
|
||||
allow(cache).to receive(:fetch).with("distinct_domain_count").and_return(345)
|
||||
Rails.cache.write 'distinct_domain_count', 345
|
||||
|
||||
expect(instance_presenter.domain_count).to eq(345)
|
||||
end
|
||||
|
@@ -51,6 +51,8 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
config.after :each do
|
||||
Rails.cache.clear
|
||||
|
||||
keys = Redis.current.keys
|
||||
Redis.current.del(keys) if keys.any?
|
||||
end
|
||||
|
@@ -1,4 +1,35 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchRemoteStatusService do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:prefetched_body) { nil }
|
||||
let(:valid_domain) { Rails.configuration.x.local_domain }
|
||||
|
||||
let(:note) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: "https://#{valid_domain}/@foo/1234",
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(account),
|
||||
}
|
||||
end
|
||||
|
||||
context 'protocol is :activitypub' do
|
||||
subject { described_class.new.call(note[:id], prefetched_body, protocol) }
|
||||
let(:prefetched_body) { Oj.dump(note) }
|
||||
let(:protocol) { :activitypub }
|
||||
|
||||
before do
|
||||
account.update(uri: ActivityPub::TagManager.instance.uri_for(account))
|
||||
subject
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = account.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user