Skip to content

Commit 23aef7c

Browse files
committed
more accurate contextless send permission in conversations ui
fixes CNVS-23104 test plan - as an account admin (not site admin), ensure that you can send a conversation message without specifying a context - disable the "See the list of users" permission for the Account Admin role on the user's root account - as the account admin, ensure that you now cannot send a conversation message without specifying a context Change-Id: I25d6bacae1b213d6fa5caf7813de6d979282411b Reviewed-on: https://gerrit.instructure.com/66155 Reviewed-by: Matthew Wheeler <mwheeler@instructure.com> Tested-by: Jenkins QA-Review: Adrian Russell <arussell@instructure.com> Product-Review: Joel Hough <joel@instructure.com>
1 parent b48b5a5 commit 23aef7c

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

app/coffeescripts/views/conversations/AutocompleteView.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ define [
658658
# Returns nothing.
659659
setContext: (context, disable = false) ->
660660
context = null unless context.id
661-
if disable and !_.include(ENV.current_user_roles, 'admin') and !@disabled
661+
if disable and !ENV.CONVERSATIONS.CAN_MESSAGE_ACCOUNT_CONTEXT and !@disabled
662662
@disable(!context)
663663
return if context?.id == @currentContext?.id
664664
@currentContext = context

app/coffeescripts/views/conversations/CourseSelectionView.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ define [
9191
view.clearSearch()
9292

9393
getAriaLabel: ->
94-
return if _.include(ENV.current_user_roles, 'admin')
94+
return if ENV.CONVERSATIONS.CAN_MESSAGE_ACCOUNT_CONTEXT
9595
label = @getCurrentContext().name || I18n.t("Select course: a selection is required before recipients field will become available")
9696
@$picker.find('button').attr("aria-label", label)
9797

app/coffeescripts/views/conversations/MessageFormDialog.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ define [
178178
@recipientView.on('changeToken', @recipientIdsChanged)
179179
@recipientView.on('recipientTotalChange', @recipientTotalChanged)
180180

181-
unless _.include(ENV.current_user_roles, 'admin')
181+
unless ENV.CONVERSATIONS.CAN_MESSAGE_ACCOUNT_CONTEXT
182182
@$messageCourse.attr('aria-required', true)
183183
@recipientView.disable(true)
184184

app/controllers/conversations_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def index
248248
hash = {
249249
:ATTACHMENTS_FOLDER_ID => @current_user.conversation_attachments_folder.id,
250250
:ACCOUNT_CONTEXT_CODE => "account_#{@domain_root_account.id}",
251+
:CAN_MESSAGE_ACCOUNT_CONTEXT => valid_account_context?(@domain_root_account),
251252
:MAX_GROUP_CONVERSATION_SIZE => Conversation.max_group_conversation_size
252253
}
253254

spec/selenium/conversations/conversations_message_sending_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
expect(c.conversation_participants.collect(&:user_id).sort).to eq([@teacher, @s1, @s2].collect(&:id).sort)
4141
end
4242

43-
it "should allow admins to send a message without picking a context", priority: "1", test_id: 138677 do
43+
it "should allow admins with read_roster permission to send a message without picking a context", priority: "1", test_id: 138677 do
4444
user = account_admin_user
4545
user_logged_in({:user => user})
4646
get_conversations
@@ -50,6 +50,16 @@
5050
expect(c.context).to eq Account.default
5151
end
5252

53+
it "should not allow admins without read_roster permission to send a message without picking a context", priority: "1" do
54+
user = account_admin_user
55+
RoleOverride.manage_role_override(Account.default, Role.get_built_in_role('AccountAdmin'), 'read_roster', override: false, locked: false)
56+
user_logged_in({:user => user})
57+
get_conversations
58+
fj('#compose-btn').click
59+
wait_for_animations
60+
expect(fj('#recipient-row')).to have_attribute(:style, 'display: none;')
61+
end
62+
5363
it "should not allow non-admins to send a message without picking a context", priority: "1", test_id: 138678 do
5464
get_conversations
5565
fj('#compose-btn').click
@@ -153,4 +163,4 @@
153163
end
154164
end
155165
end
156-
end
166+
end

0 commit comments

Comments
 (0)