Merge commit '0ad2413b35287958f59073a5b63aecc659a64d98' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/styles/mastodon/forms.scss`: Conflict because we ran eslint autofix on upstream files. - `config/initializers/content_security_policy.rb`: Code style changes but we have a different version. Kept our version. - `streaming/index.js`: Upstream fixed a typo close to glitch-soc-only code. Applied upstream's changes.
This commit is contained in:
@ -2,9 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Rack::Attack do
|
||||
include Rack::Test::Methods
|
||||
|
||||
describe Rack::Attack, type: :request do
|
||||
def app
|
||||
Rails.application
|
||||
end
|
||||
@ -25,7 +23,7 @@ describe Rack::Attack do
|
||||
it 'does not change the request status' do
|
||||
limit.times do
|
||||
request.call
|
||||
expect(last_response.status).to_not eq(429)
|
||||
expect(response).to_not have_http_status(429)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -34,13 +32,13 @@ describe Rack::Attack do
|
||||
it 'returns http too many requests after limit and returns to normal status after period' do
|
||||
(limit * 2).times do |i|
|
||||
request.call
|
||||
expect(last_response.status).to eq(429) if i > limit
|
||||
expect(response).to have_http_status(429) if i > limit
|
||||
end
|
||||
|
||||
travel period
|
||||
|
||||
request.call
|
||||
expect(last_response.status).to_not eq(429)
|
||||
expect(response).to_not have_http_status(429)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -51,7 +49,7 @@ describe Rack::Attack do
|
||||
context 'through the website' do
|
||||
let(:limit) { 25 }
|
||||
let(:period) { 5.minutes }
|
||||
let(:request) { -> { post path, {}, 'REMOTE_ADDR' => remote_ip } }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
let(:path) { '/auth' }
|
||||
@ -69,7 +67,7 @@ describe Rack::Attack do
|
||||
context 'through the API' do
|
||||
let(:limit) { 5 }
|
||||
let(:period) { 30.minutes }
|
||||
let(:request) { -> { post path, {}, 'REMOTE_ADDR' => remote_ip } }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
let(:path) { '/api/v1/accounts' }
|
||||
@ -82,7 +80,7 @@ describe Rack::Attack do
|
||||
|
||||
it 'returns http not found' do
|
||||
request.call
|
||||
expect(last_response.status).to eq(404)
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -91,7 +89,7 @@ describe Rack::Attack do
|
||||
describe 'throttle excessive sign-in requests by IP address' do
|
||||
let(:limit) { 25 }
|
||||
let(:period) { 5.minutes }
|
||||
let(:request) { -> { post path, {}, 'REMOTE_ADDR' => remote_ip } }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
let(:path) { '/auth/sign_in' }
|
||||
|
@ -104,9 +104,9 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
||||
end
|
||||
|
||||
around do |example|
|
||||
current_locale = I18n.locale
|
||||
example.run
|
||||
I18n.locale = current_locale
|
||||
I18n.with_locale(I18n.locale) do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
before { request.env['devise.mapping'] = Devise.mappings[:user] }
|
||||
|
@ -45,30 +45,28 @@ describe ApplicationHelper do
|
||||
end
|
||||
|
||||
describe 'locale_direction' do
|
||||
around do |example|
|
||||
current_locale = I18n.locale
|
||||
example.run
|
||||
I18n.locale = current_locale
|
||||
end
|
||||
|
||||
it 'adds rtl body class if locale is Arabic' do
|
||||
I18n.locale = :ar
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
I18n.with_locale(:ar) do
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds rtl body class if locale is Farsi' do
|
||||
I18n.locale = :fa
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
I18n.with_locale(:fa) do
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds rtl if locale is Hebrew' do
|
||||
I18n.locale = :he
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
I18n.with_locale(:he) do
|
||||
expect(helper.locale_direction).to eq 'rtl'
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not add rtl if locale is Thai' do
|
||||
I18n.locale = :th
|
||||
expect(helper.locale_direction).to_not eq 'rtl'
|
||||
I18n.with_locale(:th) do
|
||||
expect(helper.locale_direction).to_not eq 'rtl'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,12 +61,12 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
||||
|
||||
it 'renders the headers' do
|
||||
expect(mail.subject).to eq('bob favourited your post')
|
||||
expect(mail.subject).to eq('bob favorited your post')
|
||||
expect(mail[:to].value).to eq("#{receiver.account.username} <#{receiver.email}>")
|
||||
end
|
||||
|
||||
it 'renders the body' do
|
||||
expect(mail.body.encoded).to match('Your post was favourited by bob')
|
||||
expect(mail.body.encoded).to match('Your post was favorited by bob')
|
||||
expect(mail.body.encoded).to include 'The body of the own status'
|
||||
end
|
||||
end
|
||||
|
@ -951,10 +951,10 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
context 'when is local' do
|
||||
# Test disabled because test environment omits autogenerating keys for performance
|
||||
xit 'generates keys' do
|
||||
it 'generates keys' do
|
||||
account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
|
||||
expect(account.keypair.private?).to be true
|
||||
expect(account.keypair).to be_private
|
||||
expect(account.keypair).to be_public
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -527,6 +527,28 @@ RSpec.describe User, type: :model do
|
||||
end
|
||||
|
||||
describe '.those_who_can' do
|
||||
pending
|
||||
let!(:moderator_user) { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
|
||||
|
||||
context 'when there are not any user roles' do
|
||||
before { UserRole.destroy_all }
|
||||
|
||||
it 'returns an empty list' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are not users with the needed role' do
|
||||
it 'returns an empty list' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are users with roles' do
|
||||
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
it 'returns the users with the role' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([admin_user])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
13
spec/requests/follower_accounts_spec.rb
Normal file
13
spec/requests/follower_accounts_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'FollowerAccountsController' do
|
||||
describe 'The follower_accounts route' do
|
||||
it "returns a http 'moved_permanently' code" do
|
||||
get '/users/:username/followers'
|
||||
|
||||
expect(response).to have_http_status(301)
|
||||
end
|
||||
end
|
||||
end
|
13
spec/requests/following_accounts_spec.rb
Normal file
13
spec/requests/following_accounts_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'FollowingAccountsController' do
|
||||
describe 'The following_accounts route' do
|
||||
it "returns a http 'moved_permanently' code" do
|
||||
get '/users/:username/following'
|
||||
|
||||
expect(response).to have_http_status(301)
|
||||
end
|
||||
end
|
||||
end
|
@ -3,8 +3,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Localization' do
|
||||
after(:all) do
|
||||
I18n.locale = I18n.default_locale
|
||||
around do |example|
|
||||
I18n.with_locale(I18n.locale) do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
it 'uses a specific region when provided' do
|
||||
|
@ -29,10 +29,10 @@ describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
|
||||
|
||||
header_tags = view.content_for(:header_tags)
|
||||
|
||||
expect(header_tags).to match(%r{<meta content=".+" property="og:title" />})
|
||||
expect(header_tags).to match(%r{<meta content="article" property="og:type" />})
|
||||
expect(header_tags).to match(%r{<meta content=".+" property="og:image" />})
|
||||
expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />})
|
||||
expect(header_tags).to match(/<meta content=".+" property="og:title">/)
|
||||
expect(header_tags).to match(/<meta content="article" property="og:type">/)
|
||||
expect(header_tags).to match(/<meta content=".+" property="og:image">/)
|
||||
expect(header_tags).to match(%r{<meta content="http://.+" property="og:url">})
|
||||
end
|
||||
|
||||
it 'has twitter player tag' do
|
||||
@ -48,7 +48,7 @@ describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
|
||||
|
||||
header_tags = view.content_for(:header_tags)
|
||||
|
||||
expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player" />})
|
||||
expect(header_tags).to match(%r{<meta content="player" property="twitter:card" />})
|
||||
expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
|
||||
expect(header_tags).to match(/<meta content="player" property="twitter:card">/)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user