Sha256: 3b4d4346bcbd5c9a8986b285a594e7643414deb1cbb725026245a574f9e0d653

Contents?: true

Size: 1.76 KB

Versions: 54

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe Aptible::CLI::Agent do
  let(:app) { Fabricate(:app) }
  let(:operation) { Fabricate(:operation, resource: app) }
  before { allow(subject).to receive(:ensure_app).and_return(app) }

  describe '#restart' do
    it 'restarts the app' do
      expect(app).to receive(:create_operation!).with(type: 'restart')
        .and_return(operation)
      expect(subject).to receive(:attach_to_operation_logs).with(operation)

      subject.send('restart')
    end

    it 'does not require the --force flag for a regular restart' do
      app.account.type = 'production'
      expect(app).to receive(:create_operation!)
      expect(subject).to receive(:attach_to_operation_logs)

      subject.send('restart')
    end

    it 'uses captain_comeback_restart if --simulate-oom is passed' do
      subject.options = { simulate_oom: true }
      expect(app).to receive(:create_operation!)
        .with(type: 'captain_comeback_restart')
        .and_return(operation)
      expect(subject).to receive(:attach_to_operation_logs).with(operation)

      subject.send('restart')
    end

    it 'fails a CC restart if the --force flag is not passed for a prod app' do
      subject.options = { simulate_oom: true }
      app.account.type = 'production'
      expect(app).not_to receive(:create_operation!)
      expect(subject).not_to receive(:attach_to_operation_logs)

      expect { subject.send('restart') }.to raise_error(/are you sure/i)
    end

    it 'creates a CC restart if the --force flag is passed for a prod app' do
      subject.options = { simulate_oom: true, force: true }
      app.account.type = 'production'
      expect(app).to receive(:create_operation!)
      expect(subject).to receive(:attach_to_operation_logs)

      subject.send('restart')
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
aptible-cli-0.24.2 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.24.1 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.24.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.23.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.22.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.21.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.20.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.9 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.7 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.6 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.4 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.3 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.2 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.1 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.19.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.18.3 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.18.2 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.18.1 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.18.0 spec/aptible/cli/subcommands/restart_spec.rb
aptible-cli-0.17.2 spec/aptible/cli/subcommands/restart_spec.rb