Compare commits

...

5 Commits

Author SHA1 Message Date
Matt Jankowski
37c25ebb7d
Merge 6fb6b9fa4b into 74fc4dbacf 2025-07-15 17:05:58 +00:00
diondiondion
74fc4dbacf
refactor: Only remove pointer-events when necessary (#35390)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
2025-07-15 15:57:31 +00:00
Matt Jankowski
6fb6b9fa4b Use private methods 2025-07-03 18:28:38 -04:00
Matt Jankowski
bfdaa9789a Remove unused options arg 2025-07-03 18:28:38 -04:00
Matt Jankowski
f400360cf9 Add coverage for TagRelationshipsPresenter class 2025-07-03 18:28:38 -04:00
3 changed files with 59 additions and 5 deletions

View File

@ -2848,7 +2848,6 @@ a.account__display-name {
&__pane {
height: 100%;
overflow: hidden;
pointer-events: none;
display: flex;
justify-content: flex-end;
min-width: 285px;
@ -2860,7 +2859,6 @@ a.account__display-name {
&__inner {
position: fixed;
width: 285px;
pointer-events: auto;
height: 100%;
}
}

View File

@ -3,13 +3,29 @@
class TagRelationshipsPresenter
attr_reader :following_map, :featuring_map
def initialize(tags, current_account_id = nil, **options)
def initialize(tags, current_account_id = nil)
if current_account_id.nil?
@following_map = {}
@featuring_map = {}
else
@following_map = TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
@featuring_map = FeaturedTag.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:featuring_map] || {})
@following_map = mapped_tag_follows(tags, current_account_id)
@featuring_map = mapped_featured_tags(tags, current_account_id)
end
end
private
def mapped_tag_follows(tags, account_id)
TagFollow
.where(tag_id: tags.map(&:id), account_id: account_id)
.pluck(:tag_id)
.index_with(true)
end
def mapped_featured_tags(tags, account_id)
FeaturedTag
.where(tag_id: tags.map(&:id), account_id: account_id)
.pluck(:tag_id)
.index_with(true)
end
end

View File

@ -0,0 +1,40 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TagRelationshipsPresenter do
context 'without an account' do
subject { described_class.new(tags, nil) }
let(:tags) { Fabricate.times 2, :tag }
it 'includes empty hashes for maps' do
expect(subject)
.to have_attributes(
following_map: eq({}),
featuring_map: eq({})
)
end
end
context 'with an account and following and featured tags' do
subject { described_class.new(Tag.all, account.id) }
let(:account) { Fabricate :account }
let(:tag_to_feature) { Fabricate :tag }
let(:tag_to_follow) { Fabricate :tag }
before do
Fabricate :featured_tag, account: account, tag: tag_to_feature
Fabricate :tag_follow, account: account, tag: tag_to_follow
end
it 'includes map with relevant id values' do
expect(subject)
.to have_attributes(
featuring_map: eq(tag_to_feature.id => true),
following_map: eq(tag_to_follow.id => true)
)
end
end
end