limit the length of media comment titles to 255 chars
test plan: - record a video or audio comment, and enter a long title. it should prevent you from entering more than 255 chars (rather than failing to save the media comment) fixes CNVS-4446 Change-Id: Iec4d022bba3b33f5bf678ed7ca37c366a337b3f1 Reviewed-on: https://gerrit.instructure.com/20944 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com> QA-Review: Clare Strong <clare@instructure.com>
This commit is contained in:
parent
f6b6b39673
commit
b498f26e45
|
@ -28,12 +28,13 @@ class ContextController < ApplicationController
|
|||
@context = Context.find_by_asset_string(params[:context_code])
|
||||
if authorized_action(@context, @current_user, :read)
|
||||
if params[:id] && params[:type] && @context.respond_to?(:media_objects)
|
||||
self.extend TextHelper
|
||||
@media_object = @context.media_objects.find_or_initialize_by_media_id_and_media_type(params[:id], params[:type])
|
||||
@media_object.title = params[:title] if params[:title]
|
||||
@media_object.title = truncate_text(params[:title], :max_length => 255) if params[:title]
|
||||
@media_object.user = @current_user
|
||||
@media_object.media_type = params[:type]
|
||||
@media_object.root_account_id = @domain_root_account.id if @domain_root_account && @media_object.respond_to?(:root_account_id)
|
||||
@media_object.user_entered_title = params[:user_entered_title] if params[:user_entered_title] && !params[:user_entered_title].empty?
|
||||
@media_object.user_entered_title = truncate_text(params[:user_entered_title], :max_length => 255) if params[:user_entered_title] && !params[:user_entered_title].empty?
|
||||
@media_object.save
|
||||
end
|
||||
render :json => @media_object.to_json
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div class="recorder_message">Saving Recording...</div>
|
||||
</div>
|
||||
<div style="margin-bottom: 1px; margin-left: 10px;">
|
||||
Title: <input id="video_record_title" type="text" style="width: 250px;"/>
|
||||
Title: <input id="video_record_title" type="text" style="width: 250px;" maxlength="255"/>
|
||||
</div>
|
||||
<div id="video_record_holder">
|
||||
<div id="video_record_meter" class="volume_meter">
|
||||
|
@ -47,7 +47,7 @@
|
|||
<div class="recorder_message">Saving Recording...</div>
|
||||
</div>
|
||||
<div style="margin-bottom: 1px; margin-left: 10px;">
|
||||
Title: <input id="audio_record_title" type="text" style="width: 250px;"/>
|
||||
Title: <input id="audio_record_title" type="text" style="width: 250px;" maxlength="255"/>
|
||||
</div>
|
||||
<div id="audio_record_holder">
|
||||
<div id="audio_record_meter" class="volume_meter">
|
||||
|
|
|
@ -188,6 +188,18 @@ describe ContextController do
|
|||
@media_object.media_type.should == "audio"
|
||||
@media_object.title.should == "title"
|
||||
end
|
||||
|
||||
it "should truncate the title and user_entered_title" do
|
||||
post :create_media_object,
|
||||
:context_code => "user_#{@user.id}",
|
||||
:id => "new_object",
|
||||
:type => "audio",
|
||||
:title => 'x' * 300,
|
||||
:user_entered_title => 'y' * 300
|
||||
@media_object = @user.reload.media_objects.last
|
||||
@media_object.title.size.should <= 255
|
||||
@media_object.user_entered_title.size.should <= 255
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'prior_users" do
|
||||
|
|
Loading…
Reference in New Issue