Remove "Duplicating Objects" feature flag.
Closes FALCOR-233 Test Plan: * Go to Account->Settings->Feature Options. There should now not be any setting for "Duplicate Objects" * It should still be possible to duplicate assignments and wiki pages (except for discussion topics and quizzes) Change-Id: Ib75ebdbc7852e1e11e455e4c72633b6bc9d64385 Reviewed-on: https://gerrit.instructure.com/116813 Tested-by: Jenkins Reviewed-by: Steven Burnett <sburnett@instructure.com> QA-Review: Dan Sasaki <dsasaki@instructure.com> Product-Review: Dan Minkevitch <dan@instructure.com>
This commit is contained in:
parent
0cbc08777d
commit
51a8d87c45
|
@ -274,7 +274,7 @@ define [
|
|||
|
||||
canDuplicate: ->
|
||||
# For now, forbid duplicating quizzes. We will implement that later.
|
||||
(@userIsAdmin || @canManage()) && ENV.DUPLICATE_ENABLED && @isDuplicableAssignment()
|
||||
(@userIsAdmin || @canManage()) && @isDuplicableAssignment()
|
||||
|
||||
canMove: ->
|
||||
@userIsAdmin or (@canManage() and @model.canMove())
|
||||
|
|
|
@ -59,7 +59,6 @@ define [
|
|||
json.CAN =
|
||||
MANAGE: !!@WIKI_RIGHTS.manage
|
||||
PUBLISH: !!@WIKI_RIGHTS.manage && @contextName == 'courses'
|
||||
DUPLICATE: !!ENV.DUPLICATE_ENABLED
|
||||
|
||||
json.cannot_edit_by_master_course = json.is_master_course_child_content && json.restricted_by_master_course
|
||||
|
||||
|
|
|
@ -603,10 +603,6 @@ class AssignmentsApiController < ApplicationController
|
|||
|
||||
return unless authorized_action(old_assignment, @current_user, :create)
|
||||
|
||||
if !@context.root_account.feature_enabled?(:duplicate_objects)
|
||||
return render json: { error: 'duplicating objects not enabled' }, status: 400
|
||||
end
|
||||
|
||||
new_assignment = old_assignment.duplicate
|
||||
new_assignment.save!
|
||||
render :json => assignment_json(new_assignment, @current_user, session)
|
||||
|
|
|
@ -63,7 +63,6 @@ class AssignmentsController < ApplicationController
|
|||
HAS_ASSIGNMENTS: @context.active_assignments.count > 0,
|
||||
QUIZ_LTI_ENABLED: @context.quiz_lti_tool.present?,
|
||||
DUE_DATE_REQUIRED_FOR_ACCOUNT: due_date_required_for_account,
|
||||
DUPLICATE_ENABLED: @domain_root_account.feature_enabled?(:duplicate_objects)
|
||||
}
|
||||
js_env(hash)
|
||||
|
||||
|
|
|
@ -171,10 +171,6 @@ class WikiPagesApiController < ApplicationController
|
|||
# @returns the page that was created
|
||||
def duplicate
|
||||
return unless authorized_action(@page, @current_user, :create)
|
||||
if !@context.root_account.feature_enabled?(:duplicate_objects)
|
||||
return render json: { error: 'duplicating objects not enabled' }, status: :bad_request
|
||||
end
|
||||
|
||||
if @page.deleted?
|
||||
return render json: { error: 'cannot duplicate deleted page' }, status: :bad_request
|
||||
end
|
||||
|
|
|
@ -79,10 +79,6 @@ class WikiPagesController < ApplicationController
|
|||
end
|
||||
js_env :wiki_page_menu_tools => external_tools_display_hashes(:wiki_page_menu)
|
||||
set_tutorial_js_env
|
||||
hash = {
|
||||
DUPLICATE_ENABLED: @domain_root_account.feature_enabled?(:duplicate_objects)
|
||||
}
|
||||
js_env(hash)
|
||||
@padless = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
</a>
|
||||
</li>
|
||||
{{/unless}}
|
||||
{{#if CAN.DUPLICATE}}
|
||||
{{#if CAN.MANAGE}}
|
||||
<li>
|
||||
<a href="#" class="icon-copy-course duplicate-wiki-page" title="{{#t}}Duplicate{{/t}}">
|
||||
{{#t}}Duplicate{{/t}}
|
||||
|
|
|
@ -253,15 +253,6 @@ END
|
|||
root_opt_in: true,
|
||||
beta: true
|
||||
},
|
||||
'duplicate_objects' =>
|
||||
{
|
||||
display_name: -> { I18n.t('Duplicate Objects') },
|
||||
description: -> { I18n.t("Allows the duplicating of objects in Canvas") },
|
||||
applies_to: 'Account',
|
||||
state: 'hidden',
|
||||
root_opt_in: true,
|
||||
beta: true
|
||||
},
|
||||
'allow_opt_out_of_inbox' =>
|
||||
{
|
||||
display_name: -> { I18n.t('features.allow_opt_out_of_inbox', "Allow Users to Opt-out of the Inbox") },
|
||||
|
|
|
@ -925,142 +925,31 @@ describe AssignmentsApiController, type: :request do
|
|||
student_in_course(active_all: true)
|
||||
end
|
||||
|
||||
describe 'duplicating enabled' do
|
||||
before :once do
|
||||
a = @course.account
|
||||
a.enable_feature!(:duplicate_objects)
|
||||
a.save!
|
||||
end
|
||||
|
||||
it "students cannot duplicate" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:assignment_group => @group,
|
||||
:due_at => Time.zone.now + 1.week
|
||||
)
|
||||
api_call_as_user(@student, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 401 })
|
||||
end
|
||||
|
||||
it "should duplicate if teacher" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:assignment_group => @group,
|
||||
:due_at => Time.zone.now + 1.week
|
||||
)
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json", :course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["name"]).to eq "some assignment Copy"
|
||||
end
|
||||
|
||||
it "should require non-quiz" do
|
||||
assignment = @course.assignments.create(:title => "some assignment")
|
||||
assignment.quiz = @course.quizzes.create
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should require non-discussion topic" do
|
||||
assignment = group_discussion_assignment.assignment
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should duplicate wiki page assignment" do
|
||||
assignment = wiki_page_assignment_model({ :title => "Wiki Page Assignment" })
|
||||
assignment.save!
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["name"]).to eq "Wiki Page Assignment Copy"
|
||||
end
|
||||
|
||||
it "should require non-deleted assignment" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:workflow_state => "deleted"
|
||||
)
|
||||
# assignment.save!
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should require existing assignment" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:workflow_state => "deleted"
|
||||
)
|
||||
assignment.save!
|
||||
assignment_id = Assignment.maximum(:id) + 100
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment_id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment_id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not duplicate if feature disabled' do
|
||||
a = @course.account
|
||||
a.disable_feature!(:duplicate_objects)
|
||||
a.save!
|
||||
it "students cannot duplicate" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:assignment_group => @group,
|
||||
:due_at => Time.zone.now + 1.week
|
||||
)
|
||||
api_call_as_user(@teacher, :post,
|
||||
api_call_as_user(@student, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 401 })
|
||||
end
|
||||
|
||||
it "should duplicate if teacher" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:assignment_group => @group,
|
||||
:due_at => Time.zone.now + 1.week
|
||||
)
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
|
@ -1068,6 +957,89 @@ describe AssignmentsApiController, type: :request do
|
|||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["name"]).to eq "some assignment Copy"
|
||||
end
|
||||
|
||||
it "should require non-quiz" do
|
||||
assignment = @course.assignments.create(:title => "some assignment")
|
||||
assignment.quiz = @course.quizzes.create
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should require non-discussion topic" do
|
||||
assignment = group_discussion_assignment.assignment
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should duplicate wiki page assignment" do
|
||||
assignment = wiki_page_assignment_model({ :title => "Wiki Page Assignment" })
|
||||
assignment.save!
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["name"]).to eq "Wiki Page Assignment Copy"
|
||||
end
|
||||
|
||||
it "should require non-deleted assignment" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:workflow_state => "deleted"
|
||||
)
|
||||
# assignment.save!
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment.id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment.id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
|
||||
it "should require existing assignment" do
|
||||
assignment = @course.assignments.create(
|
||||
:title => "some assignment",
|
||||
:workflow_state => "deleted"
|
||||
)
|
||||
assignment.save!
|
||||
assignment_id = Assignment.maximum(:id) + 100
|
||||
api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{assignment_id}/duplicate.json",
|
||||
{ :controller => "assignments_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:assignment_id => assignment_id.to_s },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,62 +34,8 @@ describe WikiPagesApiController, type: :request do
|
|||
wiki_page_model({ :title => "Wiki Page" })
|
||||
end
|
||||
|
||||
describe 'duplicate feature enabled' do
|
||||
before :once do
|
||||
a = @course.account
|
||||
a.enable_feature!(:duplicate_objects)
|
||||
a.save!
|
||||
end
|
||||
|
||||
it "returns unauthorized if not a teacher" do
|
||||
api_call_as_user(@student, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 401 })
|
||||
end
|
||||
|
||||
it "can duplicate wiki non-assignment if teacher" do
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["title"]).to eq "Wiki Page Copy"
|
||||
end
|
||||
|
||||
it "can duplicate wiki assignment if teacher" do
|
||||
wiki_page_assignment_model({ :title => "Assignment Wiki" })
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["title"]).to eq "Assignment Wiki Copy"
|
||||
end
|
||||
end
|
||||
|
||||
it 'duplicate feature disabled' do
|
||||
a = @course.account
|
||||
a.disable_feature!(:duplicate_objects)
|
||||
a.save!
|
||||
wiki_page_assignment_model({ :title => "Assignment Wiki" })
|
||||
api_call_as_user(@teacher, :post,
|
||||
it "returns unauthorized if not a teacher" do
|
||||
api_call_as_user(@student, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
|
@ -98,7 +44,36 @@ describe WikiPagesApiController, type: :request do
|
|||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 400 })
|
||||
{ :expected_status => 401 })
|
||||
end
|
||||
|
||||
it "can duplicate wiki non-assignment if teacher" do
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["title"]).to eq "Wiki Page Copy"
|
||||
end
|
||||
|
||||
it "can duplicate wiki assignment if teacher" do
|
||||
wiki_page_assignment_model({ :title => "Assignment Wiki" })
|
||||
json = api_call_as_user(@teacher, :post,
|
||||
"/api/v1/courses/#{@course.id}/pages/#{@page.url}/duplicate.json",
|
||||
{ :controller => "wiki_pages_api",
|
||||
:action => "duplicate",
|
||||
:format => "json",
|
||||
:course_id => @course.id.to_s,
|
||||
:url => @page.url },
|
||||
{},
|
||||
{},
|
||||
{ :expected_status => 200 })
|
||||
expect(json["title"]).to eq "Assignment Wiki Copy"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue