Skip to content
Snippets Groups Projects
Commit 3962cea4 authored by Simon Williams's avatar Simon Williams Committed by Brian Palmer
Browse files

link observer immediately after adding; fixes #7528

fix the javascript so that the required attributes are added after the ajax
request, so that the link can be made immediately rather than needing to first
refresh the page.

test-plan:
- in a course with a student, go to course settings, users tab
- add an observer
- without reloading the page, try linking that observer to someone

Change-Id: Ibaf54372f103d52755f92c0b1c966c97044f27ec
Reviewed-on: https://gerrit.instructure.com/9128


Tested-by: default avatarHudson <hudson@instructure.com>
Reviewed-by: default avatarCody Cutrer <cody@instructure.com>
parent 5c52e2a0
No related merge requests found
......@@ -69,7 +69,7 @@
<div class="email"><%= enrollment.try_rescue(:user).try_rescue(:email) %></div>
<%# [nil] because we want a blank template to show up when enrollments is nil %>
<% (enrollments || [nil]).each do |enrollment| %>
<div class="enrollment_link enrollment_<%= enrollment.try_rescue(:id)%>">
<div class="enrollment_link enrollment_<%= enrollment.try_rescue(:id) || "blank" %>">
<div class="associated_user associated" style="<%= hidden unless enrollment.try_rescue(:associated_user_id) %>">
<%= before_label :linked_to, "linked to" %>
<span class="associated_user_name associated_user_link"><%= context_user_name(@context, enrollment.try_rescue(:associated_user_id)) %></span>
......
......@@ -189,13 +189,14 @@ require([
}
});
enrollment.enrollment_id = enrollment.id;
var already_existed = true;
if(!$("#enrollment_" + enrollment.id).length) {
already_existed = false;
var $enrollment = $enrollment_blank
.clone(true)
.fillTemplateData({
textValues: ['name', 'membership_type', 'email'],
textValues: ['name', 'membership_type', 'email', 'enrollment_id'],
id: 'enrollment_' + enrollment.id,
hrefValues: ['id', 'user_id', 'pseudonym_id', 'communication_channel_id'],
data: enrollment
......@@ -211,6 +212,9 @@ require([
.animate({'backgroundColor': '#FFFFFF'}, 2000, function() {
$(this).css('backgroundColor', '');
});
$enrollment.find('.enrollment_link')
.removeClass('enrollment_blank')
.addClass('enrollment_' + enrollment.id);
$enrollment
.parents(".user_list")
.scrollToVisible($enrollment);
......
......@@ -112,20 +112,20 @@ describe "people" do
end
it "should link an observer to student after adding the observer to the course" do
pending("bug 7528 - Unexpected error if trying to link an observer to student after adding the observer to the course") do
expect_new_page_load { driver.find_element(:link, 'Manage Users').click }
add_users_button = driver.find_element(:css, '.add_users_link')
add_users_button.click
add_user("Observers", @test_observer.name, 'ul.user_list.observer_enrollments')
find_with_jquery('.associated_user_link:visible').click #driver.find_element = element hidden
link_student_form = driver.find_element(:id, 'link_student_dialog_form')
click_option('#student_enrollment_link_option', @student_1.name)
link_student_form.find_element(:css, '.save_button').click
wait_for_ajax_requests
ObserverEnrollment.count.should == 1
driver.find_element(:css, '.error_text').should_not be_displayed
#TODO - should add validation that the student was linked when the bug fix goes in
end
expect_new_page_load { driver.find_element(:link, 'Manage Users').click }
add_users_button = driver.find_element(:css, '.add_users_link')
add_users_button.click
add_user("Observers", @test_observer.name, 'ul.user_list.observer_enrollments')
ObserverEnrollment.count.should == 1
oe = ObserverEnrollment.first
find_with_jquery('.associated_user_link:visible').click #driver.find_element = element hidden
link_student_form = f('#link_student_dialog_form')
click_option('#student_enrollment_link_option', @student_1.name)
link_student_form.find_element(:css, '.save_button').click
wait_for_ajaximations
f(".enrollment_#{oe.id} .associated_user_name").should include_text @student_1.name
oe.reload.associated_user_id.should == @student_1.id
end
it "should make a new set of student groups" do
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment