Sha256: 5ec1e1724a6cfbf7231027f0592621d084a2ccb6e8ddb1d77988d607d6bc9a30

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Mongo::Operation::Write::RemoveUser do

  describe '#execute' do

    before do
      root_authorized_client.database.users.create(
        'durran',
        password: 'password', roles: [ Mongo::Auth::Roles::READ_WRITE ]
      )
    end

    let(:operation) do
      described_class.new(user_name: 'durran', db_name: 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', if: write_command_enabled? do
        expect {
          operation.execute(root_authorized_primary)
        }.to raise_error(Mongo::Error::OperationFailure)
      end

      it 'does not raise an exception', unless: write_command_enabled? do
        expect(operation.execute(root_authorized_primary).written_count).to eq(0)
      end
    end
  end
end

Version data entries

13 entries across 11 versions & 2 rubygems

Version Path
mongo-2.5.0.beta spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.3 spec/mongo/operation/write/remove_user_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongo-2.4.1/spec/mongo/operation/write/remove_user_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongo-2.4.2/spec/mongo/operation/write/remove_user_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongo-2.4.1/spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.2 spec/mongo/operation/write/remove_user_spec.rb
tdiary-5.0.4 vendor/bundle/gems/mongo-2.4.1/spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.1 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.3.1 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.0.rc1 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.4.0.rc0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.3.0 spec/mongo/operation/write/remove_user_spec.rb