Sha256: bf67c8f63ec08720dd4af409489934cb945e576825bf88a3dab5c8947842fd53

Contents?: true

Size: 1.06 KB

Versions: 14

Compression:

Stored size: 1.06 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, client: nil)
      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, client: nil)
      end

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/mongo/operation/remove_user_spec.rb
mongo-2.14.1 spec/mongo/operation/remove_user_spec.rb
mongo-2.13.2 spec/mongo/operation/remove_user_spec.rb
mongo-2.14.0 spec/mongo/operation/remove_user_spec.rb
mongo-2.14.0.rc1 spec/mongo/operation/remove_user_spec.rb
mongo-2.13.1 spec/mongo/operation/remove_user_spec.rb
mongo-2.12.4 spec/mongo/operation/remove_user_spec.rb
mongo-2.13.0 spec/mongo/operation/remove_user_spec.rb
mongo-2.12.3 spec/mongo/operation/remove_user_spec.rb
mongo-2.13.0.rc1 spec/mongo/operation/remove_user_spec.rb
mongo-2.12.2 spec/mongo/operation/remove_user_spec.rb
mongo-2.13.0.beta1 spec/mongo/operation/remove_user_spec.rb
mongo-2.12.1 spec/mongo/operation/remove_user_spec.rb
mongo-2.12.0.rc0 spec/mongo/operation/remove_user_spec.rb