Merge commit '55e7c08a83547424024bac311d5459cb82cf6dae' into glitch-soc/merge-upstream

Conflicts:
- `app/models/user_settings.rb`:
  Upstream added a constraint on a setting textually close
  to glitch-soc-only settings.
  Applied upstream's change.
- `lib/sanitize_ext/sanitize_config.rb`:
  Upstream added support for the `translate` attribute on a few elements,
  where glitch-soc had a different set of allowed elements and attributes.
  Extended glitch-soc's allowed attributes with `translate` as upstream did.
- `spec/validators/status_length_validator_spec.rb`:
  Upstream refactored to use RSpec's `instance_double` instead of `double`,
  but glitch-soc had changes to tests due to configurable max toot chars.
  Applied upstream's changes while keeping tests against configurable max
  toot chars.
This commit is contained in:
Claire
2023-06-25 12:02:52 +02:00
117 changed files with 1235 additions and 862 deletions

View File

@ -23,7 +23,8 @@ RSpec.describe Admin::ChangeEmailsController do
describe 'GET #update' do
before do
allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
allow(UserMailer).to receive(:confirmation_instructions)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
end
it 'returns http success' do

View File

@ -38,7 +38,7 @@ RSpec.describe Admin::ConfirmationsController do
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
before do
allow(UserMailer).to receive(:confirmation_instructions) { double(:email, deliver_later: nil) }
allow(UserMailer).to receive(:confirmation_instructions) { instance_double(ActionMailer::MessageDelivery, deliver_later: nil) }
end
context 'when email is not confirmed' do

View File

@ -19,7 +19,8 @@ RSpec.describe Admin::Disputes::AppealsController do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
allow(UserMailer).to receive(:appeal_approved).and_return(double('email', deliver_later: nil))
allow(UserMailer).to receive(:appeal_approved)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :approve, params: { id: appeal.id }
end
@ -40,7 +41,8 @@ RSpec.describe Admin::Disputes::AppealsController do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
allow(UserMailer).to receive(:appeal_rejected).and_return(double('email', deliver_later: nil))
allow(UserMailer).to receive(:appeal_rejected)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :reject, params: { id: appeal.id }
end

View File

@ -37,7 +37,7 @@ RSpec.describe Admin::DomainAllowsController do
describe 'DELETE #destroy' do
it 'disallows the domain' do
service = double(call: true)
service = instance_double(UnallowDomainService, call: true)
allow(UnallowDomainService).to receive(:new).and_return(service)
domain_allow = Fabricate(:domain_allow)
delete :destroy, params: { id: domain_allow.id }

View File

@ -213,7 +213,7 @@ RSpec.describe Admin::DomainBlocksController do
describe 'DELETE #destroy' do
it 'unblocks the domain' do
service = double(call: true)
service = instance_double(UnblockDomainService, call: true)
allow(UnblockDomainService).to receive(:new).and_return(service)
domain_block = Fabricate(:domain_block)
delete :destroy, params: { id: domain_block.id }

View File

@ -62,17 +62,10 @@ describe Admin::Reports::ActionsController do
end
shared_examples 'common behavior' do
it 'closes the report' do
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
end
it 'closes the report and redirects' do
expect { subject }.to mark_report_action_taken.and create_target_account_strike
it 'creates a strike with the expected text' do
expect { subject }.to change { report.target_account.strikes.count }.by(1)
expect(report.target_account.strikes.last.text).to eq text
end
it 'redirects' do
subject
expect(response).to redirect_to(admin_reports_path)
end
@ -81,20 +74,21 @@ describe Admin::Reports::ActionsController do
{ report_id: report.id }
end
it 'closes the report' do
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
end
it 'closes the report and redirects' do
expect { subject }.to mark_report_action_taken.and create_target_account_strike
it 'creates a strike with the expected text' do
expect { subject }.to change { report.target_account.strikes.count }.by(1)
expect(report.target_account.strikes.last.text).to eq ''
end
it 'redirects' do
subject
expect(response).to redirect_to(admin_reports_path)
end
end
def mark_report_action_taken
change { report.reload.action_taken? }.from(false).to(true)
end
def create_target_account_strike
change { report.target_account.strikes.count }.by(1)
end
end
shared_examples 'all action types' do

