add yes/no push notification column to notification preferences
fixes CNVS-9552 test plan: - create a push notification communication channel for a user. - navigate to the user's notification preferences. - check there is a column for the push notification channel and it only has 'asap' and 'never' as options. Change-Id: I6bed09d631a6db575c9689d4cf975197c1647502 Reviewed-on: https://gerrit.instructure.com/26471 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Joel Hough <joel@instructure.com> QA-Review: Matt Fairbourn <mfairbourn@instructure.com> Product-Review: Jon Willesen <jonw@instructure.com>
This commit is contained in:
parent
51c6ddffe1
commit
b664ca47ef
|
@ -39,6 +39,8 @@ define [
|
|||
title: I18n.t('frequencies.title.never', 'Do not send me anything')
|
||||
]
|
||||
|
||||
@limitedButtonData = [_.first(@buttonData), _.last(@buttonData)]
|
||||
|
||||
@updateUrl = @options.update_url
|
||||
@channels = @options.channels || []
|
||||
@categories = @options.categories || []
|
||||
|
@ -49,6 +51,7 @@ define [
|
|||
c.name = switch c.type
|
||||
when 'email' then I18n.t('communication.email.display', 'Email Address')
|
||||
when 'sms' then I18n.t('communication.sms.display', 'Cell Number')
|
||||
when 'push' then I18n.t('communication.push.display', 'Push Notification')
|
||||
when 'twitter' then I18n.t('communication.twitter.display', 'Twitter')
|
||||
when 'facebook' then I18n.t('communication.facebook.display', 'Facebook')
|
||||
# Setup the mappings
|
||||
|
@ -86,7 +89,7 @@ define [
|
|||
p.channel_id is c.id and p.category is category.category
|
||||
frequency = 'never'
|
||||
frequency = policy['frequency'] if policy
|
||||
@policyCellHtml(category, c.id, frequency)
|
||||
@policyCellHtml(category, c, frequency)
|
||||
fragments.join ''
|
||||
|
||||
hideButtonsExceptCell: ($notCell) =>
|
||||
|
@ -167,17 +170,24 @@ define [
|
|||
null
|
||||
|
||||
# Generate and return the HTML for an option cell with the with the sepecified value set/reflected.
|
||||
policyCellHtml: (category, channelId, selectedValue = 'never') =>
|
||||
policyCellHtml: (category, channel, selectedValue = 'never') =>
|
||||
# Reset all buttons to not be active by default. Set their ID to be unique to the data combination.
|
||||
_.each(@buttonData, (b) ->
|
||||
b['active'] = false
|
||||
b['coordinate'] = "cat_#{category.id}_ch_#{channelId}"
|
||||
b['coordinate'] = "cat_#{category.id}_ch_#{channel.id}"
|
||||
b['id'] = "#{b['coordinate']}_#{b['code']}"
|
||||
)
|
||||
selected = @findButtonDataForCode(selectedValue)
|
||||
selected['active'] = true
|
||||
|
||||
policyCellTemplate(touch: INST.browser.touch, category: category.category, channelId: channelId, selected: selected, allButtons: @buttonData)
|
||||
cellButtonData = if channel.type == 'push' then @limitedButtonData else @buttonData
|
||||
|
||||
policyCellTemplate
|
||||
touch: INST.browser.touch
|
||||
category: category.category
|
||||
channelId: channel.id
|
||||
selected: selected
|
||||
allButtons: cellButtonData
|
||||
|
||||
# Record and display the value for the cell.
|
||||
saveNewCellValue: ($cell, value) =>
|
||||
|
|
|
@ -251,7 +251,7 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
twitter_service = user.user_services.for_service(CommunicationChannel::TYPE_TWITTER).first
|
||||
twitter_service.assert_communication_channel if twitter_service
|
||||
|
||||
rank_order = [TYPE_EMAIL, TYPE_SMS]
|
||||
rank_order = [TYPE_EMAIL, TYPE_SMS, TYPE_PUSH]
|
||||
# Add facebook and twitter (in that order) if the user's account is setup for them.
|
||||
rank_order << TYPE_FACEBOOK unless user.user_services.for_service(CommunicationChannel::TYPE_FACEBOOK).empty?
|
||||
rank_order << TYPE_TWITTER if twitter_service
|
||||
|
|
|
@ -69,6 +69,37 @@ describe "profile communication settings" do
|
|||
fj('tr.grouping:first th.comm-channel:last').should include_text('8011235555@vtext.com')
|
||||
end
|
||||
|
||||
let(:sns_response) { stub(data: {endpointarn: 'endpointarn'}) }
|
||||
let(:sns_client) { stub(create_platform_endpoint: sns_response) }
|
||||
let(:sns_developer_key_sns_field) { stub(client: sns_client) }
|
||||
|
||||
let(:sns_developer_key) do
|
||||
DeveloperKey.stubs(:sns).returns(sns_developer_key_sns_field)
|
||||
dk = DeveloperKey.default
|
||||
dk.sns_arn = 'apparn'
|
||||
dk.save!
|
||||
dk
|
||||
end
|
||||
|
||||
let(:sns_access_token) { @user.access_tokens.create!(developer_key: sns_developer_key) }
|
||||
let(:sns_channel) { @user.communication_channels.create_push(sns_access_token, 'device_token') }
|
||||
|
||||
it "should display an sns channel" do
|
||||
sns_channel
|
||||
get "/profile/communication"
|
||||
wait_for_ajaximations
|
||||
fj('tr.grouping:first th.comm-channel:last').should include_text('Push Notification')
|
||||
end
|
||||
|
||||
it "should only display asap and never for sns channels" do
|
||||
sns_channel
|
||||
get "/profile/communication"
|
||||
wait_for_ajaximations
|
||||
cell = find_frequency_cell("Grading", sns_channel.id)
|
||||
buttons = ffj('.frequency', cell)
|
||||
buttons.map {|b| b.attribute(:'data-value')}.should == %w(immediately never)
|
||||
end
|
||||
|
||||
it "should load the initial state of a user-pref checkbox" do
|
||||
# set the user's initial user preference and verify checked or unchecked
|
||||
@user.preferences[:send_scores_in_emails] = false
|
||||
|
|
Loading…
Reference in New Issue