Clean up `settings/featured_tags/index` view (#28688)
parent
55802242ce
commit
87097a227c
|
@ -9,6 +9,19 @@ module SettingsHelper
|
||||||
LanguagesHelper.sorted_locale_keys(I18n.available_locales)
|
LanguagesHelper.sorted_locale_keys(I18n.available_locales)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def featured_tags_hint(recently_used_tags)
|
||||||
|
safe_join(
|
||||||
|
[
|
||||||
|
t('simple_form.hints.featured_tag.name'),
|
||||||
|
safe_join(
|
||||||
|
links_for_featured_tags(recently_used_tags),
|
||||||
|
', '
|
||||||
|
),
|
||||||
|
],
|
||||||
|
' '
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def session_device_icon(session)
|
def session_device_icon(session)
|
||||||
device = session.detection.device
|
device = session.detection.device
|
||||||
|
|
||||||
|
@ -28,4 +41,18 @@ module SettingsHelper
|
||||||
safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
|
safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def links_for_featured_tags(tags)
|
||||||
|
tags.map { |tag| post_link_to_featured_tag(tag) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_link_to_featured_tag(tag)
|
||||||
|
link_to(
|
||||||
|
"##{tag.display_name}",
|
||||||
|
settings_featured_tags_path(featured_tag: { name: tag.name }),
|
||||||
|
method: :post
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :name,
|
= f.input :name,
|
||||||
hint: safe_join([t('simple_form.hints.featured_tag.name'), safe_join(@recently_used_tags.map { |tag| link_to("##{tag.display_name}", settings_featured_tags_path(featured_tag: { name: tag.name }), method: :post) }, ', ')], ' '),
|
hint: featured_tags_hint(@recently_used_tags),
|
||||||
wrapper: :with_block_label
|
wrapper: :with_block_label
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
|
|
|
@ -43,10 +43,20 @@ describe Settings::FeaturedTagsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET to #index' do
|
describe 'GET to #index' do
|
||||||
|
let(:tag) { Fabricate(:tag) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
status = Fabricate :status, account: user.account
|
||||||
|
status.tags << tag
|
||||||
|
end
|
||||||
|
|
||||||
it 'responds with success' do
|
it 'responds with success' do
|
||||||
get :index
|
get :index
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
expect(response.body).to include(
|
||||||
|
settings_featured_tags_path(featured_tag: { name: tag.name })
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue