Sha256: e2765ccf1c83eb6f9db1e175146caf3f98a994e11b88ce37fd60278bddd1b71c

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Fluentd::AgentsController do
  before do
    allow(controller).to receive(:current_user).and_return true
    allow(controller).to receive(:find_fluentd).and_return(nil)
    controller.instance_variable_set(:@fluentd, double(agent: @agent = double(:agent)))
  end

  describe "when the action succeeds" do
    it "stops" do
      expect(@agent).to receive(:stop).and_return true
      put :stop
    end

    it "starts" do
      expect(@agent).to receive(:start).and_return true
      put :start
    end

    it "restarts" do
      expect(@agent).to receive(:restart).and_return true
      put :restart
    end
  end

  describe "when the action does not succeed" do
    it "stops" do
      expect(@agent).to receive(:stop).and_return false
      put :stop
    end

    it "starts" do
      expect(@agent).to receive(:start).and_return false
      expect(@agent).to receive(:log_tail).with(1).and_return ["some message"]
      put :start
    end

    it "restarts" do
      expect(@agent).to receive(:restart).and_return false
      expect(@agent).to receive(:log_tail).with(1).and_return ["some message"]
      put :restart
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluentd-ui-0.3.14 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.13 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.12 spec/controllers/fluentd/agents_controller_spec.rb