spec: add coverage for admin merge feature
Change-Id: I4d154a18fbefc63ac12ebea1ce19c5c8af5aa6ff Reviewed-on: https://gerrit.instructure.com/10442 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bryan Madsen <bryan@instructure.com>
This commit is contained in:
parent
8bd98c3a52
commit
3bd75cd6bc
|
@ -57,11 +57,11 @@
|
|||
:user_name => @user.name, :user_email => @user.email,
|
||||
:pending_other_user_name => @pending_other_user.name, :pending_other_user_email => @pending_other_user.email) %>
|
||||
<%= render :partial => 'merge_results', :locals => {:user => @user, :other_user => @pending_other_user} %>
|
||||
<a class="button" style="width: 6em;" href="<%= user_admin_merge_url(@user.id, :new_user_id => @pending_other_user.id) %>"><%= t('prepare_to_merge', "Prepare to Merge Users") %></a>
|
||||
<a class="button" id="prepare_to_merge" style="width: 6em;" href="<%= user_admin_merge_url(@user.id, :new_user_id => @pending_other_user.id) %>"><%= t('prepare_to_merge', "Prepare to Merge Users") %></a>
|
||||
<span style="font-size: 0.8em; padding-left: 50px;">
|
||||
<a class="button" style="width: 6em;" href="<%= user_admin_merge_url(@pending_other_user.id, :pending_user_id => @user.id) %>"><%= t('switch_user_positions', "Switch User Positions") %></a>
|
||||
<a class="button" style="width: 13em;" href="<%= user_admin_merge_url(@user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @user.name) %></a>
|
||||
<a class="button" style="width: 13em;" href="<%= user_admin_merge_url(@pending_other_user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @pending_other_user.name) %></a>
|
||||
<a class="button" id="switch_user_positions" style="width: 6em;" href="<%= user_admin_merge_url(@pending_other_user.id, :pending_user_id => @user.id) %>"><%= t('switch_user_positions', "Switch User Positions") %></a>
|
||||
<a class="button merge_with_other" style="width: 13em;" href="<%= user_admin_merge_url(@user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @user.name) %></a>
|
||||
<a class="button merge_with_other" style="width: 13em;" href="<%= user_admin_merge_url(@pending_other_user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @pending_other_user.name) %></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<p><%= t('merge_user_initial_instructions', "You've selected to merge the user, %{user_name} (%{user_email}) with another account.
|
||||
|
|
|
@ -28,4 +28,87 @@ describe "user selenium tests" do
|
|||
pseudonym.valid_password?('qwerty1').should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "admin merge" do
|
||||
STUDENT_1_ID = 'student1@example.com'
|
||||
STUDENT_2_ID = 'student2@example.com'
|
||||
WORKFLOW_STATES = %w(registered deleted)
|
||||
|
||||
def setup_user_merge(users)
|
||||
2.times { |i| get "/users/#{users[i].id}/admin_merge" }
|
||||
end
|
||||
|
||||
def reload_users(users)
|
||||
users.each { |user| user.reload }
|
||||
end
|
||||
|
||||
def submit_merge
|
||||
expect_new_page_load { f('#prepare_to_merge').click }
|
||||
expect_new_page_load { f('button[type="submit"]').click }
|
||||
end
|
||||
|
||||
def validate_login_info(user_id)
|
||||
f('#login_information').should include_text(user_id)
|
||||
end
|
||||
|
||||
before (:each) do
|
||||
course_with_admin_logged_in
|
||||
@student_1 = User.create!(:name => 'Student One')
|
||||
@student_1.register!
|
||||
@student_1.pseudonyms.create!(:unique_id => STUDENT_1_ID, :password => 'asdfasdf', :password_confirmation => 'asdfasdf')
|
||||
@course.enroll_user(@student_1).accept!
|
||||
|
||||
@student_2 = User.create!(:name => 'Student Two')
|
||||
@student_2.register!
|
||||
@student_2.pseudonyms.create!(:unique_id => STUDENT_2_ID, :password => 'asdfasdf', :password_confirmation => 'asdfasdf')
|
||||
@course.enroll_user(@student_2).accept!
|
||||
@users = [@student_1, @student_2]
|
||||
end
|
||||
|
||||
it "should merge user a with user b with navigate to another user function" do
|
||||
setup_user_merge(@users)
|
||||
submit_merge
|
||||
reload_users(@users)
|
||||
@student_1.workflow_state.should == 'registered'
|
||||
@student_2.workflow_state.should == 'deleted'
|
||||
validate_login_info(STUDENT_1_ID)
|
||||
end
|
||||
|
||||
it "should merge user b with user a with enter user id function" do
|
||||
get "/users/#{@student_1.id}/admin_merge"
|
||||
f('#manual_user_id').send_keys(@student_2.id)
|
||||
expect_new_page_load { f('button[type="submit"]').click }
|
||||
submit_merge
|
||||
reload_users(@users)
|
||||
@student_1.workflow_state.should == 'deleted'
|
||||
@student_2.workflow_state.should == 'registered'
|
||||
validate_login_info(STUDENT_2_ID)
|
||||
end
|
||||
|
||||
it "should validate switching the users to merge" do
|
||||
setup_user_merge(@users)
|
||||
user_names = ff('.result td')
|
||||
user_names[0].should include_text(@student_2.name)
|
||||
user_names[1].should include_text(@student_1.name)
|
||||
f('#switch_user_positions').click
|
||||
wait_for_ajax_requests
|
||||
user_names = ff('.result td')
|
||||
user_names[0].should include_text(@student_1.name)
|
||||
user_names[1].should include_text(@student_2.name)
|
||||
submit_merge
|
||||
reload_users(@users)
|
||||
@student_1.workflow_state.should == 'deleted'
|
||||
@student_2.workflow_state.should == 'registered'
|
||||
validate_login_info(STUDENT_1_ID)
|
||||
end
|
||||
|
||||
it "should cancel a merge and validate both users still exist" do
|
||||
setup_user_merge(@users)
|
||||
expect_new_page_load { f('#prepare_to_merge').click }
|
||||
expect_new_page_load { f('.button-secondary').click }
|
||||
f('#courses_menu_item').should be_displayed
|
||||
@student_1.workflow_state.should == 'registered'
|
||||
@student_2.workflow_state.should == 'registered'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue