mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 02:46:11 +02:00
Merge pull request #128 from rthbound/adds_tests_to_polling_controller
Adds tests to polling controller
This commit is contained in:
commit
b617c01010
@ -1,20 +1,17 @@
|
||||
class PollingController < ApplicationController
|
||||
def alerts
|
||||
alerts = []
|
||||
installing_gems.each do |plugin|
|
||||
target = plugin.gem_name.dup
|
||||
target << "(#{plugin.version})" if plugin.version
|
||||
alerts << {
|
||||
text: I18n.t('terms.installing', target: target)
|
||||
}
|
||||
end
|
||||
uninstalling_gems.each do |plugin|
|
||||
target = plugin.gem_name.dup
|
||||
target << "(#{plugin.version})" if plugin.version
|
||||
alerts << {
|
||||
text: I18n.t('terms.uninstalling', target: target)
|
||||
}
|
||||
|
||||
%w{ installing uninstalling }.each do |action|
|
||||
send("#{action}_gems").each do |plugin|
|
||||
target = plugin.gem_name.dup
|
||||
target << "(#{plugin.version})" if plugin.version
|
||||
alerts << {
|
||||
text: I18n.t("terms.#{action}", target: target)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
render json: alerts
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,39 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe PollingController do
|
||||
describe 'polling for alerts' do
|
||||
before do
|
||||
allow(controller).to receive(:current_user).and_return true
|
||||
end
|
||||
|
||||
after do
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'may find nothing' do
|
||||
expect(controller).to receive(:uninstalling_gems).and_return []
|
||||
expect(controller).to receive(:installing_gems).and_return []
|
||||
get :alerts
|
||||
end
|
||||
|
||||
it 'may find gems being uninstalled' do
|
||||
expect(controller).to receive(:uninstalling_gems).and_return [
|
||||
double(gem_name: "foobar", version: "1.0.0")
|
||||
]
|
||||
|
||||
allow(controller).to receive(:installing_gems).and_return []
|
||||
|
||||
get :alerts
|
||||
end
|
||||
|
||||
it 'may find gems being installed' do
|
||||
expect(controller).to receive(:installing_gems).and_return [
|
||||
double(gem_name: "bazbang", version: "0.0.1")
|
||||
]
|
||||
|
||||
allow(controller).to receive(:uninstalling_gems).and_return []
|
||||
|
||||
get :alerts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user