View File

@ -48,7 +48,7 @@ describe Admin::WebhooksController do
end
context 'with an existing record' do
let!(:webhook) { Fabricate :webhook }
let!(:webhook) { Fabricate(:webhook, events: ['account.created', 'report.created']) }
describe 'GET #show' do
it 'returns http success and renders view' do
@ -82,7 +82,7 @@ describe Admin::WebhooksController do
end.to_not change(webhook, :url)
expect(response).to have_http_status(:success)
expect(response).to render_template(:show)
expect(response).to render_template(:edit)
end
end

View File

@ -1,55 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Admin::AccountActionsController do
render_views
let(:role) { UserRole.find_by(name: 'Moderator') }
let(:user) { Fabricate(:user, role: role) }
let(:scopes) { 'admin:read admin:write' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
context 'with type of disable' do
before do
post :create, params: { account_id: account.id, type: 'disable' }
end
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
it_behaves_like 'forbidden for wrong role', ''
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'performs action against account' do
expect(account.reload.user_disabled?).to be true
end
it 'logs action' do
log_item = Admin::ActionLog.last
expect(log_item).to_not be_nil
expect(log_item.action).to eq :disable
expect(log_item.account_id).to eq user.account_id
expect(log_item.target_id).to eq account.user.id
end
end
context 'with no type' do
before do
post :create, params: { account_id: account.id }
end
it 'returns http unprocessable entity' do
expect(response).to have_http_status(422)
end
end
end
end

View File

@ -18,6 +18,7 @@ RSpec.describe Api::V1::ConversationsController do
before do
PostStatusService.new.call(other.account, text: 'Hey @alice', visibility: 'direct')
PostStatusService.new.call(user.account, text: 'Hey, nobody here', visibility: 'direct')
end
it 'returns http success' do
@ -33,7 +34,8 @@ RSpec.describe Api::V1::ConversationsController do
it 'returns conversations' do
get :index
json = body_as_json
expect(json.size).to eq 1
expect(json.size).to eq 2
expect(json[0][:accounts].size).to eq 1
end
context 'with since_id' do
@ -41,7 +43,7 @@ RSpec.describe Api::V1::ConversationsController do
it 'returns conversations' do
get :index, params: { since_id: Mastodon::Snowflake.id_at(1.hour.ago, with_random: false) }
json = body_as_json
expect(json.size).to eq 1
expect(json.size).to eq 2
end
end

View File

@ -67,24 +67,13 @@ RSpec.describe Api::V1::NotificationsController do
get :index
end
it 'returns http success' do
it 'returns expected notification types', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'includes reblog' do
expect(body_as_json.pluck(:type)).to include 'reblog'
end
it 'includes mention' do
expect(body_as_json.pluck(:type)).to include 'mention'
end
it 'includes favourite' do
expect(body_as_json.pluck(:type)).to include 'favourite'
end
it 'includes follow' do
expect(body_as_json.pluck(:type)).to include 'follow'
expect(body_json_types).to include 'reblog'
expect(body_json_types).to include 'mention'
expect(body_json_types).to include 'favourite'
expect(body_json_types).to include 'follow'
end
end
@ -93,12 +82,14 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { account_id: third.account.id }
end
it 'returns http success' do
it 'returns only notifications from specified user', :aggregate_failures do
expect(response).to have_http_status(200)
expect(body_json_account_ids.uniq).to eq [third.account.id.to_s]
end
it 'returns only notifications from specified user' do
expect(body_as_json.map { |x| x[:account][:id] }.uniq).to eq [third.account.id.to_s]
def body_json_account_ids
body_as_json.map { |x| x[:account][:id] }
end
end
@ -107,27 +98,23 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { account_id: 'foo' }
end
it 'returns http success' do
it 'returns nothing', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns nothing' do
expect(body_as_json.size).to eq 0
end
end
describe 'with excluded_types param' do
describe 'with exclude_types param' do
before do
get :index, params: { exclude_types: %w(mention) }
end
it 'returns http success' do
it 'returns everything but excluded type', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns everything but excluded type' do
expect(body_as_json.size).to_not eq 0
expect(body_as_json.pluck(:type).uniq).to_not include 'mention'
expect(body_json_types.uniq).to_not include 'mention'
end
end
@ -136,13 +123,15 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { types: %w(mention) }
end
it 'returns http success' do
it 'returns only requested type', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns only requested type' do
expect(body_as_json.pluck(:type).uniq).to eq ['mention']
expect(body_json_types.uniq).to eq ['mention']
end
end
def body_json_types
body_as_json.pluck(:type)
end
end
end

View File

@ -23,7 +23,8 @@ RSpec.describe Api::V1::ReportsController do
let(:rule_ids) { nil }
before do
allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))
allow(AdminMailer).to receive(:new_report)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :create, params: { status_ids: [status.id], account_id: target_account.id, comment: 'reasons', category: category, rule_ids: rule_ids, forward: forward }
end

