Merge commit 'f79b96a5ef0f6c4f57eee7f44ce2579b28a22098' into glitch-soc/merge-upstream
Conflicts: - `app/lib/feed_manager.rb`: Not a real conflict, but glitch-soc has an extra `populate_direct_feed` method. Added upstream's code. - `app/models/user_settings.rb`: Not a real conflict, glitch-soc has an extra setting textually-adjacent to a setting added upstream. Added upstream's setting. - `app/serializers/initial_state_serializer.rb`: Same. - `app/services/precompute_feed_service.rb`: Not a real conflict, glitch-soc has extra code for the direct feed. Added upstream's new code for populating lists.
This commit is contained in:
commit
c85616ee3a
92 files changed
+767
-328
No files matched your search
@@ -0,0 +1,112 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Reports' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Viewing existing reports' do
|
||||
let!(:unresolved_report) { Fabricate(:report, action_taken_at: nil, comment: 'First report') }
|
||||
let!(:resolved_report) { Fabricate(:report, action_taken_at: Time.now.utc, comment: 'Second report') }
|
||||
let!(:report_note) { Fabricate :report_note, report: resolved_report, content: 'Note about resolved report' }
|
||||
|
||||
it 'Shows basic report details' do
|
||||
visit admin_reports_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(unresolved_report.comment)
|
||||
.and have_no_content(resolved_report.comment)
|
||||
|
||||
click_on I18n.t('admin.reports.resolved')
|
||||
expect(page)
|
||||
.to have_content(resolved_report.comment)
|
||||
.and have_no_content(unresolved_report.comment)
|
||||
|
||||
click_on resolved_report.comment
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: resolved_report.id))
|
||||
.and have_content(resolved_report.comment)
|
||||
.and have_content(report_note.content)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Resolving reports' do
|
||||
let!(:report) { Fabricate :report }
|
||||
|
||||
it 'resolves an open report' do
|
||||
visit admin_report_path(report)
|
||||
within '.content__heading__actions' do
|
||||
click_on I18n.t('admin.reports.mark_as_resolved')
|
||||
end
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.title'))
|
||||
.and have_content(I18n.t('admin.reports.resolved_msg'))
|
||||
|
||||
report.reload
|
||||
expect(report.action_taken_by_account)
|
||||
.to eq user.account
|
||||
expect(report)
|
||||
.to be_action_taken
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Reopening reports' do
|
||||
let!(:report) { Fabricate :report, action_taken_at: 3.days.ago }
|
||||
|
||||
it 'reopens a resolved report' do
|
||||
visit admin_report_path(report)
|
||||
within '.content__heading__actions' do
|
||||
click_on I18n.t('admin.reports.mark_as_unresolved')
|
||||
end
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
|
||||
report.reload
|
||||
expect(report.action_taken_by_account)
|
||||
.to be_nil
|
||||
expect(report)
|
||||
.to_not be_action_taken
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Assigning reports' do
|
||||
let!(:report) { Fabricate :report }
|
||||
|
||||
it 'assigns report to user and then unassigns' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
click_on I18n.t('admin.reports.assign_to_self')
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
report.reload
|
||||
expect(report.assigned_account)
|
||||
.to eq user.account
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
|
||||
click_on I18n.t('admin.reports.unassign')
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
report.reload
|
||||
expect(report.assigned_account)
|
||||
.to be_nil
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def last_action_log
|
||||
Admin::ActionLog.last
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,83 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Auth Passwords' do
|
||||
let(:user) { Fabricate :user }
|
||||
let!(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
let!(:access_token) { Fabricate(:access_token, resource_owner_id: user.id) }
|
||||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
|
||||
|
||||
describe 'Resetting a password', :inline_jobs do
|
||||
let(:new_password) { 'New.Pass.123' }
|
||||
|
||||
before { allow(Devise).to receive(:pam_authentication).and_return(false) } # Avoid the "seamless external" path
|
||||
|
||||
it 'initiates reset, sends link, resets password from form, clears data' do
|
||||
visit new_user_password_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('auth.reset_password'))
|
||||
|
||||
submit_email_reset
|
||||
expect(page)
|
||||
.to have_title(I18n.t('auth.set_new_password'))
|
||||
|
||||
set_new_password
|
||||
expect(page)
|
||||
.to have_title(I18n.t('auth.login'))
|
||||
|
||||
# Change password
|
||||
expect(User.find(user.id))
|
||||
.to be_present
|
||||
.and be_valid_password(new_password)
|
||||
|
||||
# Deactivate session
|
||||
expect(user_session_count)
|
||||
.to eq(0)
|
||||
expect { session_activation.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
||||
# Revoke tokens
|
||||
expect(user_token_count)
|
||||
.to eq(0)
|
||||
|
||||
# Remove push subs
|
||||
expect(push_subs_count)
|
||||
.to eq(0)
|
||||
expect { web_push_subscription.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
def submit_email_reset
|
||||
fill_in 'user_email', with: user.email
|
||||
click_on I18n.t('auth.reset_password')
|
||||
open_last_email
|
||||
visit_in_email(I18n.t('devise.mailer.reset_password_instructions.action'))
|
||||
end
|
||||
|
||||
def set_new_password
|
||||
fill_in 'user_password', with: new_password
|
||||
fill_in 'user_password_confirmation', with: new_password
|
||||
click_on I18n.t('auth.set_new_password')
|
||||
end
|
||||
|
||||
def user_session_count
|
||||
user
|
||||
.session_activations
|
||||
.count
|
||||
end
|
||||
|
||||
def user_token_count
|
||||
Doorkeeper::AccessToken
|
||||
.active_for(user)
|
||||
.count
|
||||
end
|
||||
|
||||
def push_subs_count
|
||||
Web::PushSubscription
|
||||
.where(user: user)
|
||||
.or(Web::PushSubscription.where(access_token: access_token))
|
||||
.count
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user