diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-06-24 14:32:22 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-06-24 14:32:22 +0200 |
commit | 4b0f27ba7822befed76f8368b472c6ade6977cb2 (patch) | |
tree | cebf03387c15cb6299d27a7988f78d173d7945de | |
parent | 03cfe366fd0146cb4c3ede4dcdeeb2228a513e7d (diff) | |
parent | 50a2854f922ebdd2c056870a0de402329bdf1bb3 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
-rw-r--r-- | app/controllers/remote_unfollows_controller.rb (renamed from app/controllers/remote_unfollows.rb) | 0 | ||||
-rw-r--r-- | app/javascript/styles/mastodon/components.scss | 6 | ||||
-rw-r--r-- | app/models/concerns/attachmentable.rb | 5 | ||||
-rw-r--r-- | db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb | 7 | ||||
-rw-r--r-- | db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb | 7 | ||||
-rw-r--r-- | spec/controllers/remote_unfollows_controller_spec.rb | 38 |
6 files changed, 53 insertions, 10 deletions
diff --git a/app/controllers/remote_unfollows.rb b/app/controllers/remote_unfollows_controller.rb index af5943363..af5943363 100644 --- a/app/controllers/remote_unfollows.rb +++ b/app/controllers/remote_unfollows_controller.rb diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 147cc653b..6905eaa1e 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -302,12 +302,10 @@ height: 0; transform-origin: bottom; opacity: 0.0; - transition: all 0.4s ease; &.spoiler-input--visible { height: 47px; opacity: 1.0; - transition: all 0.4s ease; } } @@ -568,6 +566,10 @@ } } +.no-reduce-motion .spoiler-input { + transition: height 0.4s ease, opacity 0.4s ease; +} + .emojione { font-size: inherit; vertical-align: middle; diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb index db63c3eca..44bdfa39a 100644 --- a/app/models/concerns/attachmentable.rb +++ b/app/models/concerns/attachmentable.rb @@ -42,8 +42,9 @@ module Attachmentable extensions_for_mime_type = mime_type.empty? ? [] : mime_type.first.extensions original_extension = Paperclip::Interpolations.extension(attachment, :original) proper_extension = extensions_for_mime_type.first.to_s - proper_extension = 'jpeg' if proper_extension == 'jpe' + extension = extensions_for_mime_type.include?(original_extension) ? original_extension : proper_extension + extension = 'jpeg' if extension == 'jpe' - extensions_for_mime_type.include?(original_extension) ? original_extension : proper_extension + extension end end diff --git a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index 2573bdf94..b29e62803 100644 --- a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -4,8 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi disable_ddl_transaction! def change - add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently - add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently - remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 + # These changes ware reverted by migration 20180514140000. + # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently + # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently + # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 end end diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index b6b9f96ae..4a8761fec 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -5,10 +5,11 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor def change safety_assured do - add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 + add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_exists?(:statuses, name: "index_statuses_20180106") end - remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently - remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently + # These index may not exists (see migration 20180514130000) + remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)') + remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)") end end diff --git a/spec/controllers/remote_unfollows_controller_spec.rb b/spec/controllers/remote_unfollows_controller_spec.rb new file mode 100644 index 000000000..223ed64af --- /dev/null +++ b/spec/controllers/remote_unfollows_controller_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe RemoteUnfollowsController do + render_views + + describe '#create' do + subject { post :create, params: { acct: acct } } + + let(:current_user) { Fabricate(:user, account: current_account) } + let(:current_account) { Fabricate(:account) } + let(:remote_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account } + before do + sign_in current_user + current_account.follow!(remote_account) + stub_request(:post, 'http://example.com/inbox'){ { status: 200 } } + end + + context 'when successfully unfollow remote account' do + let(:acct) {"acct:#{ remote_account.username }@#{ remote_account.domain }"} + + it do + is_expected.to render_template :success + expect(current_account.following?(remote_account)).to be false + end + end + + context 'when fails to unfollow remote account' do + let(:acct) {"acct:#{ remote_account.username + '_test' }@#{ remote_account.domain }"} + + it do + is_expected.to render_template :error + expect(current_account.following?(remote_account)).to be true + end + end + end +end |