Merge remote-tracking branch 'parent/main' into upstream-20241216

This commit is contained in:
KMY 2024-12-16 10:14:31 +09:00
commit 3784ad273c
555 changed files with 7564 additions and 3363 deletions

View file

@ -32,15 +32,16 @@ RSpec.describe Admin::ExportDomainAllowsController do
it 'allows imported domains' do
post :import, params: { admin_import: { data: fixture_file_upload('domain_allows.csv') } }
expect(response).to redirect_to(admin_instances_path)
expect(response)
.to redirect_to(admin_instances_path)
# Header should not be imported
expect(DomainAllow.where(domain: '#domain').present?).to be(false)
# Domains should now be added
get :export, params: { format: :csv }
expect(response).to have_http_status(200)
expect(response.body).to eq(domain_allows_csv_file)
# Header row should not be imported, but domains should
expect(DomainAllow)
.to_not exist(domain: '#domain')
expect(DomainAllow)
.to exist(domain: 'good.domain')
expect(DomainAllow)
.to exist(domain: 'better.domain')
end
it 'displays error on no file selected' do

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::DistributionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
before do
sign_in user, scope: :user
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { terms_of_service_id: terms_of_service.id }
expect(response).to redirect_to(admin_terms_of_service_index_path)
end
end
end

View file

@ -0,0 +1,66 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::DraftsController 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
subject { put :update, params: params }
let!(:terms) { Fabricate :terms_of_service, published_at: nil }
context 'with publishing params' do
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'publish' } }
it 'publishes the record' do
expect { subject }
.to change(Admin::ActionLog, :count).by(1)
expect(response)
.to redirect_to(admin_terms_of_service_index_path)
expect(terms.reload.published_at)
.to_not be_nil
end
end
context 'with non publishing params' do
let(:params) { { terms_of_service: { text: 'new' }, action_type: 'save_draft' } }
it 'updates but does not publish the record' do
expect { subject }
.to_not change(Admin::ActionLog, :count)
expect(response)
.to redirect_to(admin_terms_of_service_draft_path)
expect(terms.reload.published_at)
.to be_nil
end
end
context 'with invalid params' do
let(:params) { { terms_of_service: { text: '' }, action_type: 'save_draft' } }
it 'does not update the record' do
subject
expect(response)
.to have_http_status(:success)
end
end
end
end

View file

@ -0,0 +1,65 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::GeneratesController 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 'POST #create' do
subject { post :create, params: params }
context 'with valid params' do
let(:params) do
{
terms_of_service_generator: {
admin_email: 'test@host.example',
arbitration_address: '123 Main Street',
arbitration_website: 'https://host.example',
dmca_address: '123 DMCA Ave',
dmca_email: 'dmca@host.example',
domain: 'host.example',
jurisdiction: 'Europe',
},
}
end
it 'saves new record' do
expect { subject }
.to change(TermsOfService, :count).by(1)
expect(response)
.to redirect_to(admin_terms_of_service_draft_path)
end
end
context 'with invalid params' do
let(:params) do
{
terms_of_service_generator: {
admin_email: 'what the',
},
}
end
it 'does not save new record' do
expect { subject }
.to_not change(TermsOfService, :count)
expect(response)
.to have_http_status(200)
end
end
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::HistoriesController 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
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::PreviewsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show, params: { terms_of_service_id: terms_of_service.id }
expect(response).to have_http_status(:success)
end
end
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::TestsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:terms_of_service) { Fabricate(:terms_of_service, notification_sent_at: nil) }
before do
sign_in user, scope: :user
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { terms_of_service_id: terms_of_service.id }
expect(response).to redirect_to(admin_terms_of_service_preview_path(terms_of_service))
end
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfServiceController 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
end

View file

@ -1,29 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Settings::VerificationsController do
render_views
let!(:user) { Fabricate(:user) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
before do
get :show
end
it 'returns http success with private cache control headers', :aggregate_failures do
expect(response)
.to have_http_status(200)
.and have_attributes(
headers: include(
'Cache-Control' => 'private, no-store'
)
)
end
end
end