UX: Display group tabs in user's messages tab for non-staff as well.
https://meta.discourse.org/t/group-inboxes-in-user-messages/86787
This commit is contained in:
parent
3f8e3a6f73
commit
b74c108c09
|
@ -43,7 +43,7 @@ class BasicGroupSerializer < ApplicationSerializer
|
|||
end
|
||||
|
||||
def include_has_messages?
|
||||
staff?
|
||||
staff? || scope.can_see_group_messages?(object)
|
||||
end
|
||||
|
||||
def include_bio_raw?
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
|||
describe BasicGroupSerializer do
|
||||
let(:guardian) { Guardian.new }
|
||||
let(:group) { Fabricate(:group) }
|
||||
subject { described_class.new(group, scope: Guardian.new, root: false) }
|
||||
subject { described_class.new(group, scope: guardian, root: false) }
|
||||
|
||||
describe '#display_name' do
|
||||
describe 'automatic group' do
|
||||
|
@ -26,17 +26,52 @@ describe BasicGroupSerializer do
|
|||
describe '#bio_raw' do
|
||||
let(:group) { Fabricate(:group, bio_raw: 'testing') }
|
||||
|
||||
let(:user) do
|
||||
user = Fabricate(:user)
|
||||
group.add_owner(user)
|
||||
user
|
||||
subject do
|
||||
described_class.new(group, scope: guardian, root: false, owner_group_ids: [group.id])
|
||||
end
|
||||
|
||||
let(:guardian) { Guardian.new(user) }
|
||||
|
||||
describe 'group owner' do
|
||||
let(:user) do
|
||||
user = Fabricate(:user)
|
||||
group.add_owner(user)
|
||||
user
|
||||
end
|
||||
|
||||
it 'should include bio_raw' do
|
||||
expect(subject.bio_raw).to eq('testing')
|
||||
expect(subject.as_json[:bio_raw]).to eq('testing')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_messages' do
|
||||
let(:group) { Fabricate(:group, has_messages: true) }
|
||||
|
||||
describe 'for a staff user' do
|
||||
let(:guardian) { Guardian.new(Fabricate(:moderator)) }
|
||||
|
||||
it 'should be present' do
|
||||
expect(subject.as_json[:has_messages]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for a group user' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:guardian) { Guardian.new(user) }
|
||||
|
||||
before do
|
||||
group.add(user)
|
||||
end
|
||||
|
||||
it 'should be present' do
|
||||
expect(subject.as_json[:has_messages]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for a normal user' do
|
||||
let(:guardian) { Guardian.new(Fabricate(:user)) }
|
||||
|
||||
it 'should not be present' do
|
||||
expect(subject.as_json[:has_messages]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue