Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/controllers/settings/preferences_controller.rb`:
  Conflicts due to us having more user settings and upstream dropping
  `hide_network` (to replace it with an account attribute, properly migrated).
  Dropped `hide_network` like upstream.
- `app/lib/user_settings_decorator.rb`:
  Conflicts due to us having more user settings and upstream dropping
  `hide_network` (to replace it with an account attribute, properly migrated).
  Dropped `hide_network` like upstream.
- `app/models/status.rb`:
  Conflict because of slight change in how glitch-soc handles the scope to
  filter out local-only posts for anonymous viewers.
  Took upstream's changes and re-applied glitch-soc's change.
- `app/models/user.rb`:
  Conflicts due to us having more user settings and upstream dropping
  `hide_network` (to replace it with an account attribute, properly migrated).
  Dropped `hide_network` like upstream.
- `app/views/directories/index.html.haml`:
  Conflict because upstream redesigned that page while glitch-soc had a minor
  change to support hiding the number of followers.
  Ported glitch-soc's change on top of upstream's redesign.

Additional changes:
- `app/models/account_statuses_filter.rb`:
  See change to `app/models/status.rb`.
This commit is contained in:
Claire
2022-03-08 20:22:54 +01:00
75 changed files with 906 additions and 597 deletions

View File

@@ -5,7 +5,7 @@ RSpec.describe AccountsController, type: :controller do
let(:account) { Fabricate(:account) }
shared_examples 'cachable response' do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
@@ -374,7 +374,7 @@ RSpec.describe AccountsController, type: :controller do
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'renders account' do
json = body_as_json
@@ -432,7 +432,7 @@ RSpec.describe AccountsController, type: :controller do
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'renders account' do
json = body_as_json
@@ -499,7 +499,7 @@ RSpec.describe AccountsController, type: :controller do
expect(response).to have_http_status(200)
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
end
context do

View File

@@ -7,7 +7,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
let!(:private_pinned) { Fabricate(:status, account: account, text: 'secret private stuff', visibility: :private) }
let(:remote_account) { nil }
shared_examples 'cachable response' do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
@@ -48,7 +48,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'returns orderedItems with pinned statuses' do
expect(body[:orderedItems]).to be_an Array
@@ -101,7 +101,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'returns orderedItems with pinned statuses' do
json = body_as_json

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe ActivityPub::OutboxesController, type: :controller do
let!(:account) { Fabricate(:account) }
shared_examples 'cachable response' do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
@@ -53,7 +53,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
expect(body[:totalItems]).to eq 4
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'does not have a Vary header' do
expect(response.headers['Vary']).to be_nil
@@ -98,7 +98,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
expect(body[:orderedItems].all? { |item| item[:to].include?(ActivityPub::TagManager::COLLECTIONS[:public]) || item[:cc].include?(ActivityPub::TagManager::COLLECTIONS[:public]) }).to be true
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'returns Vary header with Signature' do
expect(response.headers['Vary']).to include 'Signature'

View File

@@ -8,7 +8,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do
let(:remote_reply_id) { 'https://foobar.com/statuses/1234' }
let(:remote_querier) { nil }
shared_examples 'cachable response' do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
@@ -93,7 +93,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
context 'without only_other_accounts' do
it "returns items with thread author's replies" do

View File

@@ -31,7 +31,7 @@ describe Api::V1::Accounts::NotesController do
end
end
context 'when account note exceends allowed length' do
context 'when account note exceeds allowed length' do
let(:comment) { 'a' * 2_001 }
it 'returns 422' do

View File

@@ -140,7 +140,7 @@ RSpec.describe Api::V1::Admin::AccountsController, type: :controller do
expect(response).to have_http_status(200)
end
it 'unsensitives account' do
it 'unsensitizes account' do
expect(account.reload.sensitized?).to be false
end
end

View File

@@ -56,7 +56,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control
Fabricate(:favourite, status: status)
end
it 'returns http unautharized' do
it 'returns http unauthorized' do
get :index, params: { status_id: status.id }
expect(response).to have_http_status(404)
end

View File

@@ -56,7 +56,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll
Fabricate(:status, reblog_of_id: status.id)
end
it 'returns http unautharized' do
it 'returns http unauthorized' do
get :index, params: { status_id: status.id }
expect(response).to have_http_status(404)
end

View File

@@ -130,7 +130,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
let(:status) { Fabricate(:status, account: user.account, visibility: :private) }
describe 'GET #show' do
it 'returns http unautharized' do
it 'returns http unauthorized' do
get :show, params: { id: status.id }
expect(response).to have_http_status(404)
end
@@ -141,7 +141,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
Fabricate(:status, account: user.account, thread: status)
end
it 'returns http unautharized' do
it 'returns http unauthorized' do
get :context, params: { id: status.id }
expect(response).to have_http_status(404)
end

View File

@@ -191,30 +191,30 @@ describe ApplicationController, type: :controller do
controller do
before_action :require_admin!
def sucesss
def success
head 200
end
end
before do
routes.draw { get 'sucesss' => 'anonymous#sucesss' }
routes.draw { get 'success' => 'anonymous#success' }
end
it 'returns a 403 if current user is not admin' do
sign_in(Fabricate(:user, admin: false))
get 'sucesss'
get 'success'
expect(response).to have_http_status(403)
end
it 'returns a 403 if current user is only a moderator' do
sign_in(Fabricate(:user, moderator: true))
get 'sucesss'
get 'success'
expect(response).to have_http_status(403)
end
it 'does nothing if current user is admin' do
sign_in(Fabricate(:user, admin: true))
get 'sucesss'
get 'success'
expect(response).to have_http_status(200)
end
end
@@ -223,30 +223,30 @@ describe ApplicationController, type: :controller do
controller do
before_action :require_staff!
def sucesss
def success
head 200
end
end
before do
routes.draw { get 'sucesss' => 'anonymous#sucesss' }
routes.draw { get 'success' => 'anonymous#success' }
end
it 'returns a 403 if current user is not admin or moderator' do
sign_in(Fabricate(:user, admin: false, moderator: false))
get 'sucesss'
get 'success'
expect(response).to have_http_status(403)
end
it 'does nothing if current user is moderator' do
sign_in(Fabricate(:user, moderator: true))
get 'sucesss'
get 'success'
expect(response).to have_http_status(200)
end
it 'does nothing if current user is admin' do
sign_in(Fabricate(:user, admin: true))
get 'sucesss'
get 'success'
expect(response).to have_http_status(200)
end
end

View File

@@ -103,7 +103,7 @@ describe FollowerAccountsController do
context 'when account hides their network' do
before do
alice.user.settings.hide_network = true
alice.update(hide_collections: true)
end
it 'returns followers count' do

View File

@@ -103,7 +103,7 @@ describe FollowingAccountsController do
context 'when account hides their network' do
before do
alice.user.settings.hide_network = true
alice.update(hide_collections: true)
end
it 'returns followers count' do

View File

@@ -5,7 +5,7 @@ require 'rails_helper'
describe StatusesController do
render_views
shared_examples 'cachable response' do
shared_examples 'cacheable response' do
it 'does not set cookies' do
expect(response.cookies).to be_empty
expect(response.headers['Set-Cookies']).to be nil
@@ -108,7 +108,7 @@ describe StatusesController do
expect(response.headers['Vary']).to eq 'Accept'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
@@ -496,7 +496,7 @@ describe StatusesController do
expect(response.headers['Vary']).to eq 'Accept'
end
it_behaves_like 'cachable response'
it_behaves_like 'cacheable response'
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'