0
0
Fork 0

Convert admin/terms_of_service/* spec controller->system (#33975)

This commit is contained in:
Matt Jankowski 2025-03-04 10:27:44 -05:00 committed by GitHub
parent e245633ffa
commit ce23342d72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 150 additions and 219 deletions

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::DistributionsController do
render_views
let(:user) { Fabricate(:admin_user) }
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

@ -1,66 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::DraftsController do
render_views
let(:user) { Fabricate(:admin_user) }
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

@ -1,66 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::GeneratesController do
render_views
let(:user) { Fabricate(:admin_user) }
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',
choice_of_law: 'New York',
},
}
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

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::PreviewsController do
render_views
let(:user) { Fabricate(:admin_user) }
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

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfService::TestsController do
render_views
let(:user) { Fabricate(:admin_user) }
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

@ -1,21 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::TermsOfServiceController do
render_views
let(:user) { Fabricate(:admin_user) }
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