mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
UX: Add group name to error message (#11333)
The group name used to be part of the error message, but was removed in a past commit.
This commit is contained in:
parent
2742595b00
commit
123107c28f
|
@ -207,6 +207,7 @@ class ApplicationController < ActionController::Base
|
|||
403,
|
||||
include_ember: true,
|
||||
custom_message: e.custom_message,
|
||||
custom_message_params: e.custom_message_params,
|
||||
group: e.group
|
||||
)
|
||||
end
|
||||
|
|
|
@ -112,6 +112,7 @@ class TopicsController < ApplicationController
|
|||
'not in group',
|
||||
ex.obj,
|
||||
custom_message: 'not_in_group.title_topic',
|
||||
custom_message_params: { group: group.name },
|
||||
group: group
|
||||
)
|
||||
end
|
||||
|
|
|
@ -281,7 +281,7 @@ en:
|
|||
email_template_cant_be_modified: "This email template can't be modified"
|
||||
invalid_whisper_access: "Either whispers are not enabled or you do not have access to create whisper posts"
|
||||
not_in_group:
|
||||
title_topic: "You must be in a group to see this topic."
|
||||
title_topic: "You need to request membership to the '%{group}' group to see this topic."
|
||||
title_category: "You must be in a group to see this category."
|
||||
request_membership: "Request Membership"
|
||||
join_group: "Join Group"
|
||||
|
|
|
@ -142,6 +142,7 @@ module Discourse
|
|||
attr_reader :obj
|
||||
attr_reader :opts
|
||||
attr_reader :custom_message
|
||||
attr_reader :custom_message_params
|
||||
attr_reader :group
|
||||
|
||||
def initialize(msg = nil, obj = nil, opts = nil)
|
||||
|
@ -150,6 +151,7 @@ module Discourse
|
|||
@opts = opts || {}
|
||||
@obj = obj
|
||||
@custom_message = opts[:custom_message] if @opts[:custom_message]
|
||||
@custom_message_params = opts[:custom_message_params] if @opts[:custom_message_params]
|
||||
@group = opts[:group] if @opts[:group]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1584,6 +1584,30 @@ RSpec.describe TopicsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'when topic is allowed to a group' do
|
||||
let(:group) { Fabricate(:group, public_admission: true) }
|
||||
let(:category) do
|
||||
Fabricate(:category_with_definition).tap do |category|
|
||||
category.set_permissions(group => :full)
|
||||
category.save!
|
||||
end
|
||||
end
|
||||
let(:topic) { Fabricate(:topic, category: category) }
|
||||
|
||||
before do
|
||||
SiteSetting.detailed_404 = true
|
||||
end
|
||||
|
||||
it 'shows a descriptive error message containing the group name' do
|
||||
get "/t/#{topic.id}.json"
|
||||
|
||||
html = CGI.unescapeHTML(response.parsed_body["extras"]["html"])
|
||||
expect(response.status).to eq(403)
|
||||
expect(html).to include(I18n.t('not_in_group.title_topic', group: group.name))
|
||||
expect(html).to include(I18n.t('not_in_group.join_group'))
|
||||
end
|
||||
end
|
||||
|
||||
it 'correctly renders canoicals' do
|
||||
get "/t/#{topic.id}", params: { slug: topic.slug }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user