View File

@ -23,6 +23,7 @@ describe Api::V1::Statuses::HistoriesController do
it 'returns http success' do
expect(response).to have_http_status(200)
expect(body_as_json.size).to_not be 0
end
end
end

View File

@ -1,37 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::SuggestionsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read write') }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
let(:bob) { Fabricate(:account) }
let(:jeff) { Fabricate(:account) }
before do
PotentialFriendshipTracker.record(user.account_id, bob.id, :reblog)
PotentialFriendshipTracker.record(user.account_id, jeff.id, :favourite)
get :index
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns accounts' do
json = body_as_json
expect(json.size).to be >= 1
expect(json.pluck(:id)).to include(*[bob, jeff].map { |i| i.id.to_s })
end
end
end

View File

@ -1,88 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::TagsController do
render_views
let(:user) { Fabricate(:user) }
let(:scopes) { 'write:follows' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
before { allow(controller).to receive(:doorkeeper_token) { token } }
describe 'GET #show' do
before do
get :show, params: { id: name }
end
context 'with existing tag' do
let!(:tag) { Fabricate(:tag) }
let(:name) { tag.name }
it 'returns http success' do
expect(response).to have_http_status(:success)
end
end
context 'with non-existing tag' do
let(:name) { 'hoge' }
it 'returns http success' do
expect(response).to have_http_status(:success)
end
end
end
describe 'POST #follow' do
let!(:unrelated_tag) { Fabricate(:tag) }
before do
TagFollow.create!(account: user.account, tag: unrelated_tag)
post :follow, params: { id: name }
end
context 'with existing tag' do
let!(:tag) { Fabricate(:tag) }
let(:name) { tag.name }
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'creates follow' do
expect(TagFollow.where(tag: tag, account: user.account).exists?).to be true
end
end
context 'with non-existing tag' do
let(:name) { 'hoge' }
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'creates follow' do
expect(TagFollow.where(tag: Tag.find_by!(name: name), account: user.account).exists?).to be true
end
end
end
describe 'POST #unfollow' do
let!(:tag) { Fabricate(:tag, name: 'foo') }
let!(:tag_follow) { Fabricate(:tag_follow, account: user.account, tag: tag) }
before do
post :unfollow, params: { id: tag.name }
end
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'removes the follow' do
expect(TagFollow.where(tag: tag, account: user.account).exists?).to be false
end
end
end

View File

@ -55,5 +55,13 @@ RSpec.describe Api::V2::Admin::AccountsController do
end
end
end
context 'with limit param' do
let(:params) { { limit: 1 } }
it 'sets the correct pagination headers' do
expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v2_admin_accounts_url(limit: 1, max_id: admin_account.id)
end
end
end
end

View File

@ -26,7 +26,7 @@ describe Api::Web::EmbedsController do
context 'when fails to find status' do
let(:url) { 'https://host.test/oembed.html' }
let(:service_instance) { double('fetch_oembed_service') }
let(:service_instance) { instance_double(FetchOEmbedService) }
before do
allow(FetchOEmbedService).to receive(:new) { service_instance }

View File

@ -127,7 +127,8 @@ RSpec.describe Auth::SessionsController do
before do
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return(current_ip)
allow(UserMailer).to receive(:suspicious_sign_in).and_return(double('email', deliver_later!: nil))
allow(UserMailer).to receive(:suspicious_sign_in)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later!: nil))
user.update(current_sign_in_at: 1.month.ago)
post :create, params: { user: { email: user.email, password: user.password } }
end

