Sha256: a27aedb60e56f1b58464ad990559ca31d949cdcf86374be288ca8b855b634928

Contents?: true

Size: 1.02 KB

Versions: 28

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Mongo::Operation::RemoveUser do

  describe '#execute' do

    before do
      users = root_authorized_client.database.users
      if users.info('durran').any?
        users.remove('durran')
      end
      users.create(
        'durran',
        password: 'password', roles: [ Mongo::Auth::Roles::READ_WRITE ]
      )
    end

    let(:operation) do
      described_class.new(user_name: 'durran', db_name: SpecConfig.instance.test_db)
    end

    context 'when user removal was successful' do

      let!(:response) do
        operation.execute(root_authorized_primary)
      end

      it 'removes the user from the database' do
        expect(response).to be_successful
      end
    end

    context 'when removal was not successful' do

      before do
        operation.execute(root_authorized_primary)
      end

      it 'raises an exception' do
        expect {
          operation.execute(root_authorized_primary)
        }.to raise_error(Mongo::Error::OperationFailure)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
mongo-2.9.0.rc1 spec/mongo/operation/remove_user_spec.rb
mongo-2.9.0.rc0 spec/mongo/operation/remove_user_spec.rb
mongo-2.8.0 spec/mongo/operation/remove_user_spec.rb
mongo-2.7.2 spec/mongo/operation/remove_user_spec.rb
mongo-2.8.0.rc0 spec/mongo/operation/remove_user_spec.rb
mongo-2.7.1 spec/mongo/operation/remove_user_spec.rb
mongo-2.7.0 spec/mongo/operation/remove_user_spec.rb
mongo-2.7.0.rc0 spec/mongo/operation/remove_user_spec.rb