Merge remote-tracking branch 'parent/main' into upstream-20240906
This commit is contained in:
commit
f18eabfe75
689 changed files with 4369 additions and 2434 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountsIndex do
|
||||
RSpec.describe AccountsIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PublicStatusesIndex do
|
||||
RSpec.describe PublicStatusesIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe StatusesIndex do
|
||||
RSpec.describe StatusesIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe TagsIndex do
|
||||
RSpec.describe TagsIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Rack::Attack, type: :request do
|
||||
RSpec.describe Rack::Attack, type: :request do
|
||||
def app
|
||||
Rails.application
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::ClaimsController do
|
||||
RSpec.describe ActivityPub::ClaimsController do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'POST #create' do
|
||||
|
|
|
@ -25,10 +25,10 @@ RSpec.describe ActivityPub::CollectionsController do
|
|||
context 'without signature' do
|
||||
let(:remote_account) { nil }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
|
||||
it 'returns http success and correct media type and correct items' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
|
||||
expect(body_as_json[:orderedItems])
|
||||
|
@ -64,10 +64,11 @@ RSpec.describe ActivityPub::CollectionsController do
|
|||
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
|
||||
context 'when getting a featured resource' do
|
||||
it_behaves_like 'cacheable response'
|
||||
|
||||
it 'returns http success and correct media type and expected items' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
|
||||
expect(body_as_json[:orderedItems])
|
||||
|
|
|
@ -25,10 +25,11 @@ RSpec.describe ActivityPub::OutboxesController do
|
|||
context 'with page not requested' do
|
||||
let(:page) { nil }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
|
||||
it 'returns http success and correct media type and headers and items count' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response.headers['Vary']).to be_nil
|
||||
expect(body[:totalItems]).to eq 4
|
||||
|
@ -59,10 +60,11 @@ RSpec.describe ActivityPub::OutboxesController do
|
|||
context 'with page requested' do
|
||||
let(:page) { 'true' }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
|
||||
it 'returns http success and correct media type and vary header and items' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
expect(response.headers['Vary']).to include 'Signature'
|
||||
|
||||
|
|
|
@ -68,10 +68,11 @@ RSpec.describe ActivityPub::RepliesController do
|
|||
let(:parent_visibility) { :public }
|
||||
let(:page_json) { body_as_json[:first] }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
|
||||
it 'returns http success and correct media type' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
|
||||
expect(response.media_type).to eq 'application/activity+json'
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::AccountActionsController do
|
||||
RSpec.describe Admin::AccountActionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -40,15 +40,16 @@ RSpec.describe Admin::AccountsController do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(assigns(:accounts))
|
||||
.to have_attributes(
|
||||
count: eq(1),
|
||||
klass: be(Account)
|
||||
)
|
||||
expect(accounts_table_rows.size)
|
||||
.to eq(1)
|
||||
expect(AccountFilter)
|
||||
.to have_received(:new)
|
||||
.with(hash_including(params))
|
||||
end
|
||||
|
||||
def accounts_table_rows
|
||||
response.parsed_body.css('table.accounts-table tr')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::ActionLogsController do
|
||||
RSpec.describe Admin::ActionLogsController do
|
||||
render_views
|
||||
|
||||
# Action logs typically cause issues when their targets are not in the database
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::AnnouncementsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'returns http success and renders new' do
|
||||
get :new
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response).to render_template(:new)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
let(:announcement) { Fabricate(:announcement) }
|
||||
|
||||
it 'returns http success and renders edit' do
|
||||
get :edit, params: { id: announcement.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response).to render_template(:edit)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'creates a new announcement and redirects' do
|
||||
expect do
|
||||
post :create, params: { announcement: { text: 'The announcement message.' } }
|
||||
end.to change(Announcement, :count).by(1)
|
||||
|
||||
expect(response).to redirect_to(admin_announcements_path)
|
||||
expect(flash.notice).to match(I18n.t('admin.announcements.published_msg'))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
let(:announcement) { Fabricate(:announcement, text: 'Original text') }
|
||||
|
||||
it 'updates an announcement and redirects' do
|
||||
put :update, params: { id: announcement.id, announcement: { text: 'Updated text.' } }
|
||||
|
||||
expect(response).to redirect_to(admin_announcements_path)
|
||||
expect(flash.notice).to match(I18n.t('admin.announcements.updated_msg'))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let!(:announcement) { Fabricate(:announcement, text: 'Original text') }
|
||||
|
||||
it 'destroys an announcement and redirects' do
|
||||
expect do
|
||||
delete :destroy, params: { id: announcement.id }
|
||||
end.to change(Announcement, :count).by(-1)
|
||||
|
||||
expect(response).to redirect_to(admin_announcements_path)
|
||||
expect(flash.notice).to match(I18n.t('admin.announcements.destroyed_msg'))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #publish' do
|
||||
subject { post :publish, params: { id: announcement.id } }
|
||||
|
||||
let(:announcement) { Fabricate(:announcement, published_at: nil) }
|
||||
|
||||
it 'marks announcement published' do
|
||||
subject
|
||||
|
||||
expect(announcement.reload).to be_published
|
||||
expect(response).to redirect_to admin_announcements_path
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #unpublish' do
|
||||
subject { post :unpublish, params: { id: announcement.id } }
|
||||
|
||||
let(:announcement) { Fabricate(:announcement, published_at: 4.days.ago) }
|
||||
|
||||
it 'marks announcement as not published' do
|
||||
subject
|
||||
|
||||
expect(announcement.reload).to_not be_published
|
||||
expect(response).to redirect_to admin_announcements_path
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::BaseController do
|
||||
RSpec.describe Admin::BaseController do
|
||||
controller do
|
||||
def success
|
||||
authorize :dashboard, :index?
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::CustomEmojisController do
|
||||
RSpec.describe Admin::CustomEmojisController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::DashboardController do
|
||||
RSpec.describe Admin::DashboardController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
|
|
|
@ -13,7 +13,6 @@ RSpec.describe Admin::DomainAllowsController do
|
|||
it 'assigns a new domain allow' do
|
||||
get :new
|
||||
|
||||
expect(assigns(:domain_allow)).to be_instance_of(DomainAllow)
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@ RSpec.describe Admin::DomainBlocksController do
|
|||
it 'assigns a new domain block' do
|
||||
get :new
|
||||
|
||||
expect(assigns(:domain_block)).to be_instance_of(DomainBlock)
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
@ -171,7 +170,6 @@ RSpec.describe Admin::DomainBlocksController do
|
|||
it 'returns http success' do
|
||||
get :edit, params: { id: domain_block.id }
|
||||
|
||||
expect(assigns(:domain_block)).to be_instance_of(DomainBlock)
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,10 +43,6 @@ RSpec.describe Admin::ExportDomainBlocksController do
|
|||
post :import, params: { admin_import: { data: fixture_file_upload('domain_blocks.csv') } }
|
||||
end
|
||||
|
||||
it 'renders page with expected domain blocks' do
|
||||
expect(assigns(:domain_blocks).map { |block| [block.domain, block.severity.to_sym] }).to contain_exactly(['bad.domain', :silence], ['worse.domain', :suspend], ['reject.media', :noop], ['little.spam', :noop])
|
||||
end
|
||||
|
||||
it 'renders page with extended domain blocks' do
|
||||
expect(assigns(:domain_blocks).map { |block| [block.domain, block.reject_favourite, block.reject_friend] }).to contain_exactly(
|
||||
['bad.domain', false, false],
|
||||
|
@ -56,7 +52,8 @@ RSpec.describe Admin::ExportDomainBlocksController do
|
|||
)
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'renders page with expected domain blocks and returns http success' do
|
||||
expect(mapped_batch_table_rows).to contain_exactly(['bad.domain', :silence], ['worse.domain', :suspend], ['reject.media', :noop], ['little.spam', :noop])
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
@ -66,14 +63,19 @@ RSpec.describe Admin::ExportDomainBlocksController do
|
|||
post :import, params: { admin_import: { data: fixture_file_upload('domain_blocks_list.txt') } }
|
||||
end
|
||||
|
||||
it 'renders page with expected domain blocks' do
|
||||
expect(assigns(:domain_blocks).map { |block| [block.domain, block.severity.to_sym] }).to contain_exactly(['bad.domain', :suspend], ['worse.domain', :suspend], ['reject.media', :suspend])
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
it 'renders page with expected domain blocks and returns http success' do
|
||||
expect(mapped_batch_table_rows).to contain_exactly(['bad.domain', :suspend], ['worse.domain', :suspend], ['reject.media', :suspend])
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
def mapped_batch_table_rows
|
||||
batch_table_rows.map { |row| [row.at_css('[id$=_domain]')['value'], row.at_css('[id$=_severity]')['value'].to_sym] }
|
||||
end
|
||||
|
||||
def batch_table_rows
|
||||
response.parsed_body.css('body div.batch-table__row')
|
||||
end
|
||||
end
|
||||
|
||||
it 'displays error on no file selected' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::FollowRecommendationsController do
|
||||
RSpec.describe Admin::FollowRecommendationsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -28,12 +28,15 @@ RSpec.describe Admin::InstancesController do
|
|||
it 'renders instances' do
|
||||
get :index, params: { page: 2 }
|
||||
|
||||
instances = assigns(:instances).to_a
|
||||
expect(instances.size).to eq 1
|
||||
expect(instances[0].domain).to eq 'less.popular'
|
||||
expect(instance_directory_links.size).to eq(1)
|
||||
expect(instance_directory_links.first.text.strip).to match('less.popular')
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
def instance_directory_links
|
||||
response.parsed_body.css('div.directory__tag a')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::InvitesController do
|
||||
RSpec.describe Admin::InvitesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
@ -18,7 +18,8 @@ describe Admin::InvitesController do
|
|||
|
||||
it 'renders index page' do
|
||||
expect(subject).to render_template :index
|
||||
expect(assigns(:invites)).to include invite
|
||||
expect(response.body)
|
||||
.to include(invite.code)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::IpBlocksController do
|
||||
RSpec.describe Admin::IpBlocksController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::RelationshipsController do
|
||||
RSpec.describe Admin::RelationshipsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::RelaysController do
|
||||
RSpec.describe Admin::RelaysController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::ReportNotesController do
|
||||
RSpec.describe Admin::ReportNotesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Reports::ActionsController do
|
||||
RSpec.describe Admin::Reports::ActionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::ReportsController do
|
||||
RSpec.describe Admin::ReportsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
@ -13,39 +13,39 @@ describe Admin::ReportsController do
|
|||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success with no filters' do
|
||||
specified = Fabricate(:report, action_taken_at: nil)
|
||||
Fabricate(:report, action_taken_at: Time.now.utc)
|
||||
specified = Fabricate(:report, action_taken_at: nil, comment: 'First report')
|
||||
other = Fabricate(:report, action_taken_at: Time.now.utc, comment: 'Second report')
|
||||
|
||||
get :index
|
||||
|
||||
reports = assigns(:reports).to_a
|
||||
expect(reports.size).to eq 1
|
||||
expect(reports[0]).to eq specified
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(specified.comment)
|
||||
.and not_include(other.comment)
|
||||
end
|
||||
|
||||
it 'returns http success with resolved filter' do
|
||||
specified = Fabricate(:report, action_taken_at: Time.now.utc)
|
||||
Fabricate(:report, action_taken_at: nil)
|
||||
specified = Fabricate(:report, action_taken_at: Time.now.utc, comment: 'First report')
|
||||
other = Fabricate(:report, action_taken_at: nil, comment: 'Second report')
|
||||
|
||||
get :index, params: { resolved: '1' }
|
||||
|
||||
reports = assigns(:reports).to_a
|
||||
expect(reports.size).to eq 1
|
||||
expect(reports[0]).to eq specified
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(specified.comment)
|
||||
.and not_include(other.comment)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'renders report' do
|
||||
report = Fabricate(:report)
|
||||
report = Fabricate(:report, comment: 'A big problem')
|
||||
|
||||
get :show, params: { id: report }
|
||||
|
||||
expect(assigns(:report)).to eq report
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(report.comment)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::RolesController do
|
||||
RSpec.describe Admin::RolesController do
|
||||
render_views
|
||||
|
||||
let(:permissions) { UserRole::Flags::NONE }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::RulesController do
|
||||
RSpec.describe Admin::RulesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Settings::AboutController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'updates the settings' do
|
||||
put :update, params: { form_admin_settings: { site_extended_description: 'new site description' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_about_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Settings::AppearanceController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'updates the settings' do
|
||||
put :update, params: { form_admin_settings: { custom_css: 'html { display: inline; }' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_appearance_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,14 +10,6 @@ RSpec.describe Admin::Settings::BrandingController do
|
|||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'cannot create a setting value for a non-admin key' do
|
||||
expect(Setting.new_setting_key).to be_blank
|
||||
|
@ -27,15 +19,6 @@ RSpec.describe Admin::Settings::BrandingController do
|
|||
expect(response).to redirect_to(admin_settings_branding_path)
|
||||
expect(Setting.new_setting_key).to be_nil
|
||||
end
|
||||
|
||||
it 'creates a settings value that didnt exist before for eligible key' do
|
||||
expect(Setting.site_short_description).to be_blank
|
||||
|
||||
patch :update, params: { form_admin_settings: { site_short_description: 'New key value' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_branding_path)
|
||||
expect(Setting.site_short_description).to eq 'New key value'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Settings::ContentRetentionController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'updates the settings' do
|
||||
put :update, params: { form_admin_settings: { media_cache_retention_period: '2' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_content_retention_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Settings::DiscoveryController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'updates the settings' do
|
||||
put :update, params: { form_admin_settings: { trends: '1' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_discovery_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Settings::RegistrationsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
it 'updates the settings' do
|
||||
put :update, params: { form_admin_settings: { registrations_mode: 'open' } }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_registrations_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::SiteUploadsController do
|
||||
RSpec.describe Admin::SiteUploadsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::StatusesController do
|
||||
RSpec.describe Admin::StatusesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Trends::Links::PreviewCardProvidersController do
|
||||
RSpec.describe Admin::Trends::Links::PreviewCardProvidersController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Trends::LinksController do
|
||||
RSpec.describe Admin::Trends::LinksController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Trends::StatusesController do
|
||||
RSpec.describe Admin::Trends::StatusesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Trends::TagsController do
|
||||
RSpec.describe Admin::Trends::TagsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Users::RolesController do
|
||||
RSpec.describe Admin::Users::RolesController do
|
||||
render_views
|
||||
|
||||
let(:current_role) { UserRole.create(name: 'Foo', permissions: UserRole::FLAGS[:manage_roles], position: 10) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
require 'webauthn/fake_client'
|
||||
|
||||
describe Admin::Users::TwoFactorAuthenticationsController do
|
||||
RSpec.describe Admin::Users::TwoFactorAuthenticationsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::WarningPresetsController do
|
||||
RSpec.describe Admin::WarningPresetsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Webhooks::SecretsController do
|
||||
RSpec.describe Admin::Webhooks::SecretsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::WebhooksController do
|
||||
RSpec.describe Admin::WebhooksController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::BaseController do
|
||||
RSpec.describe Api::BaseController do
|
||||
controller do
|
||||
def success
|
||||
head 200
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::Web::PushSubscriptionsController do
|
||||
RSpec.describe Api::Web::PushSubscriptionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ApplicationController do
|
||||
RSpec.describe ApplicationController do
|
||||
controller do
|
||||
def success
|
||||
head 200
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Auth::ChallengesController do
|
||||
RSpec.describe Auth::ChallengesController do
|
||||
render_views
|
||||
|
||||
let(:password) { 'foobar12345' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Auth::ConfirmationsController do
|
||||
RSpec.describe Auth::ConfirmationsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #new' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Auth::PasswordsController do
|
||||
RSpec.describe Auth::PasswordsController do
|
||||
include Devise::Test::ControllerHelpers
|
||||
|
||||
describe 'GET #new' do
|
||||
|
|
|
@ -342,7 +342,7 @@ RSpec.describe Auth::RegistrationsController do
|
|||
end
|
||||
|
||||
def username_error_text
|
||||
Nokogiri::Slop(response.body).css('.user_account_username .error').text
|
||||
response.parsed_body.css('.user_account_username .error').text
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Auth::SetupController do
|
||||
RSpec.describe Auth::SetupController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AuthorizeInteractionsController do
|
||||
RSpec.describe AuthorizeInteractionsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
@ -46,8 +46,9 @@ describe AuthorizeInteractionsController do
|
|||
|
||||
get :show, params: { acct: 'http://example.com' }
|
||||
|
||||
expect(response).to have_http_status(302)
|
||||
expect(assigns(:resource)).to eq account
|
||||
expect(response)
|
||||
.to have_http_status(302)
|
||||
.and redirect_to(web_url("@#{account.pretty_acct}"))
|
||||
end
|
||||
|
||||
it 'sets resource from acct uri' do
|
||||
|
@ -58,8 +59,9 @@ describe AuthorizeInteractionsController do
|
|||
|
||||
get :show, params: { acct: 'acct:found@hostname' }
|
||||
|
||||
expect(response).to have_http_status(302)
|
||||
expect(assigns(:resource)).to eq account
|
||||
expect(response)
|
||||
.to have_http_status(302)
|
||||
.and redirect_to(web_url("@#{account.pretty_acct}"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountControllerConcern do
|
||||
RSpec.describe AccountControllerConcern do
|
||||
controller(ApplicationController) do
|
||||
include AccountControllerConcern
|
||||
|
||||
def success
|
||||
head 200
|
||||
render plain: @account.username # rubocop:disable RSpec/InstanceVariable
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,19 +51,15 @@ describe AccountControllerConcern do
|
|||
context 'when account is not suspended' do
|
||||
let(:account) { Fabricate(:account, username: 'username') }
|
||||
|
||||
it 'assigns @account, returns success, and sets link headers' do
|
||||
it 'Prepares the account, returns success, and sets link headers' do
|
||||
get 'success', params: { account_username: account.username }
|
||||
|
||||
expect(assigns(:account)).to eq account
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.headers['Link'].to_s).to eq(expected_link_headers)
|
||||
end
|
||||
|
||||
def expected_link_headers
|
||||
[
|
||||
'<http://test.host/.well-known/webfinger?resource=acct%3Ausername%40cb6e6126.ngrok.io>; rel="lrdd"; type="application/jrd+json"',
|
||||
'<https://cb6e6126.ngrok.io/users/username>; rel="alternate"; type="application/activity+json"',
|
||||
].join(', ')
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_http_link_header('http://test.host/.well-known/webfinger?resource=acct%3Ausername%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json')
|
||||
.and have_http_link_header('https://cb6e6126.ngrok.io/users/username').for(rel: 'alternate', type: 'application/activity+json')
|
||||
expect(response.body)
|
||||
.to include(account.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::ErrorHandling do
|
||||
RSpec.describe Api::ErrorHandling do
|
||||
before do
|
||||
stub_const('FakeService', Class.new)
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::RateLimitHeaders do
|
||||
RSpec.describe Api::RateLimitHeaders do
|
||||
controller(ApplicationController) do
|
||||
include Api::RateLimitHeaders
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Localized do
|
||||
RSpec.describe Localized do
|
||||
controller(ApplicationController) do
|
||||
include Localized
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::ExportControllerConcern do
|
||||
RSpec.describe Settings::ExportControllerConcern do
|
||||
controller(ApplicationController) do
|
||||
include Settings::ExportControllerConcern
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe UserTrackingConcern do
|
||||
RSpec.describe UserTrackingConcern do
|
||||
controller(ApplicationController) do
|
||||
include UserTrackingConcern
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Filters::StatusesController do
|
||||
RSpec.describe Filters::StatusesController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FiltersController do
|
||||
RSpec.describe FiltersController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FollowerAccountsController do
|
||||
RSpec.describe FollowerAccountsController do
|
||||
render_views
|
||||
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FollowingAccountsController do
|
||||
RSpec.describe FollowingAccountsController do
|
||||
render_views
|
||||
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe InvitesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
Fabricate(:invite, user: user)
|
||||
end
|
||||
|
||||
context 'when everyone can invite' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole.everyone.permissions | UserRole::FLAGS[:invite_users])
|
||||
get :index
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'returns private cache control headers' do
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not everyone can invite' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole.everyone.permissions & ~UserRole::FLAGS[:invite_users])
|
||||
get :index
|
||||
end
|
||||
|
||||
it 'returns http forbidden' do
|
||||
expect(response).to have_http_status(403)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } }
|
||||
|
||||
context 'when everyone can invite' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole.everyone.permissions | UserRole::FLAGS[:invite_users])
|
||||
end
|
||||
|
||||
it 'succeeds to create a invite' do
|
||||
expect { subject }.to change(Invite, :count).by(1)
|
||||
expect(subject).to redirect_to invites_path
|
||||
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not everyone can invite' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole.everyone.permissions & ~UserRole::FLAGS[:invite_users])
|
||||
end
|
||||
|
||||
it 'returns http forbidden' do
|
||||
expect(subject).to have_http_status(403)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: invite.id } }
|
||||
|
||||
let(:invite) { Fabricate(:invite, user: user, expires_at: nil) }
|
||||
|
||||
it 'expires invite and redirects' do
|
||||
expect { subject }
|
||||
.to(change { invite.reload.expired? }.to(true))
|
||||
expect(response)
|
||||
.to redirect_to invites_path
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Oauth::AuthorizedApplicationsController do
|
||||
RSpec.describe Oauth::AuthorizedApplicationsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe RelationshipsController do
|
||||
RSpec.describe RelationshipsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::AliasesController do
|
||||
RSpec.describe Settings::AliasesController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::ApplicationsController do
|
||||
RSpec.describe Settings::ApplicationsController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::DeletesController do
|
||||
RSpec.describe Settings::DeletesController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::ExportsController do
|
||||
RSpec.describe Settings::ExportsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::FeaturedTagsController do
|
||||
RSpec.describe Settings::FeaturedTagsController do
|
||||
render_views
|
||||
|
||||
shared_examples 'authenticate user' do
|
||||
|
|
|
@ -21,9 +21,10 @@ RSpec.describe Settings::ImportsController do
|
|||
|
||||
it 'assigns the expected imports', :aggregate_failures do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(assigns(:recent_imports)).to eq [import]
|
||||
expect(assigns(:recent_imports)).to_not include(other_import)
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
expect(response.body)
|
||||
.to include("bulk_import_#{import.id}")
|
||||
.and not_include("bulk_import_#{other_import.id}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -261,7 +262,8 @@ RSpec.describe Settings::ImportsController do
|
|||
it 'does not creates an unconfirmed bulk_import', :aggregate_failures do
|
||||
expect { subject }.to_not(change { user.account.bulk_imports.count })
|
||||
|
||||
expect(assigns(:import).errors).to_not be_empty
|
||||
expect(response.body)
|
||||
.to include('field_with_errors')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::LoginActivitiesController do
|
||||
RSpec.describe Settings::LoginActivitiesController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Migration::RedirectsController do
|
||||
RSpec.describe Settings::Migration::RedirectsController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user, password: 'testtest') }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::MigrationsController do
|
||||
RSpec.describe Settings::MigrationsController do
|
||||
render_views
|
||||
|
||||
shared_examples 'authenticate user' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::PicturesController do
|
||||
RSpec.describe Settings::PicturesController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Preferences::AppearanceController do
|
||||
RSpec.describe Settings::Preferences::AppearanceController do
|
||||
render_views
|
||||
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Preferences::BaseController do
|
||||
RSpec.describe Settings::Preferences::BaseController do
|
||||
describe 'after_update_redirect_path' do
|
||||
it 'raises error when called' do
|
||||
expect { described_class.new.send(:after_update_redirect_path) }.to raise_error(/Override/)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Preferences::NotificationsController do
|
||||
RSpec.describe Settings::Preferences::NotificationsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::Preferences::OtherController do
|
||||
RSpec.describe Settings::Preferences::OtherController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, chosen_languages: []) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::SessionsController do
|
||||
RSpec.describe Settings::SessionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,18 +2,23 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
render_views
|
||||
|
||||
shared_examples 'renders :new' do
|
||||
it 'renders the new view' do
|
||||
subject
|
||||
|
||||
expect(assigns(:confirmation)).to be_instance_of Form::TwoFactorConfirmation
|
||||
expect(assigns(:provision_url)).to eq 'otpauth://totp/cb6e6126.ngrok.io:local-part%40domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io'
|
||||
expect(assigns(:qrcode)).to be_instance_of RQRCode::QRCode
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template(:new)
|
||||
expect(response.body)
|
||||
.to include(qr_code_markup)
|
||||
end
|
||||
|
||||
def qr_code_markup
|
||||
RQRCode::QRCode.new(
|
||||
'otpauth://totp/cb6e6126.ngrok.io:local-part%40domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io'
|
||||
).as_svg(padding: 0, module_size: 4)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,10 +66,10 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
|||
expect { post_create_with_options }
|
||||
.to change { user.reload.otp_secret }.to 'thisisasecretforthespecofnewview'
|
||||
|
||||
expect(assigns(:recovery_codes)).to eq otp_backup_codes
|
||||
expect(flash[:notice]).to eq 'Two-factor authentication successfully enabled'
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template('settings/two_factor_authentication/recovery_codes/index')
|
||||
expect(response.body).to include(*otp_backup_codes)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
|
||||
RSpec.describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::TwoFactorAuthentication::RecoveryCodesController do
|
||||
RSpec.describe Settings::TwoFactorAuthentication::RecoveryCodesController do
|
||||
render_views
|
||||
|
||||
describe 'POST #create' do
|
||||
|
@ -15,10 +15,11 @@ describe Settings::TwoFactorAuthentication::RecoveryCodesController do
|
|||
sign_in user, scope: :user
|
||||
post :create, session: { challenge_passed_at: Time.now.utc }
|
||||
|
||||
expect(assigns(:recovery_codes)).to eq otp_backup_codes
|
||||
expect(flash[:notice]).to eq 'Recovery codes successfully regenerated'
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response).to render_template(:index)
|
||||
expect(response.body)
|
||||
.to include(*otp_backup_codes)
|
||||
end
|
||||
|
||||
it 'redirects when not signed in' do
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
require 'webauthn/fake_client'
|
||||
|
||||
describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
|
||||
RSpec.describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Settings::TwoFactorAuthenticationMethodsController do
|
||||
RSpec.describe Settings::TwoFactorAuthenticationMethodsController do
|
||||
render_views
|
||||
|
||||
context 'when not signed in' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe StatusesController do
|
||||
RSpec.describe StatusesController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
|
@ -72,13 +72,12 @@ describe StatusesController do
|
|||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'renders ActivityPub Note object successfully', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
|
||||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
)
|
||||
|
@ -380,13 +379,11 @@ describe StatusesController do
|
|||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
|
||||
it 'renders ActivityPub Note object successfully', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
||||
expect(response.headers).to include(
|
||||
'Vary' => 'Accept, Accept-Language, Cookie',
|
||||
'Content-Type' => include('application/activity+json'),
|
||||
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
|
||||
)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TagsController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
let(:format) { 'html' }
|
||||
let(:tag) { Fabricate(:tag, name: 'test') }
|
||||
let(:tag_name) { tag&.name }
|
||||
|
||||
before do
|
||||
get :show, params: { id: tag_name, format: format }
|
||||
end
|
||||
|
||||
context 'when tag exists' do
|
||||
context 'when requested as HTML' do
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
end
|
||||
|
||||
context 'when requested as JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when tag does not exist' do
|
||||
let(:tag_name) { 'hoge' }
|
||||
|
||||
it 'returns http not found' do
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
Fabrication.manager.load_definitions if Fabrication.manager.empty?
|
||||
|
||||
Fabrication.manager.schematics.map(&:first).each do |factory_name|
|
||||
describe "The #{factory_name} factory" do
|
||||
RSpec.describe "The #{factory_name} factory" do
|
||||
it 'is able to create valid records' do
|
||||
records = Fabricate.times(2, factory_name) # Create multiple of each to uncover uniqueness issues
|
||||
expect(records).to all(be_valid)
|
||||
|
|
8
spec/fabricators/generated_annual_report_fabricator.rb
Normal file
8
spec/fabricators/generated_annual_report_fabricator.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:generated_annual_report) do
|
||||
account { Fabricate.build(:account) }
|
||||
data { { test: :data } }
|
||||
schema_version { AnnualReport::SCHEMA }
|
||||
year { sequence(:year) { |i| 2000 + i } }
|
||||
end
|
|
@ -6,7 +6,7 @@ require 'rails/generators/testing/assertions'
|
|||
|
||||
require 'generators/post_deployment_migration/post_deployment_migration_generator'
|
||||
|
||||
describe PostDeploymentMigrationGenerator, type: :generator do
|
||||
RSpec.describe PostDeploymentMigrationGenerator, type: :generator do
|
||||
include Rails::Generators::Testing::Behavior
|
||||
include Rails::Generators::Testing::Assertions
|
||||
include FileUtils
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::DashboardHelper do
|
||||
RSpec.describe Admin::DashboardHelper do
|
||||
describe 'relevant_account_timestamp' do
|
||||
context 'with an account with older sign in' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::DisputesHelper do
|
||||
RSpec.describe Admin::DisputesHelper do
|
||||
describe 'strike_action_label' do
|
||||
it 'returns html describing the appeal' do
|
||||
adam = Account.new(username: 'Adam')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::FilterHelper do
|
||||
RSpec.describe Admin::FilterHelper do
|
||||
it 'Uses filter_link_to to create filter links' do
|
||||
params = ActionController::Parameters.new(
|
||||
{ test: 'test' }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::Trends::StatusesHelper do
|
||||
RSpec.describe Admin::Trends::StatusesHelper do
|
||||
describe '.one_line_preview' do
|
||||
before do
|
||||
allow(helper).to receive(:current_user).and_return(Fabricate.build(:user))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ApplicationHelper do
|
||||
RSpec.describe ApplicationHelper do
|
||||
describe 'body_classes' do
|
||||
context 'with a body class string from a controller' do
|
||||
before { helper.extend controller_helpers }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FlashesHelper do
|
||||
RSpec.describe FlashesHelper do
|
||||
describe 'user_facing_flashes' do
|
||||
before do
|
||||
# rubocop:disable Rails/I18nLocaleTexts
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue