Skip to content

Commit

Permalink
Merge pull request #2997 from zendesk/grosser/periodical
Browse files Browse the repository at this point in the history
allow spaces in periodical to make it less surprising
  • Loading branch information
grosser authored Oct 12, 2018
2 parents ffd0494 + 1194b6b commit 4975212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/samson/periodical.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def env_settings(name)
end

def configs_from_string(string)
string.to_s.split(',').each_with_object({}) do |item, h|
string.to_s.split(/ ?, ?/).each_with_object({}) do |item, h|
name, execution_interval = item.split(':', 2)
config = {active: true}
config[:execution_interval] = Integer(execution_interval) if execution_interval
Expand Down
5 changes: 5 additions & 0 deletions test/lib/samson/periodical_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def with_registered

describe ".overdue?" do
with_env PERIODICAL: 'bar:10'

before do
Samson::Periodical.register(:foo, 'bar') { 111 }
Samson::Periodical.register(:bar, 'bar') { 111 }
Expand Down Expand Up @@ -144,6 +145,10 @@ def call(*args)
call('foo:123').must_equal(foo: {active: true, execution_interval: 123})
end

it "supports spaces around ," do
call('foo ,bar , baz').must_equal(foo: {active: true}, bar: {active: true}, baz: {active: true})
end

it "does not accept unknown arguments" do
assert_raises(ArgumentError) { call('foo:123:123') }
end
Expand Down

0 comments on commit 4975212

Please sign in to comment.