ref: master
plugins/spaminator/test/functional/spaminator_plugin_admin_controller_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
require 'test_helper' require_relative '../../controllers/spaminator_plugin_admin_controller' class SpaminatorPluginAdminControllerTest < ActionController::TestCase def setup @controller = SpaminatorPluginAdminController.new @environment = Environment.default @settings = Noosfero::Plugin::Settings.new(@environment, SpaminatorPlugin) login_as(create_admin_user(@environment)) end attr_accessor :settings, :environment should 'deploy spaminator' do SpaminatorPlugin.expects(:schedule_scan).with(environment) get :deploy reload_settings assert settings.deployed end should 'deploy spaminator when already deployed' do settings.deployed = true settings.save! SpaminatorPlugin.expects(:scheduled_scan).never get :deploy end should 'withhold spaminator' do settings.deployed = true settings.save! get :withhold reload_settings refute settings.deployed end should 'make spaminator scan' do Delayed::Job.expects(:enqueue) get :scan reload_settings assert settings.scanning end should 'not scan if already scanning' do settings.scanning = true settings.save! Delayed::Job.expects(:enqueue).never get :scan end should 'remove scheduled scan' do SpaminatorPlugin.schedule_scan(environment) reload_settings assert settings.scheduled_scan assert Delayed::Job.exists?(settings.scheduled_scan) @controller.stubs(:settings).returns(settings) @controller.send(:remove_scheduled_scan) reload_settings assert settings.scheduled_scan.nil? refute Delayed::Job.exists?(settings.scheduled_scan) end private def reload_settings environment.reload settings = Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin) end end |