独自機能の追加などで他の部分への影響が分かるようにCI周りの修正 (#1)

* Fix EmojiFormatter failure

* Add notification_emails.warning setting default value

* Fix list spec failure and add antennas for spec response

* Fix domain block spec failure to add kb custom response

* Fix SearchQueryTransformer spec failure

* Fix Account#matches_display_name spec failure

* Fix UpdateStatusService changes mentions spec failure

* Fix RuboCop Lint

* Ignore brakeman warning

* Fix CI failure for ignore brakeman warning

* Fix migration failure

* Fix README

* Fix migration CI failure

* Fix some spec failure

* Format code for RuboCop lint failure

* Fix ESlint failure

* Fix haml-lint failure
This commit is contained in:
S.H 2023-08-07 21:38:15 +09:00 committed by GitHub
parent b5949f8e48
commit 696e4a10d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 347 additions and 113 deletions

View file

@ -38,6 +38,7 @@ linters:
- 'app/views/invites/_form.html.haml'
- 'app/views/relationships/_account.html.haml'
- 'app/views/shared/_og.html.haml'
- 'app/views/application/_sidebar.html.haml'
# Offense count: 3
IdNames:

View file

@ -7,7 +7,7 @@ kmyblue はフォーク名であり、同時に[サーバー名](https://kmy.blu
kmyblue は AGPL ライセンスで公開されているため、どなたでも自由にフォークし、このソースコードを元に自分でサーバーを立てて公開することができます。また ActivityPub に参加することもできます。サーバーkmyblueは創作作家向けのものですが、フォークとしてのkmyblueは作者の嫌いな政治に関する過激な話を取り扱うコミュニティ、創作活動の一部エロ関係含むまたは全体を否定するコミュニティなども平等にお使いいただけますし、サーバーkmyblueのルールを適用する必要もありません。
ただし kmyblue においてテストコードは飾りでしかないため、不具合が発生しても自己責任になります。既知のバグもいくつかありますし、直す予定のないものも含まれます。
テストコードは飾りですが、Lint は動いています。
テストコード、Lint どちらも動いています。
## kmyblue の強み

View file

@ -1,4 +1,5 @@
import api from '../api';
import { importFetchedAccounts } from './importer';
export const ANTENNAS_FETCH_REQUEST = 'ANTENNAS_FETCH_REQUEST';

View file

@ -1,4 +1,5 @@
import api, { getLinks } from '../api';
import { importFetchedStatuses } from './importer';
export const EMOJI_REACTED_STATUSES_FETCH_REQUEST = 'EMOJI_REACTED_STATUSES_FETCH_REQUEST';

View file

@ -1,5 +1,6 @@
import { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import emojify from '../features/emoji/emoji';
export default class EmojiView extends PureComponent {

View file

@ -33,7 +33,11 @@ export const ShortNumberRenderer: React.FC<ShortNumberProps> = ({
const customRenderer = children ?? renderer ?? null;
const displayNumber = !isHide ? <ShortNumberCounter value={shortNumber} /> : <span>-</span>;
const displayNumber = !isHide ? (
<ShortNumberCounter value={shortNumber} />
) : (
<span>-</span>
);
return (
customRenderer?.(displayNumber, pluralReady(value, division)) ??

View file

@ -1,8 +1,12 @@
import { PureComponent } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import { injectIntl } from 'react-intl';
import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import EmojiView from './emoji_view';
class EmojiReactionButton extends PureComponent {

View file

@ -1,10 +1,12 @@
import { connect } from 'react-redux';
import { makeGetAccount } from '../../../selectors';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { injectIntl } from 'react-intl';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';
import { Avatar } from '../../../components/avatar';
import { DisplayName } from '../../../components/display_name';
import { injectIntl } from 'react-intl';
import { makeGetAccount } from '../../../selectors';
const makeMapStateToProps = () => {
const getAccount = makeGetAccount();

View file

@ -1,12 +1,16 @@
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { IconButton } from '../../../components/icon_button';
import { defineMessages, injectIntl } from 'react-intl';
import { removeFromAntennaAdder, addToAntennaAdder } from '../../../actions/antennas';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';
import { Icon } from 'mastodon/components/icon';
import { removeFromAntennaAdder, addToAntennaAdder } from '../../../actions/antennas';
import { IconButton } from '../../../components/icon_button';
const messages = defineMessages({
remove: { id: 'lists.account.remove', defaultMessage: 'Remove from list' },
add: { id: 'lists.account.add', defaultMessage: 'Add to list' },

View file

@ -1,12 +1,16 @@
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { injectIntl } from 'react-intl';
import { setupAntennaAdder, resetAntennaAdder } from '../../actions/antennas';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import Antenna from './components/antenna';
import { setupAntennaAdder, resetAntennaAdder } from '../../actions/antennas';
import Account from './components/account';
import Antenna from './components/antenna';
// hack
const getOrderedAntennas = createSelector([state => state.get('antennas')], antennas => {

View file

@ -1,8 +1,10 @@
import { connect } from 'react-redux';
import TextIconButton from '../components/text_icon_button';
import { changeComposeMarkdown } from '../../../actions/compose';
import { injectIntl, defineMessages } from 'react-intl';
import { connect } from 'react-redux';
import { changeComposeMarkdown } from '../../../actions/compose';
import TextIconButton from '../components/text_icon_button';
const messages = defineMessages({
marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Markdown is enabled' },
unmarked: { id: 'compose_form.markdown.unmarked', defaultMessage: 'Markdown is disabled' },

View file

@ -1,10 +1,15 @@
import { debounce } from 'lodash';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { Helmet } from 'react-helmet';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { debounce } from 'lodash';
import { addColumn, removeColumn, moveColumn } from 'mastodon/actions/columns';
import { fetchEmojiReactedStatuses, expandEmojiReactedStatuses } from 'mastodon/actions/emoji_reactions';
import ColumnHeader from 'mastodon/components/column_header';

View file

@ -446,7 +446,6 @@ class Notification extends ImmutablePureComponent {
renderWarning (notification) {
const { intl, unread } = this.props;
console.dir(notification);
return (
<HotKeys handlers={this.getHandlers()}>

View file

@ -1,4 +1,5 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import {
ANTENNA_ADDER_RESET,
ANTENNA_ADDER_SETUP,

View file

@ -1,4 +1,5 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import {
ANTENNA_ACCOUNTS_FETCH_REQUEST,
ANTENNA_ACCOUNTS_FETCH_SUCCESS,

View file

@ -1,7 +1,8 @@
import { Map as ImmutableMap, fromJS } from 'immutable';
import {
ANTENNAS_FETCH_SUCCESS,
} from '../actions/antennas';
import { Map as ImmutableMap, fromJS } from 'immutable';
const initialState = ImmutableMap();

View file

@ -40,7 +40,7 @@ class CustomEmoji < ApplicationRecord
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode, inverse_of: false
has_many :emoji_reactions, inverse_of: :custom_emoji, dependent: :destroy
has_many :emoji_reactions, inverse_of: :custom_emoji
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set modify-date +set create-date' } }, validate_media_type: false

View file

@ -60,6 +60,7 @@ class UserSettings
setting :pending_account, default: true
setting :trends, default: true
setting :appeal, default: true
setting :warning, default: true
end
namespace :interactions do

View file

@ -43,6 +43,7 @@ class UpdateStatusService < BaseService
update_metadata!
broadcast_updates!
@status.reload
@status
rescue NoChangesSubmittedError
# For calls that result in no changes, swallow the error

View file

@ -4,7 +4,7 @@
%tbody
%tr
%td
%img{ src: media_attachment.url, class: 'image' }
%img.image{ src: media_attachment.url, alt: '' }
.detailed-status__meta
- if media_attachment.status.application
= media_attachment.status.application.name

View file

@ -45,7 +45,7 @@
%th= t('admin.statuses.favourites')
%td= friendly_number_to_human @status.favourites_count
%div.action-buttons
.action-buttons
%div
- if @account.local?
= link_to t('admin.statuses.remove_history'), remove_history_admin_account_status_path(@account.id), data: { confirm: t('admin.statuses.are_you_sure') }, method: :post, class: 'button' if can?(:warn, @account)

View file

@ -32,7 +32,7 @@
%h4= t('antennas.contexts.account')
%p.hint= t 'antennas.edit.accounts_hint'
.fields-row
.fields-row
.fields-row__column.fields-row__column-6.fields-group
= f.input :accounts_raw, wrapper: :with_label, as: :text, input_html: { rows: 5 }, label: t('antennas.edit.accounts_raw')
.fields-row__column.fields-row__column-6.fields-group
@ -40,7 +40,7 @@
%h4= t('antennas.contexts.tag')
.fields-row
.fields-row
.fields-row__column.fields-row__column-6.fields-group
= f.input :tags_raw, wrapper: :with_label, as: :text, input_html: { rows: 5 }, label: t('antennas.edit.tags_raw')
.fields-row__column.fields-row__column-6.fields-group
@ -49,7 +49,7 @@
%h4= t('antennas.contexts.keyword')
%p.hint= t 'antennas.edit.keywords_hint'
.fields-row
.fields-row
.fields-row__column.fields-row__column-6.fields-group
= f.input :keywords_raw, wrapper: :with_label, as: :text, input_html: { rows: 5 }, label: t('antennas.edit.keywords_raw')
.fields-row__column.fields-row__column-6.fields-group

View file

@ -38,7 +38,7 @@
= yield :header_tags
%script(src="https://www.googletagmanager.com/gtag/js?id=AW-11130587137" async)
%script{ src="https://www.googletagmanager.com/gtag/js?id=AW-11130587137" async }
:javascript
window.dataLayer = window.dataLayer || [];

View file

@ -78,7 +78,7 @@
.fields-group
= f.input :my_actor_type, collection: ['person', 'bot'],label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.#{item}"), content_tag(:span, I18n.t("simple_form.hints.defaults.#{item}"), class: 'hint')]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label
-#.fields-group
.fields-group
= f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, kmyblue: true, hint: t('simple_form.hints.defaults.group_allow_private_message')
.actions

View file

@ -57,6 +57,52 @@
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "874be88fedf4c680926845e9a588d3197765a6ccbfdd76466b44cc00151c612e",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/api/v1/admin/reports_controller.rb",
"line": 88,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.permit(:resolved, :account_id, :target_account_id)",
"render_path": null,
"location": {
"type": "method",
"class": "Api::V1::Admin::ReportsController",
"method": "filter_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "ab5035dd1a9f8c3a8d92fb2c37e8fe86fede4f87c91b71aa32e89c9eede602fc",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/api/v1/notifications_controller.rb",
"line": 81,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.permit(:account_id, :types => ([]), :exclude_types => ([]))",
"render_path": null,
"location": {
"type": "method",
"class": "Api::V1::NotificationsController",
"method": "browserable_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
},
{
"warning_type": "Cross-Site Scripting",
"warning_code": 4,
@ -89,8 +135,54 @@
79
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "d0511f0287aea4ed9511f5a744f880cb15af77a8ec88f81b7365b00b642cf427",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/api/v1/reports_controller.rb",
"line": 26,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.permit(:account_id, :comment, :category, :forward, :forward_to_domains => ([]), :status_ids => ([]), :rule_ids => ([]))",
"render_path": null,
"location": {
"type": "method",
"class": "Api::V1::ReportsController",
"method": "report_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "dd59382eb5fda8da4d29f5d52dc8261ed9070d3c61cecc12b8332e18448b1c11",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/api/v2/search_controller.rb",
"line": 42,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.permit(:type, :offset, :min_id, :max_id, :account_id, :following, :searchability)",
"render_path": null,
"location": {
"type": "method",
"class": "Api::V2::SearchController",
"method": "search_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
}
],
"updated": "2023-07-12 11:20:51 -0400",
"brakeman_version": "6.0.0"
"updated": "2023-07-30 22:53:30 +0900",
"brakeman_version": "6.0.1"
}

View file

@ -2,16 +2,20 @@
class AddImageSizeToCustomEmojis < ActiveRecord::Migration[6.1]
def change
change_table :custom_emojis, bulk: true do |t|
t.integer :image_width
t.integer :image_height
safety_assured do
change_table :custom_emojis, bulk: true do |t|
t.integer :image_width
t.integer :image_height
end
end
end
def down
change_table :custom_emojis, bulk: true do |t|
t.remove :image_width
t.remove :image_height
safety_assured do
change_table :custom_emojis, bulk: true do |t|
t.remove :image_width
t.remove :image_height
end
end
end
end

View file

@ -2,6 +2,8 @@
class AddSearchabilityToAccounts < ActiveRecord::Migration[6.1]
def change
add_column :accounts, :searchability, :integer, null: false, default: 0
safety_assured do
add_column :accounts, :searchability, :integer, null: false, default: 0
end
end
end

View file

@ -2,6 +2,8 @@
class AddEmojiReactionsCountToStatusStats < ActiveRecord::Migration[6.1]
def change
add_column :status_stats, :emoji_reactions_count, :integer, null: false, default: 0
safety_assured do
add_column :status_stats, :emoji_reactions_count, :integer, null: false, default: 0
end
end
end

View file

@ -2,6 +2,8 @@
class AddMarkdownToStatuses < ActiveRecord::Migration[6.1]
def change
add_column :statuses, :markdown, :boolean, default: false
safety_assured do
add_column :statuses, :markdown, :boolean, default: false
end
end
end

View file

@ -2,6 +2,8 @@
class AddMarkdownToStatusEdits < ActiveRecord::Migration[6.1]
def change
add_column :status_edits, :markdown, :boolean, default: false
safety_assured do
add_column :status_edits, :markdown, :boolean, default: false
end
end
end

View file

@ -2,6 +2,8 @@
class AddEmojiReactionsCountPerAccountToStatusStats < ActiveRecord::Migration[6.1]
def change
add_column :status_stats, :emoji_reaction_accounts_count, :integer, null: false, default: 0
safety_assured do
add_column :status_stats, :emoji_reaction_accounts_count, :integer, null: false, default: 0
end
end
end

View file

@ -2,18 +2,22 @@
class AddExcludesToAntennas < ActiveRecord::Migration[6.1]
def change
change_table :antennas, bulk: true do |t|
t.jsonb :exclude_domains
t.jsonb :exclude_accounts
t.jsonb :exclude_tags
safety_assured do
change_table :antennas, bulk: true do |t|
t.jsonb :exclude_domains
t.jsonb :exclude_accounts
t.jsonb :exclude_tags
end
end
end
def down
change_table :antennas, bulk: true do |t|
t.remove :exclude_domains
t.remove :exclude_accounts
t.remove :exclude_tags
safety_assured do
change_table :antennas, bulk: true do |t|
t.remove :exclude_domains
t.remove :exclude_accounts
t.remove :exclude_tags
end
end
end
end

View file

@ -2,24 +2,28 @@
class AddRejectSendingToDomainBlocks < ActiveRecord::Migration[6.1]
def change
change_table :domain_blocks, bulk: true do |t|
t.boolean :reject_send_not_public_searchability, null: false, default: false
t.boolean :reject_send_unlisted_dissubscribable, null: false, default: false
t.boolean :reject_send_public_unlisted, null: false, default: false
t.boolean :reject_send_dissubscribable, null: false, default: false
t.boolean :reject_send_media, null: false, default: false
t.boolean :reject_send_sensitive, null: false, default: false
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.boolean :reject_send_not_public_searchability, null: false, default: false
t.boolean :reject_send_unlisted_dissubscribable, null: false, default: false
t.boolean :reject_send_public_unlisted, null: false, default: false
t.boolean :reject_send_dissubscribable, null: false, default: false
t.boolean :reject_send_media, null: false, default: false
t.boolean :reject_send_sensitive, null: false, default: false
end
end
end
def down
change_table :domain_blocks, bulk: true do |t|
t.remove :reject_send_not_public_searchability
t.remove :reject_send_unlisted_dissubscribable
t.remove :reject_send_public_unlisted
t.remove :reject_send_dissubscribable
t.remove :reject_send_media
t.remove :reject_send_sensitive
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.remove :reject_send_not_public_searchability
t.remove :reject_send_unlisted_dissubscribable
t.remove :reject_send_public_unlisted
t.remove :reject_send_dissubscribable
t.remove :reject_send_media
t.remove :reject_send_sensitive
end
end
end
end

View file

@ -2,18 +2,22 @@
class AddSomeToDomainBlocks < ActiveRecord::Migration[6.1]
def change
change_table :domain_blocks, bulk: true do |t|
t.boolean :reject_hashtag, null: false, default: false
t.boolean :reject_straight_follow, null: false, default: false
t.boolean :reject_new_follow, null: false, default: false
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.boolean :reject_hashtag, null: false, default: false
t.boolean :reject_straight_follow, null: false, default: false
t.boolean :reject_new_follow, null: false, default: false
end
end
end
def down
change_table :domain_blocks, bulk: true do |t|
t.remove :reject_hashtag
t.remove :reject_straight_follow
t.remove :reject_new_follow
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.remove :reject_hashtag
t.remove :reject_straight_follow
t.remove :reject_new_follow
end
end
end
end

View file

@ -2,16 +2,20 @@
class AddHiddenToDomainBlocks < ActiveRecord::Migration[6.1]
def change
change_table :domain_blocks, bulk: true do |t|
t.boolean :hidden, null: false, default: false
t.boolean :hidden_anonymous, null: false, default: false
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.boolean :hidden, null: false, default: false
t.boolean :hidden_anonymous, null: false, default: false
end
end
end
def down
change_table :domain_blocks, bulk: true do |t|
t.remove :hidden
t.remove :hidden_anonymous
safety_assured do
change_table :domain_blocks, bulk: true do |t|
t.remove :hidden
t.remove :hidden_anonymous
end
end
end
end

View file

@ -2,6 +2,8 @@
class AddEmojiReactionStreamingToAccounts < ActiveRecord::Migration[6.1]
def change
add_column :accounts, :stop_emoji_reaction_streaming, :boolean, default: false
safety_assured do
add_column :accounts, :stop_emoji_reaction_streaming, :boolean, default: false
end
end
end

View file

@ -1,10 +1,23 @@
# frozen_string_literal: true
class AddRejectInvalidSubscriptionToDomainBlocks < ActiveRecord::Migration[6.1]
def change
def up
safety_assured do
remove_column :domain_blocks, :reject_send_unlisted_dissubscribable, :boolean, null: false, default: false
remove_column :domain_blocks, :reject_send_unlisted_dissubscribable
change_table :domain_blocks do |t|
t.boolean :detect_invalid_subscription, null: false, default: false
end
end
end
def down
safety_assured do
remove_column :domain_blocks, :detect_invalid_subscription
change_table :domain_blocks do |t|
t.boolean :reject_send_unlisted_dissubscribable, null: false, default: false
end
end
add_column :domain_blocks, :detect_invalid_subscription, :boolean, null: false, default: false
end
end

View file

@ -2,6 +2,10 @@
class AddRejectReplyExcludeFollowersToDomainBlocks < ActiveRecord::Migration[6.1]
def change
add_column :domain_blocks, :reject_reply_exclude_followers, :boolean, null: false, default: false
safety_assured do
change_table :domain_blocks do |t|
t.boolean :reject_reply_exclude_followers, null: false, default: false
end
end
end
end

View file

@ -2,6 +2,10 @@
class AddIsSensitiveToCustomEmojis < ActiveRecord::Migration[6.1]
def change
add_column :custom_emojis, :is_sensitive, :boolean, null: false, default: false
safety_assured do
change_table :custom_emojis do |t|
t.boolean :is_sensitive, null: false, default: false
end
end
end
end

View file

@ -26,7 +26,7 @@ RSpec.describe EmojiFormatter do
let(:text) { preformat_text(':coolcat: Beep boop') }
it 'converts the shortcode to an image tag' do
expect(subject).to match(/<img rel="emoji" draggable="false" width="16" height="16" class="emojione custom-emoji" alt=":coolcat:"/)
expect(subject).to match(/<img rel="emoji" draggable="false" height="16" class="emojione custom-emoji" style="min-width:16px;" alt=":coolcat:"/)
end
end
@ -34,7 +34,7 @@ RSpec.describe EmojiFormatter do
let(:text) { preformat_text('Beep :coolcat: boop') }
it 'converts the shortcode to an image tag' do
expect(subject).to match(/Beep <img rel="emoji" draggable="false" width="16" height="16" class="emojione custom-emoji" alt=":coolcat:"/)
expect(subject).to match(/Beep <img rel="emoji" draggable="false" height="16" class="emojione custom-emoji" style="min-width:16px;" alt=":coolcat:"/)
end
end
@ -50,7 +50,7 @@ RSpec.describe EmojiFormatter do
let(:text) { preformat_text('Beep boop :coolcat:') }
it 'converts the shortcode to an image tag' do
expect(subject).to match(/boop <img rel="emoji" draggable="false" width="16" height="16" class="emojione custom-emoji" alt=":coolcat:"/)
expect(subject).to match(/boop <img rel="emoji" draggable="false" height="16" class="emojione custom-emoji" style="min-width:16px;" alt=":coolcat:"/)
end
end
end

View file

@ -9,7 +9,7 @@ describe SearchQueryTransformer do
it 'sets attributes' do
transformer = described_class.new.apply(parser)
expect(transformer.should_clauses.first).to be_a(SearchQueryTransformer::TermClause)
expect(transformer.should_clauses.first).to be_a(SearchQueryTransformer::PhraseClause)
expect(transformer.must_clauses.first).to be_nil
expect(transformer.must_not_clauses.first).to be_nil
expect(transformer.filter_clauses.first).to be_nil

View file

@ -843,18 +843,18 @@ RSpec.describe Account do
describe 'matches_display_name' do
it 'matches display name which starts with the given string' do
match = Fabricate(:account, display_name: 'pattern and suffix')
Fabricate(:account, display_name: 'prefix and pattern')
account = Fabricate(:account, display_name: 'prefix and pattern')
expect(described_class.matches_display_name('pattern')).to eq [match]
expect(described_class.matches_display_name('pattern')).to eq [match, account]
end
end
describe 'matches_username' do
it 'matches display name which starts with the given string' do
match = Fabricate(:account, username: 'pattern_and_suffix')
Fabricate(:account, username: 'prefix_and_pattern')
account = Fabricate(:account, username: 'prefix_and_pattern')
expect(described_class.matches_username('pattern')).to eq [match]
expect(described_class.matches_username('pattern')).to eq [match, account]
end
end

View file

@ -60,10 +60,38 @@ RSpec.describe 'Domain Blocks' do
end
end
let(:expected_responde_with_kb_custom) do
domain_blocks.map do |domain_block|
{
id: domain_block.id.to_s,
domain: domain_block.domain,
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
severity: domain_block.severity.to_s,
reject_media: domain_block.reject_media,
reject_reports: domain_block.reject_reports,
private_comment: domain_block.private_comment,
public_comment: domain_block.public_comment,
obfuscate: domain_block.obfuscate,
reject_favourite: domain_block.reject_favourite,
reject_hashtag: domain_block.reject_hashtag,
detect_invalid_subscription: domain_block.detect_invalid_subscription,
reject_new_follow: domain_block.reject_new_follow,
reject_reply: domain_block.reject_reply,
reject_reply_exclude_followers: domain_block.reject_reply_exclude_followers,
reject_send_dissubscribable: domain_block.reject_send_dissubscribable,
reject_send_media: domain_block.reject_send_media,
reject_send_not_public_searchability: domain_block.reject_send_not_public_searchability,
reject_send_public_unlisted: domain_block.reject_send_public_unlisted,
reject_send_sensitive: domain_block.reject_send_sensitive,
reject_straight_follow: domain_block.reject_straight_follow,
}
end
end
it 'returns the expected domain blocks' do
subject
expect(body_as_json).to match_array(expected_responde)
expect(body_as_json).to match_array(expected_responde_with_kb_custom)
end
context 'with limit param' do
@ -85,6 +113,32 @@ RSpec.describe 'Domain Blocks' do
let!(:domain_block) { Fabricate(:domain_block) }
let(:expected_response) do
{
id: domain_block.id.to_s,
domain: domain_block.domain,
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
severity: domain_block.severity.to_s,
reject_media: domain_block.reject_media,
reject_reports: domain_block.reject_reports,
private_comment: domain_block.private_comment,
public_comment: domain_block.public_comment,
obfuscate: domain_block.obfuscate,
reject_favourite: domain_block.reject_favourite,
reject_hashtag: domain_block.reject_hashtag,
detect_invalid_subscription: domain_block.detect_invalid_subscription,
reject_new_follow: domain_block.reject_new_follow,
reject_reply: domain_block.reject_reply,
reject_reply_exclude_followers: domain_block.reject_reply_exclude_followers,
reject_send_dissubscribable: domain_block.reject_send_dissubscribable,
reject_send_media: domain_block.reject_send_media,
reject_send_not_public_searchability: domain_block.reject_send_not_public_searchability,
reject_send_public_unlisted: domain_block.reject_send_public_unlisted,
reject_send_sensitive: domain_block.reject_send_sensitive,
reject_straight_follow: domain_block.reject_straight_follow,
}
end
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
it_behaves_like 'forbidden for wrong role', ''
it_behaves_like 'forbidden for wrong role', 'Moderator'
@ -98,19 +152,7 @@ RSpec.describe 'Domain Blocks' do
it 'returns the expected domain block content' do
subject
expect(body_as_json).to eq(
{
id: domain_block.id.to_s,
domain: domain_block.domain,
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
severity: domain_block.severity.to_s,
reject_media: domain_block.reject_media,
reject_reports: domain_block.reject_reports,
private_comment: domain_block.private_comment,
public_comment: domain_block.public_comment,
obfuscate: domain_block.obfuscate,
}
)
expect(body_as_json).to eq(expected_response)
end
context 'when the requested domain block does not exist' do

View file

@ -33,6 +33,18 @@ RSpec.describe 'Lists' do
end
end
let(:expected_response_with_antennas) do
lists.map do |list|
{
id: list.id.to_s,
title: list.title,
replies_policy: list.replies_policy,
exclusive: list.exclusive,
antennas: list.antennas,
}
end
end
before do
Fabricate(:list)
end
@ -48,7 +60,7 @@ RSpec.describe 'Lists' do
it 'returns the expected lists' do
subject
expect(body_as_json).to match_array(expected_response)
expect(body_as_json).to match_array(expected_response_with_antennas)
end
end
@ -75,6 +87,7 @@ RSpec.describe 'Lists' do
title: list.title,
replies_policy: list.replies_policy,
exclusive: list.exclusive,
antennas: list.antennas,
})
end
@ -171,6 +184,7 @@ RSpec.describe 'Lists' do
title: list.title,
replies_policy: list.replies_policy,
exclusive: list.exclusive,
antennas: list.antennas,
})
end

View file

@ -21,7 +21,7 @@ describe 'Content-Security-Policy' do
"child-src 'self' blob: https://cb6e6126.ngrok.io",
"worker-src 'self' blob: https://cb6e6126.ngrok.io",
"connect-src 'self' data: blob: https://cb6e6126.ngrok.io https://cb6e6126.ngrok.io ws://localhost:4000",
"script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'"
"script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval' https://www.googletagmanager.com https://googleads.g.doubleclick.net https://www.googleadservices.com https://www.google.co.jp https://www.google.com 'sha256-CS1WvLDd3zJOdxpEk+N+VigcWMa6V345p2HS0WYiFWE='"
)
end
end