Skip to content
Extraits de code Groupes Projets
user_spec.rb 32,7 ko
Newer Older
  • Learn to ignore specific revisions
  •     end
        
        it "queues up a job to send the reset password instructions" do
          user = Factory :user
          Resque.should_receive(:enqueue).with(Jobs::ResetPassword, user.id)
          user.send_reset_password_instructions
    
    
      context "close account" do
        before do
          @user = bob
        end
    
        describe "#close_account!" do
    
          it 'locks the user out' do
            @user.close_account!
            @user.reload.access_locked?.should be_true
          end
    
          it 'creates an account deletion' do
            expect{
              @user.close_account!
            }.to change(AccountDeletion, :count).by(1)
    
    
          it 'calls person#lock_access!' do
            @user.person.should_receive(:lock_access!)
            @user.close_account!
          end
        end
    
        describe "#clear_account!" do
    
          it 'resets the password to a random string' do
            random_pass = "12345678909876543210"
            ActiveSupport::SecureRandom.should_receive(:hex).and_return(random_pass)
    
            @user.valid_password?(random_pass)
          end
    
          it 'clears all the clearable fields' do
    
            attributes = @user.send(:clearable_fields)
    
            attributes.each do |attr|
              @user.send(attr.to_sym).should be_blank
            end
          end
        end
    
        describe "#clearable_attributes" do
    
          it 'returns the clearable fields' do
            user = Factory.create :user
    
            user.send(:clearable_fields).sort.should == %w{
              getting_started
              disable_mail
              language
              email
              invitation_token
              invitation_sent_at
              reset_password_token
              remember_token
              remember_created_at
              sign_in_count
              current_sign_in_at
              last_sign_in_at
              current_sign_in_ip
              last_sign_in_ip
              invitation_service
              invitation_identifier
              invitation_limit
              invited_by_id
              invited_by_type
              authentication_token
              unconfirmed_email
              confirm_email_token
              show_community_spotlight_in_stream
            }.sort
          end