fix wiki page creation for students
test plan: * create a course * create a page, allowing "Teachers and students" to edit the page * as a student, should be able to edit the page, but should not be able to link to new pages in the wiki sidebar * edit the settings to allow "Teachers and Students" to "create, rename and edit course wiki pages" * as a student, should be able to link to new pages * should also be able to follow the links and create the new pages there closes #CNVS-18825 Change-Id: If272218522e36310edf95fe77fe3b8af03456725 Reviewed-on: https://gerrit.instructure.com/49678 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
3f0fe14021
commit
e25ae7353b
|
@ -504,7 +504,7 @@ class WikiPagesApiController < ApplicationController
|
|||
@set_front_page = true
|
||||
@set_as_front_page = true
|
||||
else
|
||||
@page.workflow_state = 'unpublished'
|
||||
@page.workflow_state = @wiki.grants_right?(@current_user, session, :manage) ? 'unpublished' : 'active'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,15 +31,17 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= link_to t('links.new_page', "Link to a New Page"), polymorphic_url([@context, :wiki_page], action: :new), :id => 'new_page_link', :class => "add" %>
|
||||
<form id="new_page_drop_down" style="display:none; margin: 5px;">
|
||||
<div class="row-fluid">
|
||||
<label for="new_page_name"><%= t('new_page_name', %{What would you like to call the new page?}) %></label><br />
|
||||
<input type="text" name="new_page_name" id="new_page_name" class="span12">
|
||||
<input type="hidden" name="new_page_url_prefix" value="<%= polymorphic_path([@context, :wiki_pages]) %>" id="new_page_url_prefix" />
|
||||
<button id="new_page_submit" class="btn btn-small" type="submit"><%= t('buttons.insert_link', %{Insert Link}) %></button>
|
||||
</div>
|
||||
</form>
|
||||
<% if can_do(@wiki, @current_user, :create_page) %>
|
||||
<%= link_to t('links.new_page', "Link to a New Page"), polymorphic_url([@context, :wiki_page], action: :new), :id => 'new_page_link', :class => "add" %>
|
||||
<form id="new_page_drop_down" style="display:none; margin: 5px;">
|
||||
<div class="row-fluid">
|
||||
<label for="new_page_name"><%= t('new_page_name', %{What would you like to call the new page?}) %></label><br />
|
||||
<input type="text" name="new_page_name" id="new_page_name" class="span12">
|
||||
<input type="hidden" name="new_page_url_prefix" value="<%= polymorphic_path([@context, :wiki_pages]) %>" id="new_page_url_prefix" />
|
||||
<button id="new_page_submit" class="btn btn-small" type="submit"><%= t('buttons.insert_link', %{Insert Link}) %></button>
|
||||
</div>
|
||||
</form>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -70,6 +70,39 @@ describe "Wiki pages and Tiny WYSIWYG editor" do
|
|||
|
||||
expect(f('a.edit-wiki')).to be_displayed
|
||||
end
|
||||
|
||||
it "should allow students to create new pages if enabled" do
|
||||
@course.default_wiki_editing_roles = "teachers,students"
|
||||
@course.save!
|
||||
|
||||
get "/courses/#{@course.id}/pages"
|
||||
wait_for_ajax_requests
|
||||
f('.new_page').click
|
||||
f("#title").send_keys("new page")
|
||||
|
||||
expect_new_page_load { f('form.edit-form button.submit').click }
|
||||
new_page = @course.wiki.wiki_pages.last
|
||||
expect(new_page).to be_published
|
||||
end
|
||||
|
||||
it "should not allow students to add links to new pages unless they can create pages" do
|
||||
create_wiki_page("test_page", false, "public")
|
||||
get "/courses/#{@course.id}/pages/test_page/edit"
|
||||
wait_for_ajax_requests
|
||||
|
||||
expect(f('#new_page_link')).to be_nil
|
||||
|
||||
@course.default_wiki_editing_roles = "teachers,students"
|
||||
@course.save!
|
||||
|
||||
get "/courses/#{@course.id}/pages/somenewpage/edit" # page that doesn't exist
|
||||
wait_for_ajax_requests
|
||||
|
||||
expect(f('#new_page_link')).to_not be_nil
|
||||
expect_new_page_load { f('form.edit-form button.submit').click }
|
||||
new_page = @course.wiki.wiki_pages.last
|
||||
expect(new_page).to be_published
|
||||
end
|
||||
|
||||
it "should notify users when wiki page gets changed" do
|
||||
set_notification_policy
|
||||
|
|
Loading…
Reference in New Issue