Fixed reply option permissions
fixes CNVS-22078 test plan: - Make sure "Let students edit or delete their own discussion posts" is enabled - As a student reply to a discussion - Conclude the students enrollment - As the same student go to your reply and clicking the gear you still have the ability to edit it - Along the same vein test threaded discussions and side comments Change-Id: I8e1fc84b097cb96b2fa28654eb299d3276c045d7 Reviewed-on: https://gerrit.instructure.com/62389 Reviewed-by: Brian Finney <bfinney@instructure.com> Tested-by: Jenkins QA-Review: Michael Hargiss <mhargiss@instructure.com> Product-Review: Jason Sparks <jsparks@instructure.com>
This commit is contained in:
parent
ed8ccffa9b
commit
eeb024eb28
|
@ -816,7 +816,7 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
given { |user| self.grants_right?(user, :read) }
|
||||
can :read_replies
|
||||
|
||||
given { |user| self.user && self.user == user && self.visible_for?(user) && !self.locked_for?(user, :check_policies => true) }
|
||||
given { |user| self.user && self.user == user && self.visible_for?(user) && !self.locked_for?(user, :check_policies => true) && !context.concluded?}
|
||||
can :reply
|
||||
|
||||
given { |user| self.user && self.user == user && self.available_for?(user) && context.user_can_manage_own_discussion_posts?(user) && context.grants_right?(user, :participate_as_student) }
|
||||
|
|
|
@ -49,10 +49,10 @@
|
|||
{{else}}
|
||||
<li><a href="#topic" data-pushstate><i class="icon-discussion"></i> {{#t "go_to_topic"}}Go To Topic{{/t}}</a></li>
|
||||
{{/if}}
|
||||
{{#if canModerate}}
|
||||
{{#ifAll canModerate canReply }}
|
||||
<li><a data-event="edit" href="#"><i class="icon-edit"></i> {{#t "edit"}}Edit{{/t}}</a></li>
|
||||
<li><a data-event="remove" href="#"><i class="icon-trash"></i> {{#t "delete"}}Delete{{/t}}</a></li>
|
||||
{{/if}}
|
||||
{{/ifAll}}
|
||||
{{#if speedgraderUrl}}
|
||||
<li><a href="{{speedgraderUrl}}"><i class="icon-check"></i> {{#t "open_in_speedgrader"}}Open in SpeedGrader{{/t}}</a></li>
|
||||
{{/if}}
|
||||
|
|
|
@ -61,6 +61,28 @@ describe "threaded discussions" do
|
|||
expect(entry.reload.message).to match(edit_text)
|
||||
end
|
||||
|
||||
it "should not allow edits for a concluded student", priority: "2", test_id: 222526 do
|
||||
student_enrollment = course_with_student(:course => @course, :user => @student, :active_enrollment => true)
|
||||
entry = @topic.discussion_entries.create!(user: @student,
|
||||
message: 'new threaded reply from student')
|
||||
user_session(@student)
|
||||
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
student_enrollment.send("conclude")
|
||||
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
check_edit_entry(entry)
|
||||
end
|
||||
|
||||
it "should not allow deletes for a concluded student", priority: "2", test_id: 222526 do
|
||||
student_enrollment = course_with_student(:course => @course, :user => @student, :active_enrollment => true)
|
||||
entry = @topic.discussion_entries.create!(user: @student,
|
||||
message: 'new threaded reply from student')
|
||||
user_session(@student)
|
||||
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
student_enrollment.send("conclude")
|
||||
get "/courses/#{@course.id}/discussion_topics/#{@topic.id}"
|
||||
check_delete_entry(entry)
|
||||
end
|
||||
|
||||
it "should allow edits to discussion with replies", priority: "1", test_id: 150513 do
|
||||
reply_depth = 3
|
||||
reply_depth.times { |i| @topic.discussion_entries.create!(user: @student,
|
||||
|
|
|
@ -36,6 +36,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
|
|||
validate_entry_text(entry, text)
|
||||
end
|
||||
|
||||
def check_edit_entry(entry)
|
||||
wait_for_ajaximations
|
||||
check_entry_option(entry, '.al-options:visible li:eq(1) a')
|
||||
end
|
||||
|
||||
def delete_entry(entry)
|
||||
wait_for_ajaximations
|
||||
click_entry_option(entry, '.al-options:visible li:last-child a')
|
||||
|
@ -46,6 +51,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
|
|||
expect(entry.workflow_state).to eq 'deleted'
|
||||
end
|
||||
|
||||
def check_delete_entry(entry)
|
||||
wait_for_ajaximations
|
||||
check_entry_option(entry, '.al-options:visible li:eq(2) a')
|
||||
end
|
||||
|
||||
def add_reply(message = 'message!', attachment = nil)
|
||||
@last_entry ||= f('#discussion_topic')
|
||||
@last_entry.find_element(:css, '.discussion-reply-action').click
|
||||
|
@ -77,6 +87,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
|
|||
end
|
||||
end
|
||||
|
||||
def check_entry_option(discussion_entry, menu_item_selector)
|
||||
li_selector = "#entry-#{discussion_entry.id}"
|
||||
expect(fj(li_selector)).to be_displayed
|
||||
expect(fj("#{li_selector} .al-trigger")).to be_displayed
|
||||
fj("#{li_selector} .al-trigger").click
|
||||
wait_for_ajaximations
|
||||
menu_item = fj(menu_item_selector)
|
||||
expect(menu_item).to be_nil
|
||||
end
|
||||
|
||||
def click_entry_option(discussion_entry, menu_item_selector)
|
||||
li_selector = "#entry-#{discussion_entry.id}"
|
||||
expect(fj(li_selector)).to be_displayed
|
||||
|
|
Loading…
Reference in New Issue