mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Make action
a mandatory option in preparation for making it interpolated.
This commit is contained in:
parent
c1a2325d40
commit
2d790b54ea
5 changed files with 14 additions and 20 deletions
|
@ -12,7 +12,7 @@ module AgentControllerConcern
|
|||
end
|
||||
|
||||
def control_action
|
||||
options['action'].presence || 'run'
|
||||
options['action']
|
||||
end
|
||||
|
||||
def validate_control_action
|
||||
|
|
|
@ -19,7 +19,7 @@ module Agents
|
|||
|
||||
Set `action` to one of the action types below:
|
||||
|
||||
* `run`: This is the default. Target Agents are run at intervals.
|
||||
* `run`: Target Agents are run at intervals, except for those disabled.
|
||||
|
||||
* `disable`: Target Agents are disabled (if not) at intervals.
|
||||
|
||||
|
|
|
@ -86,11 +86,11 @@ describe Rufus::Scheduler do
|
|||
|
||||
stub.any_instance_of(Agents::SchedulerAgent).second_precision_enabled { true }
|
||||
|
||||
@agent1 = Agents::SchedulerAgent.new(name: 'Scheduler 1', options: { schedule: '*/1 * * * * *' }).tap { |a|
|
||||
@agent1 = Agents::SchedulerAgent.new(name: 'Scheduler 1', options: { action: 'run', schedule: '*/1 * * * * *' }).tap { |a|
|
||||
a.user = users(:bob)
|
||||
a.save!
|
||||
}
|
||||
@agent2 = Agents::SchedulerAgent.new(name: 'Scheduler 2', options: { schedule: '*/1 * * * * *' }).tap { |a|
|
||||
@agent2 = Agents::SchedulerAgent.new(name: 'Scheduler 2', options: { action: 'run', schedule: '*/1 * * * * *' }).tap { |a|
|
||||
a.user = users(:bob)
|
||||
a.save!
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ describe Agents::SchedulerAgent do
|
|||
let(:valid_params) {
|
||||
{
|
||||
name: 'Example',
|
||||
options: { 'schedule' => '0 * * * *' },
|
||||
options: {
|
||||
'action' => 'run',
|
||||
'schedule' => '0 * * * *'
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +76,10 @@ describe Agents::SchedulerAgent do
|
|||
|
||||
agent.memory['scheduled_at'] = time
|
||||
# Currently agent.options[]= is not detected
|
||||
agent.options = { 'schedule' => '*/5 * * * *' }
|
||||
agent.options = {
|
||||
'action' => 'run',
|
||||
'schedule' => '*/5 * * * *'
|
||||
}
|
||||
agent.save
|
||||
expect(agent.memory['scheduled_at']).to be_nil
|
||||
end
|
||||
|
|
|
@ -10,12 +10,12 @@ shared_examples_for AgentControllerConcern do
|
|||
|
||||
describe "validation" do
|
||||
it "should validate action" do
|
||||
['run', 'enable', 'disable', '', nil].each { |action|
|
||||
['run', 'enable', 'disable'].each { |action|
|
||||
agent.options['action'] = action
|
||||
expect(agent).to be_valid
|
||||
}
|
||||
|
||||
['delete', 1, true].each { |action|
|
||||
['delete', '', nil, 1, true].each { |action|
|
||||
agent.options['action'] = action
|
||||
expect(agent).not_to be_valid
|
||||
}
|
||||
|
@ -23,18 +23,6 @@ shared_examples_for AgentControllerConcern do
|
|||
end
|
||||
|
||||
describe 'control_action' do
|
||||
it "should be one of the supported values" do
|
||||
['run', '', nil].each { |action|
|
||||
agent.options['action'] = action
|
||||
expect(agent.control_action).to eq('run')
|
||||
}
|
||||
|
||||
['enable', 'disable'].each { |action|
|
||||
agent.options['action'] = action
|
||||
expect(agent.control_action).to eq(action)
|
||||
}
|
||||
end
|
||||
|
||||
it "cannot be 'run' if any of the control targets cannot be scheduled" do
|
||||
expect(agent.control_action).to eq('run')
|
||||
agent.control_targets = [agents(:bob_rain_notifier_agent)]
|
||||
|
|
Loading…
Add table
Reference in a new issue