View File

@ -28,7 +28,7 @@ describe AuthorizeInteractionsController do
end
it 'renders error when account cant be found' do
service = double
service = instance_double(ResolveAccountService)
allow(ResolveAccountService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('missing@hostname').and_return(nil)
@ -40,7 +40,7 @@ describe AuthorizeInteractionsController do
it 'sets resource from url' do
account = Fabricate(:account)
service = double
service = instance_double(ResolveURLService)
allow(ResolveURLService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('http://example.com').and_return(account)
@ -52,7 +52,7 @@ describe AuthorizeInteractionsController do
it 'sets resource from acct uri' do
account = Fabricate(:account)
service = double
service = instance_double(ResolveAccountService)
allow(ResolveAccountService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('found@hostname').and_return(account)
@ -82,7 +82,7 @@ describe AuthorizeInteractionsController do
end
it 'shows error when account not found' do
service = double
service = instance_double(ResolveAccountService)
allow(ResolveAccountService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('user@hostname').and_return(nil)
@ -94,7 +94,7 @@ describe AuthorizeInteractionsController do
it 'follows account when found' do
target_account = Fabricate(:account)
service = double
service = instance_double(ResolveAccountService)
allow(ResolveAccountService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('user@hostname').and_return(target_account)

View File

@ -14,7 +14,8 @@ RSpec.describe Disputes::AppealsController do
let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
before do
allow(AdminMailer).to receive(:new_appeal).and_return(double('email', deliver_later: nil))
allow(AdminMailer).to receive(:new_appeal)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
end

View File

@ -75,23 +75,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns public Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'public'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -100,25 +88,13 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it_behaves_like 'cacheable response'
it 'returns Content-Type header' do
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -199,23 +175,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -224,27 +188,12 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -263,23 +212,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -288,27 +225,12 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -350,23 +272,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -375,27 +285,12 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
it 'renders ActivityPub Note object successfully' do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -463,23 +358,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -488,25 +371,13 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it_behaves_like 'cacheable response'
it 'returns Content-Type header' do
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -525,23 +396,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -550,27 +409,12 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
it 'renders ActivityPub Note object successfully' do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -612,23 +456,11 @@ describe StatusesController do
context 'with HTML' do
let(:format) { 'html' }
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'renders status' do
expect(response).to render_template(:show)
expect(response.body).to include status.text
end
@ -637,27 +469,12 @@ describe StatusesController do
context 'with JSON' do
let(:format) { 'json' }
it 'returns http success' do
it 'renders ActivityPub Note object', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns private Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns Content-Type header' do
expect(response.headers['Content-Type']).to include 'application/activity+json'
end
it 'renders ActivityPub Note object' do
json = body_as_json
expect(json[:content]).to include status.text
end
@ -933,23 +750,11 @@ describe StatusesController do
get :embed, params: { account_username: status.account.username, id: status.id }
end
it 'returns http success' do
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
end
it 'returns Link header' do
expect(response.headers['Link'].to_s).to include 'activity+json'
end
it 'returns Vary header' do
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
end
it 'returns public Cache-Control header' do
expect(response.headers['Cache-Control']).to include 'public'
end
it 'renders status' do
expect(response).to render_template(:embed)
expect(response.body).to include status.text
end