Merge commit '7d9b209fe84b00eff348ea9d54905cbfffa79788' into glitch-soc/merge-upstream
Conflicts: - `app/models/form/admin_settings.rb`: Upstream changed code style change, including on a line modified by glitch-soc. Kept glitch-soc's line but with the code style change applied.
This commit is contained in:
commit
30ee7339d3
33 files changed
+591
-485
No files matched your search
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:custom_emoji_category) do
|
||||
name { sequence(:name) { |i| "name_#{i}" } }
|
||||
end
|
||||
@@ -178,11 +178,11 @@ RSpec.describe Remotable do
|
||||
|
||||
allow(foo).to receive(:public_send)
|
||||
foo.hoge_remote_url = url
|
||||
expect(foo).to have_received(:public_send).with("download_#{hoge}!", url)
|
||||
expect(foo).to have_received(:public_send).with(:"download_#{hoge}!", url)
|
||||
|
||||
allow(foo).to receive(:public_send)
|
||||
foo.download_hoge!(url)
|
||||
expect(foo).to have_received(:public_send).with("#{hoge}=", response_with_limit)
|
||||
expect(foo).to have_received(:public_send).with(:"#{hoge}=", response_with_limit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Form::CustomEmojiBatch do
|
||||
describe '#save' do
|
||||
subject { described_class.new({ current_account: account }.merge(options)) }
|
||||
|
||||
let(:options) { {} }
|
||||
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
|
||||
context 'with empty custom_emoji_ids' do
|
||||
let(:options) { { custom_emoji_ids: [] } }
|
||||
|
||||
it 'does nothing if custom_emoji_ids is empty' do
|
||||
expect(subject.save).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the update action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, category: Fabricate(:custom_emoji_category)) }
|
||||
let(:custom_emoji_category) { Fabricate(:custom_emoji_category) }
|
||||
|
||||
context 'without anything to change' do
|
||||
let(:options) { { action: 'update' } }
|
||||
|
||||
it 'silently exits without updating any custom emojis' do
|
||||
expect { subject.save }.to_not change(Admin::ActionLog, :count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a category_id' do
|
||||
let(:options) { { action: 'update', custom_emoji_ids: [custom_emoji.id], category_id: custom_emoji_category.id } }
|
||||
|
||||
it 'updates the category of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload.category).to eq(custom_emoji_category)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a category_name' do
|
||||
let(:options) { { action: 'update', custom_emoji_ids: [custom_emoji.id], category_name: custom_emoji_category.name } }
|
||||
|
||||
it 'updates the category of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload.category).to eq(custom_emoji_category)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the list action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, visible_in_picker: false) }
|
||||
let(:options) { { action: 'list', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'updates the picker visibility of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload.visible_in_picker).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the unlist action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, visible_in_picker: true) }
|
||||
let(:options) { { action: 'unlist', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'updates the picker visibility of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload.visible_in_picker).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the enable action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, disabled: true) }
|
||||
let(:options) { { action: 'enable', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'updates the disabled value of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload).to_not be_disabled
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the disable action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, visible_in_picker: false) }
|
||||
let(:options) { { action: 'disable', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'updates the disabled value of the emoji' do
|
||||
subject.save
|
||||
|
||||
expect(custom_emoji.reload).to be_disabled
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the copy action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji) }
|
||||
let(:options) { { action: 'copy', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'makes a copy of the emoji' do
|
||||
expect { subject.save }
|
||||
.to change(CustomEmoji, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the delete action' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji) }
|
||||
let(:options) { { action: 'delete', custom_emoji_ids: [custom_emoji.id] } }
|
||||
|
||||
it 'destroys the emoji' do
|
||||
subject.save
|
||||
|
||||
expect { custom_emoji.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,19 +5,18 @@ require 'rails_helper'
|
||||
RSpec.describe AccountRelationshipsPresenter do
|
||||
describe '.initialize' do
|
||||
before do
|
||||
allow(Account).to receive(:following_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:followed_by_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:blocking_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:muting_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:requested_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:requested_by_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:domain_blocking_map).with(account_ids, current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:following_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:followed_by_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:blocking_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:muting_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:requested_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
allow(Account).to receive(:requested_by_map).with(accounts.pluck(:id), current_account_id).and_return(default_map)
|
||||
end
|
||||
|
||||
let(:presenter) { described_class.new(account_ids, current_account_id, **options) }
|
||||
let(:presenter) { described_class.new(accounts, current_account_id, **options) }
|
||||
let(:current_account_id) { Fabricate(:account).id }
|
||||
let(:account_ids) { [Fabricate(:account).id] }
|
||||
let(:default_map) { { 1 => true } }
|
||||
let(:accounts) { [Fabricate(:account)] }
|
||||
let(:default_map) { { accounts[0].id => true } }
|
||||
|
||||
context 'when options are not set' do
|
||||
let(:options) { {} }
|
||||
@@ -29,7 +28,33 @@ RSpec.describe AccountRelationshipsPresenter do
|
||||
blocking: default_map,
|
||||
muting: default_map,
|
||||
requested: default_map,
|
||||
domain_blocking: default_map
|
||||
domain_blocking: { accounts[0].id => nil }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a warm cache' do
|
||||
let(:options) { {} }
|
||||
|
||||
before do
|
||||
described_class.new(accounts, current_account_id, **options)
|
||||
|
||||
allow(Account).to receive(:following_map).with([], current_account_id).and_return({})
|
||||
allow(Account).to receive(:followed_by_map).with([], current_account_id).and_return({})
|
||||
allow(Account).to receive(:blocking_map).with([], current_account_id).and_return({})
|
||||
allow(Account).to receive(:muting_map).with([], current_account_id).and_return({})
|
||||
allow(Account).to receive(:requested_map).with([], current_account_id).and_return({})
|
||||
allow(Account).to receive(:requested_by_map).with([], current_account_id).and_return({})
|
||||
end
|
||||
|
||||
it 'sets returns expected values' do
|
||||
expect(presenter).to have_attributes(
|
||||
following: default_map,
|
||||
followed_by: default_map,
|
||||
blocking: default_map,
|
||||
muting: default_map,
|
||||
requested: default_map,
|
||||
domain_blocking: { accounts[0].id => nil }
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -86,7 +111,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
||||
let(:options) { { domain_blocking_map: { 7 => true } } }
|
||||
|
||||
it 'sets @domain_blocking merged with default_map and options[:domain_blocking_map]' do
|
||||
expect(presenter.domain_blocking).to eq default_map.merge(options[:domain_blocking_map])
|
||||
expect(presenter.domain_blocking).to eq({ accounts[0].id => nil }.merge(options[:domain_blocking_map]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
describe 'OmniAuth callbacks' do
|
||||
shared_examples 'omniauth provider callbacks' do |provider|
|
||||
subject { post send "user_#{provider}_omniauth_callback_path" }
|
||||
subject { post send :"user_#{provider}_omniauth_callback_path" }
|
||||
|
||||
context 'with full information in response' do
|
||||
before do
|
||||
|
||||
Reference in new issue
Block a user