|
372 | 372 | end |
373 | 373 |
|
374 | 374 | context 'account admin creating users' do |
375 | | - it "should create a pre_registered user (in the correct account)" do |
376 | | - account = Account.create! |
377 | | - user_with_pseudonym(:account => account) |
378 | | - account.add_user(@user) |
379 | | - user_session(@user, @pseudonym) |
380 | | - post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :sis_user_id => 'testsisid' }, :user => { :name => 'Jacob Fugal' } |
381 | | - response.should be_success |
382 | | - p = Pseudonym.find_by_unique_id('jacob@instructure.com') |
383 | | - p.account_id.should == account.id |
384 | | - p.should be_active |
385 | | - p.sis_user_id.should == 'testsisid' |
386 | | - p.user.should be_pre_registered |
387 | | - end |
388 | 375 |
|
389 | | - it "should create users with non-email pseudonyms" do |
390 | | - account = Account.create! |
391 | | - user_with_pseudonym(:account => account) |
392 | | - account.add_user(@user) |
393 | | - user_session(@user, @pseudonym) |
394 | | - post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob', :sis_user_id => 'testsisid' }, :user => { :name => 'Jacob Fugal' } |
395 | | - response.should be_success |
396 | | - p = Pseudonym.find_by_unique_id('jacob') |
397 | | - p.account_id.should == account.id |
398 | | - p.should be_active |
399 | | - p.sis_user_id.should == 'testsisid' |
400 | | - p.user.should be_pre_registered |
| 376 | + describe 'successfully' do |
| 377 | + let!(:account) { Account.create! } |
| 378 | + |
| 379 | + before do |
| 380 | + user_with_pseudonym(:account => account) |
| 381 | + account.add_user(@user) |
| 382 | + user_session(@user, @pseudonym) |
| 383 | + end |
| 384 | + |
| 385 | + it "should create a pre_registered user (in the correct account)" do |
| 386 | + post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :sis_user_id => 'testsisid' }, :user => { :name => 'Jacob Fugal' } |
| 387 | + response.should be_success |
| 388 | + p = Pseudonym.find_by_unique_id('jacob@instructure.com') |
| 389 | + p.account_id.should == account.id |
| 390 | + p.should be_active |
| 391 | + p.sis_user_id.should == 'testsisid' |
| 392 | + p.user.should be_pre_registered |
| 393 | + end |
| 394 | + |
| 395 | + it "should create users with non-email pseudonyms" do |
| 396 | + post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob', :sis_user_id => 'testsisid' }, :user => { :name => 'Jacob Fugal' } |
| 397 | + response.should be_success |
| 398 | + p = Pseudonym.find_by_unique_id('jacob') |
| 399 | + p.account_id.should == account.id |
| 400 | + p.should be_active |
| 401 | + p.sis_user_id.should == 'testsisid' |
| 402 | + p.user.should be_pre_registered |
| 403 | + end |
| 404 | + |
| 405 | + |
| 406 | + it "should not require acceptance of the terms or birthdate" do |
| 407 | + post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com' }, :user => { :name => 'Jacob Fugal' } |
| 408 | + response.should be_success |
| 409 | + end |
| 410 | + |
| 411 | + it "should allow setting a password" do |
| 412 | + post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :password => 'asdfasdf', :password_confirmation => 'asdfasdf' }, :user => { :name => 'Jacob Fugal' } |
| 413 | + u = User.find_by_name 'Jacob Fugal' |
| 414 | + u.should be_present |
| 415 | + u.pseudonym.should_not be_password_auto_generated |
| 416 | + end |
| 417 | + |
401 | 418 | end |
402 | 419 |
|
403 | 420 | it "should not allow an admin to set the sis id when creating a user if they don't have privileges to manage sis" do |
|
447 | 464 | p = Pseudonym.find_by_unique_id('jacob@instructure.com') |
448 | 465 | Message.find(:first, :conditions => { :communication_channel_id => p.user.email_channel.id, :notification_id => notification.id }).should be_nil |
449 | 466 | end |
450 | | - |
451 | | - it "should not require acceptance of the terms" do |
452 | | - account = Account.create! |
453 | | - user_with_pseudonym(:account => account) |
454 | | - account.add_user(@user) |
455 | | - user_session(@user, @pseudonym) |
456 | | - post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com' }, :user => { :name => 'Jacob Fugal' } |
457 | | - response.should be_success |
458 | | - end |
459 | | - |
460 | | - it "should not require the birthdate" do |
461 | | - account = Account.create! |
462 | | - user_with_pseudonym(:account => account) |
463 | | - account.add_user(@user) |
464 | | - user_session(@user, @pseudonym) |
465 | | - post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com' }, :user => { :name => 'Jacob Fugal' } |
466 | | - response.should be_success |
467 | | - end |
468 | | - |
469 | | - it "should allow setting a password" do |
470 | | - account = Account.create! |
471 | | - user_with_pseudonym(:account => account) |
472 | | - account.add_user(@user) |
473 | | - user_session(@user, @pseudonym) |
474 | | - post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :password => 'lolwtf', :password_confirmation => 'lolwtf' }, :user => { :name => 'Jacob Fugal' } |
475 | | - response.should be_success |
476 | | - u = User.find_by_name 'Jacob Fugal' |
477 | | - u.should be_present |
478 | | - u.pseudonym.should_not be_password_auto_generated |
479 | | - end |
480 | 467 | end |
481 | 468 | end |
482 | 469 |
|
|
643 | 630 | end |
644 | 631 |
|
645 | 632 | describe "GET 'admin_merge'" do |
646 | | - it "should not allow you to view any user by id" do |
| 633 | + let(:account) { Account.create! } |
| 634 | + |
| 635 | + before do |
647 | 636 | account_admin_user |
648 | 637 | user_session(@admin) |
649 | | - user_with_pseudonym(:account => Account.create!) |
| 638 | + end |
| 639 | + |
| 640 | + describe 'as site admin' do |
| 641 | + before { Account.site_admin.add_user(@admin) } |
| 642 | + |
| 643 | + it 'warns about merging a user with itself' do |
| 644 | + user = User.create! |
| 645 | + get 'admin_merge', :user_id => user.id, :pending_user_id => user.id |
| 646 | + flash[:error].should == 'You can\'t merge an account with itself.' |
| 647 | + end |
650 | 648 |
|
| 649 | + it 'does not issue warning if the users are different' do |
| 650 | + user = User.create! |
| 651 | + other_user = User.create! |
| 652 | + get 'admin_merge', :user_id => user.id, :pending_user_id => other_user.id |
| 653 | + flash[:error].should be_nil |
| 654 | + end |
| 655 | + end |
| 656 | + |
| 657 | + it "should not allow you to view any user by id" do |
| 658 | + user_with_pseudonym(:account => account) |
651 | 659 | get 'admin_merge', :user_id => @admin.id, :pending_user_id => @user.id |
652 | 660 | response.should be_success |
653 | 661 | assigns[:pending_other_user].should be_nil |
|
0 commit comments