diff --git a/spec/selenium/groups_teacher_spec.rb b/spec/selenium/groups_teacher_spec.rb index dae34dd486b..53da75ddc17 100644 --- a/spec/selenium/groups_teacher_spec.rb +++ b/spec/selenium/groups_teacher_spec.rb @@ -9,7 +9,7 @@ describe "new groups" do course_with_teacher_logged_in end - it "should allow teachers to add a group set", :priority => "1", :test_id => 94152 do + it "should allow teachers to add a group set", priority: "1", test_id: 94152 do get "/courses/#{@course.id}/groups" f('#add-group-set').click wait_for_ajaximations @@ -20,7 +20,7 @@ describe "new groups" do expect(fj('.collectionViewItems[role=tablist]>li:last-child').text).to match "Test Group Set" end - it "should allow teachers to create groups within group sets", :priority => "1", :test_id => 94153 do + it "should allow teachers to create groups within group sets", priority: "1", test_id: 94153 do seed_groups(1,0) get "/courses/#{@course.id}/groups" @@ -34,11 +34,9 @@ describe "new groups" do expect(fj('.collectionViewItems.unstyled.groups-list>li:last-child')).to include_text("Test Group") end - it "should allow teachers to add a student to a group", :priority => "1", :test_id => 94155 do - # Creates one user - seed_users(1) - # Creates one group set with one group inside it - seed_groups(1,1) + it "should allow teachers to add a student to a group", priority: "1", test_id: 94155 do + # Creates one user, and one groupset with a group inside it + group_test_setup(1,1,1) get "/courses/#{@course.id}/groups" @@ -57,13 +55,11 @@ describe "new groups" do expect(f('.group-user-name')).to include_text(@student.name) end - it "should allow teachers to move a student to a different group", :priority => "1", :test_id => 94157 do - seed_users(1) - # Creates 1 groupset and 2 groups within it - seed_groups(1,2) + it "should allow teachers to move a student to a different group", priority: "1", test_id: 94157 do + # Creates 1 user, 1 groupset, and 2 groups within the groupset + group_test_setup(1,1,2) # Add seeded student to first seeded group - @testgroup[0].add_user @student - @testgroup[0].save! + add_user_to_group(@student,@testgroup[0]) get "/courses/#{@course.id}/groups" @@ -91,5 +87,25 @@ describe "new groups" do wait_for_ajaximations expect(f('.group-user')).to include_text(@student.name) end + + it "should allow teachers to remove a student from a group", priority: "1", test_id: 94158 do + group_test_setup + add_user_to_group(@student,@testgroup[0]) + + get "/courses/#{@course.id}/groups" + + f('.toggle-group').click + wait_for_ajaximations + + # Deletes the user + f('.group-user-actions').click + wait_for_ajaximations + f('.remove-from-group').click + wait_for_ajaximations + + expect(f('.ui-cnvs-scrollable')).to include_text(@student.name) + expect(f('.unassigned-users-heading')).to include_text("Unassigned Students (1)") + expect(f('.group-summary')).to include_text("0 students") + end end end diff --git a/spec/selenium/helpers/groups_common.rb b/spec/selenium/helpers/groups_common.rb index 02c0d708f02..adb4ca5c543 100644 --- a/spec/selenium/helpers/groups_common.rb +++ b/spec/selenium/helpers/groups_common.rb @@ -5,15 +5,26 @@ def seed_users(count) end end -# Creates group sets equal to groupset_count and groups within each group set equal to inner_group_count -def seed_groups(groupset_count, inner_group_count) +# Creates group sets equal to groupset_count and groups within each group set equal to groups_per_set +def seed_groups(groupset_count, groups_per_set) @group_category = [] @testgroup = [] groupset_count.times do |n| @group_category << @course.group_categories.create!(:name => "Test Group Set #{n+1}") - inner_group_count.times do |i| + groups_per_set.times do |i| @testgroup << @course.groups.create!(:name => "Test Group #{i+1}", :group_category => @group_category[n]) end end +end + +# Sets up groups and users for testing. Default is 1 user, 1 groupset, and 1 group per groupset. +def group_test_setup(user_count = 1, groupset_count = 1, groups_per_set = 1) + seed_users(user_count) + seed_groups(groupset_count, groups_per_set) +end + +def add_user_to_group(user,group) + group.add_user user + group.save! end \ No newline at end of file